/* =============================================================================
   REST API Route Tester — modern UI (scoped to #wprrt-app)
   ============================================================================= */
#wprrt-app {
    margin-top: 8px;
    font-family: var(--wprrt-font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--wprrt-text);
    -webkit-font-smoothing: antialiased;

    /* Design tokens */
    --wprrt-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --wprrt-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --wprrt-radius: 12px;
    --wprrt-radius-sm: 8px;
    --wprrt-radius-xs: 6px;
    --wprrt-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 20px rgba(15, 23, 42, 0.06);
    --wprrt-shadow-dropdown: 0 12px 40px rgba(15, 23, 42, 0.14);
    --wprrt-bg-page: #f1f5f9;
    --wprrt-surface: #ffffff;
    --wprrt-surface-muted: #f8fafc;
    --wprrt-border: #e2e8f0;
    --wprrt-border-strong: #cbd5e1;
    --wprrt-text: #0f172a;
    --wprrt-text-muted: #64748b;
    --wprrt-accent: #3858e9;
    --wprrt-accent-hover: #2c4bdb;
    --wprrt-accent-soft: rgba(56, 88, 233, 0.12);
    --wprrt-danger: #dc2626;
    --wprrt-tab-bg: #e2e8f0;
    --wprrt-sidebar-width: 320px;
    --wprrt-workspace-gap: 24px;
    --wprrt-response-height: min(520px, calc(100vh - 180px));
}

/* -------------------------------------------------------------------------
   Two-column layout — sidebar + main
   ------------------------------------------------------------------------- */
.wprrt-layout {
    display: flex;
    align-items: stretch;
    gap: 20px;
}

/* Sidebar */
.wprrt-sidebar {
    width: var(--wprrt-sidebar-width);
    min-width: var(--wprrt-sidebar-width);
    flex-shrink: 0;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius);
    background: var(--wprrt-surface);
    box-shadow: var(--wprrt-shadow);
    overflow: hidden;
}

.wprrt-sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--wprrt-border);
    background: var(--wprrt-surface-muted);
}

.wprrt-sidebar-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--wprrt-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.wprrt-sidebar-tab:hover {
    color: var(--wprrt-text);
    background: rgba(255, 255, 255, 0.6);
}

.wprrt-sidebar-tab.active {
    color: var(--wprrt-accent);
    background: var(--wprrt-surface);
    box-shadow: inset 0 -2px 0 var(--wprrt-accent);
}

.wprrt-sidebar-panel {
    min-height: 120px;
}

.wprrt-history-toolbar {
    padding: 8px 12px;
    border-bottom: 1px solid var(--wprrt-border);
    text-align: right;
}

.wprrt-clear-history {
    font-size: 12px;
    color: var(--wprrt-text-muted);
    cursor: pointer;
    background: none;
    border: none;
    text-decoration: underline;
}

.wprrt-clear-history:hover {
    color: var(--wprrt-accent);
}

.wprrt-history-meta {
    font-size: 11px;
    font-weight: 600;
    color: var(--wprrt-text);
}

.wprrt-history-time {
    font-size: 10px;
    color: var(--wprrt-text-muted);
}

.wprrt-ai-connect-notice {
    margin: 0 20px 16px;
}

.wprrt-ai-error {
    margin: 0;
    color: #991b1b;
}

.wprrt-ai-loading {
    margin: 0;
    color: var(--wprrt-text-muted);
}

.wprrt-ai-connect-notice {
    padding: 10px 12px;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: var(--wprrt-radius-xs);
    font-size: 13px;
    line-height: 1.5;
    color: #92400e;
}

.wprrt-ai-connect-notice p {
    margin: 0 0 6px;
}

.wprrt-ai-connect-notice p:last-child {
    margin-bottom: 0;
}

.wprrt-ai-connect-link {
    font-weight: 600;
    color: var(--wprrt-accent);
    text-decoration: none;
}

.wprrt-ai-connect-link:hover {
    text-decoration: underline;
}

.wprrt-ai-actions--pending .button-link {
    opacity: 0.85;
}

.wprrt-sidebar-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(180deg, var(--wprrt-surface-muted) 0%, var(--wprrt-surface) 100%);
    border-bottom: 1px solid var(--wprrt-border);
    color: var(--wprrt-text-muted);
}

#wprrt-saved-list,
#wprrt-history-list {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Saved request items */
.wprrt-saved-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--wprrt-border);
    cursor: pointer;
    gap: 8px;
    transition: background 0.15s ease;
}

.wprrt-saved-item:last-child {
    border-bottom: none;
}

.wprrt-saved-item:hover {
    background: var(--wprrt-accent-soft);
}

.wprrt-saved-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.wprrt-saved-method {
    font-family: var(--wprrt-font-mono);
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.wprrt-saved-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--wprrt-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wprrt-saved-route {
    font-size: 11px;
    color: var(--wprrt-text-muted);
    font-family: var(--wprrt-font-mono);
    line-height: 1.35;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wprrt-saved-delete {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

.wprrt-saved-delete:hover {
    color: #d63638;
}

.wprrt-saved-empty {
    padding: 20px 16px;
    color: var(--wprrt-text-muted);
    font-size: 12px;
    line-height: 1.6;
}

/* Main content area */
.wprrt-main {
    flex: 1;
    min-width: 0;
}

/* -------------------------------------------------------------------------
   Auth preset dropdown
   ------------------------------------------------------------------------- */
.wprrt-auth-label {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    font-size: 13px;
    color: var(--wprrt-text);
}

.wprrt-section--headers .wprrt-auth-label {
    margin-bottom: 12px;
}

.wprrt-field--inline {
    max-width: 200px;
}

.wprrt-auth-type {
    margin-top: 0;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    background: var(--wprrt-surface);
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wprrt-auth-type:focus {
    border-color: var(--wprrt-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--wprrt-accent-soft);
}

/* -------------------------------------------------------------------------
   Save request form
   ------------------------------------------------------------------------- */
.wprrt-save-btn {
    /* uses .wprrt-btn--secondary */
}

.wprrt-save-form {
    display: none;
    margin-top: 8px;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--wprrt-surface-muted);
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-sm);
}


.wprrt-save-name {
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    width: 100%;
    box-sizing: border-box;
}

.wprrt-save-actions {
    display: flex;
    gap: 6px;
}

.wprrt-save-confirm {
    padding: 8px 16px;
    background: var(--wprrt-accent);
    color: #fff;
    border: none;
    border-radius: var(--wprrt-radius-xs);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s ease;
}

.wprrt-save-confirm:hover {
    background: var(--wprrt-accent-hover);
}

.wprrt-save-cancel {
    padding: 8px 14px;
    background: var(--wprrt-surface);
    color: var(--wprrt-text-muted);
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s ease;
}

.wprrt-save-cancel:hover {
    background: var(--wprrt-surface-muted);
}
.wprrt-workspace {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.1fr);
    gap: var(--wprrt-workspace-gap);
    align-items: start;
}

.wprrt-form {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: var(--wprrt-surface);
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius);
    box-shadow: var(--wprrt-shadow);
}
.wprrt-section {
    padding: 18px 20px;
    border-bottom: 1px solid var(--wprrt-border);
}

.wprrt-section:last-of-type {
    border-bottom: none;
}

.wprrt-section-title {
    margin: 0 0 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--wprrt-text-muted);
}

.wprrt-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--wprrt-text);
    margin: 0 0 12px;
}

.wprrt-field--grow {
    flex: 1;
    min-width: 0;
}

.wprrt-field-row {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.wprrt-field-row--2 {
    grid-template-columns: 1fr 1fr;
}

.wprrt-field-hint,
.wprrt-label-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--wprrt-text-muted);
    line-height: 1.4;
}

.wprrt-label-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
}

.wprrt-label-row-actions {
    flex-shrink: 0;
    padding-top: 22px;
}

.wprrt-form label.wprrt-field,
.wprrt-form .wprrt-field {
    display: flex;
    flex-direction: column;
}

.wprrt-form select,
.wprrt-form textarea,
.wprrt-form input[type="text"] {
    padding: 10px 12px;
    font-size: 14px;
    margin-top: 0;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    background: var(--wprrt-surface);
    color: var(--wprrt-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.wprrt-form select:focus,
.wprrt-form textarea:focus,
.wprrt-form input[type="text"]:focus {
    border-color: var(--wprrt-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--wprrt-accent-soft);
}
/* Buttons */
.wprrt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    border-radius: var(--wprrt-radius-xs);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wprrt-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.wprrt-btn-icon {
    font-size: 14px;
    line-height: 1;
}

.wprrt-btn--primary {
    background: var(--wprrt-accent);
    color: #fff;
}

.wprrt-btn--primary:hover:not(:disabled) {
    background: var(--wprrt-accent-hover);
}

.wprrt-btn--secondary {
    background: var(--wprrt-surface);
    color: var(--wprrt-text);
    border-color: var(--wprrt-border-strong);
}

.wprrt-btn--secondary:hover:not(:disabled) {
    background: var(--wprrt-surface-muted);
}

.wprrt-btn--soft {
    background: var(--wprrt-accent-soft);
    color: var(--wprrt-accent);
    border-color: transparent;
}

.wprrt-btn--soft:hover:not(:disabled) {
    background: rgba(56, 88, 233, 0.2);
}

.wprrt-btn--ghost {
    background: transparent;
    color: var(--wprrt-accent);
    border-color: var(--wprrt-border);
}

.wprrt-btn--ghost:hover:not(:disabled) {
    background: var(--wprrt-accent-soft);
    border-color: var(--wprrt-accent);
}

.wprrt-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 20px;
    background: var(--wprrt-surface-muted);
    border-top: 1px solid var(--wprrt-border);
}

.wprrt-form-actions .wprrt-test {
    flex: 1;
    min-width: 140px;
}

.wprrt-response-block {
    min-width: 0;
    height: var(--wprrt-response-height);
    max-height: var(--wprrt-response-height);
    background: var(--wprrt-surface);
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius);
    box-shadow: var(--wprrt-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wprrt-response-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--wprrt-surface-muted);
    border-bottom: 1px solid var(--wprrt-border);
}

.wprrt-response-toolbar-start {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.wprrt-response-toolbar-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--wprrt-text-muted);
}

.wprrt-response-toolbar-end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wprrt-response-tabs {
    display: inline-flex;
    padding: 3px;
    background: var(--wprrt-tab-bg);
    border-radius: var(--wprrt-radius-xs);
    gap: 2px;
}

.wprrt-response-tab {
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    color: var(--wprrt-text-muted);
    border-radius: 4px;
    cursor: pointer;
}

.wprrt-response-tab:hover:not(:disabled) {
    color: var(--wprrt-text);
}

.wprrt-response-tab.is-active {
    background: var(--wprrt-surface);
    color: var(--wprrt-accent);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.wprrt-response-tab:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.wprrt-response-views {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wprrt-response-view {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0;
}

.wprrt-response-view.is-active {
    display: flex;
}

.wprrt-response-block .wprrt-response-headers {
    margin: 12px 16px 0;
    flex-shrink: 0;
    max-height: 120px;
    overflow-y: auto;
}

.wprrt-response-block pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-family: var(--wprrt-font-mono);
    font-size: 13px;
}

.wprrt-response-block pre.wprrt-response,
.wprrt-response-block pre.wprrt-response-json {
    flex: 1;
    min-height: 0;
    margin: 12px 16px 16px;
    overflow-x: auto;
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-width: thin;
    padding: 14px 16px;
    border-radius: var(--wprrt-radius-sm);
    background: var(--wprrt-surface-muted);
    border: 1px solid var(--wprrt-border);
}

.wprrt-ai-panel {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    margin: 0;
    padding: 16px 18px;
    box-sizing: border-box;
    scrollbar-width: thin;
    background: linear-gradient(180deg, #f8faff 0%, var(--wprrt-surface) 100%);
    font-size: 14px;
    line-height: 1.6;
}

.wprrt-ai-text {
    margin: 0;
    white-space: pre-wrap;
    font-family: var(--wprrt-font-sans);
    font-size: 14px;
    color: var(--wprrt-text);
}

.wprrt-ai-empty,
.wprrt-ai-loading {
    margin: 0;
    color: var(--wprrt-text-muted);
    font-size: 13px;
    line-height: 1.55;
}

.wprrt-ai-loading {
    font-style: italic;
}

.wprrt-body-suggestion {
    margin: 0 0 12px;
    padding: 12px 14px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--wprrt-radius-sm);
}

.wprrt-body-suggestion-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.wprrt-body-suggestion-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #0369a1;
}

.wprrt-body-suggestion-actions {
    display: flex;
    gap: 6px;
}

.wprrt-body-suggestion-preview {
    margin: 0;
    padding: 10px 12px;
    max-height: 160px;
    overflow: auto;
    background: var(--wprrt-surface);
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    font-family: var(--wprrt-font-mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.wprrt-body-suggestion-error {
    margin: 8px 0 0;
    color: #991b1b;
    font-size: 13px;
}

.wprrt-status-idle {
    background: #f1f5f9;
    color: var(--wprrt-text-muted);
}

.wprrt-response-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}
.wprrt-role-selector {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 0;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    background-color: var(--wprrt-surface);
}
.wprrt-controls {
    margin-bottom: 0;
    padding: 16px 18px;
    background: var(--wprrt-surface);
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius);
    box-shadow: var(--wprrt-shadow);
}
.wprrt-tabs-container {
    margin-top: 20px;
}
.wprrt-tabs-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 0;
    margin-bottom: 16px;
    border-bottom: none;
}
.wprrt-tabs {
    display: flex;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: thin;
    gap: 6px;
    padding: 4px;
    background: var(--wprrt-tab-bg);
    border-radius: var(--wprrt-radius-sm);
}
.wprrt-tab-header {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: var(--wprrt-radius-xs);
    margin-right: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    color: var(--wprrt-text-muted);
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.wprrt-tab-header:hover {
    background: rgba(255, 255, 255, 0.7);
    color: var(--wprrt-text);
}
.wprrt-tab-header.active {
    background: var(--wprrt-surface);
    color: var(--wprrt-text);
    box-shadow: var(--wprrt-shadow);
    margin-bottom: 0;
    border: none;
}
.wprrt-tab-title {
    font-size: 13px;
}
.wprrt-close-tab {
    background: none;
    border: none;
    color: var(--wprrt-text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
}
.wprrt-close-tab:hover {
    color: var(--wprrt-danger);
    background: rgba(220, 38, 38, 0.08);
}
.wprrt-add-tab {
    padding: 10px 16px;
    background: var(--wprrt-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    border-radius: var(--wprrt-radius-xs);
    margin-left: 0;
    flex-shrink: 0;
    transition: background 0.15s ease;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.wprrt-add-tab:hover {
    background: var(--wprrt-accent-hover);
}
.wprrt-tab-content {
    display: none;
}
.wprrt-tab-content.active {
    display: block;
}
.wprrt-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    background: var(--wprrt-surface-muted);
    border: 2px dashed var(--wprrt-border-strong);
    border-radius: var(--wprrt-radius);
}
.wprrt-empty-inner {
    text-align: center;
    color: var(--wprrt-text-muted);
}
.wprrt-empty-icon {
    font-size: 36px;
    margin-bottom: 8px;
}
.wprrt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}
.wprrt-loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--wprrt-border);
    border-top-color: var(--wprrt-accent);
    border-radius: 50%;
    animation: wprrt-spin 0.85s linear infinite;
    margin-bottom: 16px;
}
.wprrt-error {
    padding: 20px 22px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--wprrt-radius-sm);
    color: #991b1b;
    margin: 20px 0;
}
@keyframes wprrt-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Field container and help text styles */
.wprrt-field-container {
    position: relative;
}

.wprrt-field-help {
    margin-top: 6px;
    color: var(--wprrt-text-muted);
    font-style: normal;
}

.wprrt-field-help small {
    font-size: 12px;
    line-height: 1.4;
}

/* Enhanced textarea styling for JSON fields */
.wprrt-headers,
.wprrt-body {
    font-family: var(--wprrt-font-mono);
    font-size: 13px;
    line-height: 1.4;
    resize: vertical;
    min-height: 80px;
    width: 100%;
    box-sizing: border-box;
}

.wprrt-headers::placeholder,
.wprrt-body::placeholder {
    color: #999;
    font-style: italic;
    opacity: 0.8;
}

/* Response meta — shown in toolbar after first request */
.wprrt-response-toolbar .wprrt-response-meta {
    display: none;
}

.wprrt-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: bold;
    font-family: monospace;
    letter-spacing: 0.03em;
}

.wprrt-status-2xx { background: #d1fae5; color: #065f46; }
.wprrt-status-3xx { background: #dbeafe; color: #1e3a8a; }
.wprrt-status-4xx { background: #fef3c7; color: #92400e; }
.wprrt-status-5xx { background: #fee2e2; color: #7f1d1d; }
.wprrt-status-error { background: #f3f4f6; color: #374151; }

.wprrt-response-time {
    font-size: 12px;
    color: var(--wprrt-text-muted);
    font-family: var(--wprrt-font-mono);
}

/* Collapsible response headers */
.wprrt-response-headers {
    display: none;
    margin-bottom: 12px;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    overflow: hidden;
    background: var(--wprrt-surface);
}

.wprrt-response-headers summary {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
    color: #555;
    cursor: pointer;
    background: #f9fafb;
    user-select: none;
}

.wprrt-response-headers summary:hover {
    background: #f3f4f6;
}

.wprrt-response-headers .wprrt-headers-body {
    margin: 0;
    padding: 8px 12px;
    font-size: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    white-space: pre-wrap;
    word-break: break-all;
    color: #374151;
}

/* Route dropdown styling */
.wprrt-route-dropdown {
    display: none;
    background: var(--wprrt-surface);
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-sm);
    box-shadow: var(--wprrt-shadow-dropdown);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
}


.wprrt-route-option {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--wprrt-border);
    font-family: var(--wprrt-font-mono);
    font-size: 12px;
}

.wprrt-route-option:hover {
    background-color: var(--wprrt-accent-soft);
}

.wprrt-route-option:last-child {
    border-bottom: none;
}

/* -------------------------------------------------------------------------
   URL parameter inputs
   ------------------------------------------------------------------------- */
.wprrt-params-container {
    margin-top: 6px;
}

.wprrt-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.wprrt-param-label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-weight: normal;
    font-size: 13px;
}

.wprrt-param-name {
    font-family: var(--wprrt-font-mono);
    font-size: 11px;
    color: var(--wprrt-accent);
    font-weight: 700;
}

.wprrt-param-input {
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-xs);
    width: 100%;
    box-sizing: border-box;
    font-family: var(--wprrt-font-mono);
    margin-top: 0;
}

.wprrt-param-input:focus {
    border-color: var(--wprrt-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--wprrt-accent-soft);
}

/* Legacy button classes map to .wprrt-btn in markup */

/* -------------------------------------------------------------------------
   PrismJS syntax highlighting — GitHub-flavoured light theme
   Applied to .wprrt-response.language-json
   ------------------------------------------------------------------------- */
.wprrt-response.language-json {
    background: #f8fafc;
    border: 1px solid var(--wprrt-border);
    border-radius: var(--wprrt-radius-sm);
    color: #1e293b;
    /* Keep Prism theme inside the scrollable box. */
    display: block;
}

.wprrt-response .token.property {
    color: #6f42c1; /* JSON keys — purple */
}

.wprrt-response .token.string {
    color: #032f62; /* string values — dark blue */
}

.wprrt-response .token.number {
    color: #005cc5; /* numbers — blue */
}

.wprrt-response .token.boolean,
.wprrt-response .token.null.keyword {
    color: #d73a49; /* true / false / null — red */
}

.wprrt-response .token.punctuation,
.wprrt-response .token.operator {
    color: #6a737d; /* brackets, colons — grey */
}

/* -------------------------------------------------------------------------
   Layout helpers (replaces inline styles in markup)
   ------------------------------------------------------------------------- */
.wprrt-form .wprrt-plugin {
    width: 100%;
    margin-top: 6px;
}

.wprrt-route-container {
    position: relative;
}

.wprrt-route-container .wprrt-route {
    width: 100%;
    box-sizing: border-box;
}

.wprrt-route-container .wprrt-route-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 4px;
}

/* Keyboard focus — modern ring */
#wprrt-app button:focus-visible,
#wprrt-app select:focus-visible,
#wprrt-app input:focus-visible,
#wprrt-app textarea:focus-visible,
#wprrt-app summary:focus-visible {
    outline: 2px solid var(--wprrt-accent);
    outline-offset: 2px;
}

/* Sticky response on wide screens */
@media (min-width: 1100px) {
    #wprrt-app .wprrt-response-block {
        position: sticky;
        top: 40px;
    }
}

@media (max-width: 1100px) {
    #wprrt-app .wprrt-workspace {
        grid-template-columns: 1fr;
    }

    #wprrt-app {
        --wprrt-response-height: min(420px, calc(100vh - 200px));
    }
}

/* Narrow admin / laptop */
@media (max-width: 960px) {
    #wprrt-app {
        --wprrt-sidebar-width: 100%;
    }

    #wprrt-app .wprrt-layout {
        flex-direction: column;
    }

    #wprrt-app .wprrt-sidebar {
        width: 100%;
        min-width: 0;
    }

    #wprrt-app .wprrt-field-row--2 {
        grid-template-columns: 1fr;
    }

    #wprrt-app .wprrt-label-row {
        flex-direction: column;
    }

    #wprrt-app .wprrt-label-row-actions {
        padding-top: 0;
    }

    #wprrt-app {
        --wprrt-response-height: min(360px, calc(100vh - 220px));
    }
}
