:root {
    --primary: #4facfe;
    --primary-dark: #3d9ae8;
    --gradient: linear-gradient(135deg, #4facfe 0%, #00c6fb 100%);
    --bg: #f5f7fa;
    --card-bg: #fff;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --text: #1a202c;
    --text-muted: #4a5568;
    --selected-bg: #e0f2fe;
    --hover-bg: #f8fafc;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --input-bg: #f8fafc;
    --scrollbar-thumb: #c1c9d4;
    --scrollbar-thumb-hover: #a0aab6;
    --scrollbar-track: transparent;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.3);
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --selected-bg: #1e3a5f;
    --hover-bg: #334155;
    --code-bg: #002240;
    --code-text: #ffffff;
    --input-bg: #002240;
    --scrollbar-thumb: #475569;
    --scrollbar-thumb-hover: #64748b;
    --scrollbar-track: transparent;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* App Layout - sticky footer */
.app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.header {
    background: var(--gradient);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-logo .logo { height: 40px; display: block; }
.header-title {
    color: white;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.header-message { flex: 1; text-align: center; }

#message {
    display: inline-block;
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 16px;
    color: white;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    min-width: 60%;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#message.alert-success { background: #059669; }
#message.alert-error { background: #ef4444; }
#message.alert-warning { background: #fde047; color: #1a202c; }

/* Main */
.main {
    flex: 1;
    display: flex;
    padding: 16px;
    overflow: hidden;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width, 240px);
    flex-shrink: 0;
    min-width: 160px;
}
.sidebar .panel-body { padding: 0; }

.sidebar a { color: var(--text); }
.sidebar a:hover { color: var(--primary); }

.service-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.service-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}
.service-list li:last-child { border-bottom: none; }
.service-list li:hover { background: var(--hover-bg); }
.service-list li.selected-service {
    background: var(--selected-bg);
    color: var(--primary);
    font-weight: 600;
}

.service-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-count { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.star-toggle {
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted);
    transition: color 0.2s;
    flex-shrink: 0;
}
.star-toggle:hover { color: var(--primary); }
.star-toggle.starred { color: var(--primary); }

/* Content - now just a layout container, panes are their own cards */
.content {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-header h3#container-title { margin: 0; font-size: 13px; font-weight: 600; white-space: nowrap; }

#fixed-service-container { flex: 1; min-height: 0; }

/* Content Panels - 2 column layout with resizer */
.content-panels {
    display: flex;
    height: 100%;
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.panel-resources {
    width: var(--resources-width, 50%);
    flex-shrink: 0;
    min-width: 200px;
}

.panel-results {
    flex: 1;
    min-width: 200px;
}

/* Configuration view occupies the LEFT pane only; hide the right pane and the inter-pane resizer. */
.content-panels.view-config .panel-results,
.content-panels.view-config > .panel-resizer { display: none; }
.content-panels.view-config .panel-resources { width: 100%; }

.panel-resizer {
    width: 16px;
    flex-shrink: 0;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-resizer-handle {
    width: 3px;
    height: 32px;
    border-radius: 2px;
    background: var(--border);
    transition: background 0.15s, height 0.15s;
}

.panel-resizer:hover .panel-resizer-handle,
.panel-resizer.dragging .panel-resizer-handle {
    background: var(--primary);
    height: 48px;
}

.content-panels.resizing {
    user-select: none;
    cursor: col-resize;
}

.panel-header {
    padding: 0 16px;
    height: 48px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-header h4 { margin: 0; font-size: 13px; font-weight: 600; display: inline; flex: 1; }

/* Preset controls */
#preset-controls { display: flex; align-items: center; gap: 8px; font-size: 12px; }
#preset-label { color: var(--text-muted); white-space: nowrap; }
#preset-controls select { width: auto; min-width: 140px; padding: 4px 8px; font-size: 12px; color: var(--text); background: var(--input-bg); }
#preset-save-as, #preset-delete { cursor: pointer; color: var(--text-muted); font-size: 13px; }
#preset-save-as:hover, #preset-delete:hover { color: var(--primary); }

.panel-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: var(--card-bg);
}

/* Resources table */
#fixed-service-table-list {
    width: calc(100% + 24px);
    margin-left: -12px;
    margin-right: -12px;
    border-collapse: collapse;
}
#fixed-service-table-list th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
}
#fixed-service-table-list th:nth-child(1) { width: 40px; text-align: center; }
#fixed-service-table-list th:nth-child(2) { width: 70px; text-align: center; }

#fixed-service-table-list td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
#fixed-service-table-list td:nth-child(1) { text-align: center; }
#fixed-service-table-list td:nth-child(2) { text-align: center; }

#fixed-service-table-body tr { cursor: pointer; }
#fixed-service-table-body tr:hover { background: var(--hover-bg); }
#fixed-service-table-body tr.selected-resource { background: var(--selected-bg); }
#fixed-service-table-body tr.selected-resource .fixed-resource-path { color: var(--primary); }

/* Method badges */
.fixed-resource-method { font-weight: 600; font-size: 11px; }
.fixed-resource-method.get { color: #10b981; }
.fixed-resource-method.post { color: #3b82f6; }
.fixed-resource-method.put { color: #f59e0b; }
.fixed-resource-method.patch { color: #8b5cf6; }
.fixed-resource-method.delete { color: #ef4444; }

.fixed-resource-path {
    color: var(--primary);
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
}

/* Static-override badge: pinned to the right edge of the path cell so
   the path keeps the full row width for truncation. Positioned
   absolutely so the table-cell layout stays intact (display:flex on a
   <td> would break it). */
.static-badge {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 6px 1px 5px;
    border-radius: 4px;
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.12);
    line-height: 1.4;
    pointer-events: auto;
}
.static-badge svg {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
}
/* Reserve horizontal space so the absolutely-positioned badge never
   overlaps the path text. Targets only rows that actually carry a badge. */
.fixed-resource-path:has(.static-badge) > span:first-child {
    padding-right: 64px;
}

/* Inputs */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--hover-bg);
    width: 100%;
    transition: border-color 0.2s, background 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card-bg);
}

/* Buttons */
button, input[type="submit"] {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
button:hover { background: var(--primary-dark); }

/* Accordion - collapsed by default */
.accordion { margin-bottom: 12px; }
.accordion-header {
    padding: 10px 12px;
    background: var(--hover-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}
.accordion-header:hover { background: var(--border); }
.accordion-content {
    display: none;
    padding: 12px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    background: var(--card-bg);
}
.accordion-content.active { display: block; }
.accordion-header.expanded { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

/* Config override rows */
.config-override-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.config-override-row:last-child { margin-bottom: 0; }
.config-override-row input[type="checkbox"] {
    width: auto;
    flex-shrink: 0;
    cursor: pointer;
}
.config-override-row label {
    width: 160px;
    font-size: 13px;
    flex-shrink: 0;
    cursor: pointer;
}
.config-override-row input[type="text"] {
    flex: 1;
    min-width: 0;
    color: var(--text);
    background: var(--input-bg);
}
.config-override-row select,
.config-override-row input#override-latency-value,
.config-override-row input#override-validate-timeout-value {
    flex: 0 0 auto;
    width: 90px;
    min-width: 0;
    color: var(--text);
    background: var(--input-bg);
}

/* Custom header rows */
.custom-header-row .custom-header-name {
    width: 30%;
    flex: 0 0 30%;
    min-width: 0;
    color: var(--text);
    background: var(--input-bg);
}
.custom-header-row .custom-header-value {
    flex: 1;
    min-width: 0;
    color: var(--text);
    background: var(--input-bg);
}

.btn-add {
    margin-top: 8px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--hover-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.btn-add:hover { background: var(--border); color: var(--text); }

.btn-remove {
    padding: 4px 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.2s;
}
.btn-remove:hover { color: #ef4444; background: transparent; }

.btn-eye {
    padding: 4px 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.2s;
}
.btn-eye:hover { color: var(--primary); background: transparent; }

/* Code blocks */
pre, .code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
    font-family: 'Monaco', 'Menlo', monospace;
}

#example-curl {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

#request-path {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.accordion-content { position: relative; }
.tab-pane { position: relative; }
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.accordion-content:hover .copy-btn,
.tab-pane:hover .copy-btn { opacity: 0.7; }
.copy-btn:hover { background: var(--primary-dark); opacity: 1; }

/* Resource panel sub-tabs (separate row below panel-header) */
.panel-tabs {
    display: flex;
    gap: 0;
    padding: 0 12px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 38px;
    align-items: stretch;
}
.panel-tabs-spacer { /* placeholder strip; keeps panel bodies aligned across cards */ padding: 4px 12px; }

/* Empty-state hint shown in right pane body when no resource/entry is selected */
.empty-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

/* Configuration editor: wrap gives the editor a relative parent so the copy button can sit at top-right */
.config-editor-wrap {
    position: relative;
    width: 100%;
    height: 100%;
}
.config-editor-wrap:hover .copy-btn { opacity: 0.7; }

.filter-input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--hover-bg);
    color: var(--text);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, background 0.15s;
}
.filter-input:hover { border-color: var(--text-muted); }
.filter-input:focus { outline: none; background: var(--card-bg); border-color: var(--primary); }
.filter-input::placeholder { color: var(--text-muted); }

.resource-filter-row { margin-bottom: 8px; }
.content-panels.view-history .resource-filter-row,
.content-panels.view-replay .resource-filter-row,
.content-panels.view-config .resource-filter-row { display: none; }

.resource-tab {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}
.resource-tab:hover { color: var(--text); background: var(--hover-bg); }
.resource-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.resource-tab .response-status-badge { margin-left: 6px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; height: 100%; }

/* Editor-based tab-panes also need the body to flex so the editor fills available height */
#generator-container, #history-detail, #replay-detail { height: 100%; }

/* Resource edit table */
.resource-edit-table { width: 100%; }
.resource-edit-table td { padding: 8px; vertical-align: top; }

/* Refresh icon */
#refresh {
    display: none;
    cursor: pointer;
    color: var(--primary);
    margin-left: 4px;
    font-size: 14px;
    vertical-align: middle;
}

/* Footer - sticky */
.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    gap: 24px;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-muted);
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--primary); }
.footer-theme { display: flex; align-items: center; gap: 6px; }
.footer-theme select {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text);
    font-size: inherit;
    text-transform: capitalize;
}

/* Response headers table */
.response-headers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', monospace;
}
.response-headers-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border);
}
.response-headers-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    word-break: break-all;
}
.response-headers-table td:first-child {
    white-space: nowrap;
    font-weight: 600;
    color: var(--primary);
    width: 1%;
    padding-right: 20px;
}
.response-headers-table tr:last-child td { border-bottom: none; }

/* Details (history summary) table - similar layout, but labels are muted, not link-blue */
.history-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.history-summary-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    word-break: break-all;
}
.history-summary-table td:first-child {
    white-space: nowrap;
    color: var(--text-muted);
    font-weight: 500;
    width: 1%;
    padding-right: 20px;
}
.history-summary-table tr:last-child td { border-bottom: none; }

/* Theme toggle */
.theme-toggle {
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.1);
    transition: background 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.2); }

/* Service tabs (section tabs inside page-bar) */
.service-tabs {
    display: flex;
    gap: 0;
    align-self: stretch;
    align-items: center;
}

.service-tab {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 100%;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.service-tab:hover { color: var(--text); background: var(--hover-bg); }
.service-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* History container */
#history-container { flex: 1; min-height: 0; }

/* History table */
#history-table-list,
#replay-table-list {
    width: calc(100% + 24px);
    margin-left: -12px;
    margin-right: -12px;
    border-collapse: collapse;
}
#history-table-list th,
#replay-table-list th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
}
/* Shared columns: 1=# | 2=Method | 4=Status | 6=Time */
#history-table-list th:nth-child(1),
#replay-table-list th:nth-child(1) { width: 40px; text-align: center; }
#history-table-list th:nth-child(2),
#replay-table-list th:nth-child(2) { width: 70px; text-align: center; }
#history-table-list th:nth-child(4),
#replay-table-list th:nth-child(4) { width: 60px; text-align: center; }
#history-table-list th:nth-child(6),
#replay-table-list th:nth-child(6) { width: 70px; text-align: right; }
/* Col 5: history = Duration (right); replay = Match (left). Both fixed-width so
   PATH (col 3) is the only flexible column and the table stays aligned. */
#history-table-list th:nth-child(5) { width: 70px; text-align: right; }
#replay-table-list th:nth-child(5) { width: 160px; text-align: left; }

#history-table-list td,
#replay-table-list td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
#history-table-list td:nth-child(1),
#replay-table-list td:nth-child(1) { text-align: center; }
#history-table-list td:nth-child(2),
#replay-table-list td:nth-child(2) { text-align: center; }

#history-table-body tr,
#replay-table-body tr { cursor: pointer; }
#history-table-body tr:hover,
#replay-table-body tr:hover { background: var(--hover-bg); }
#history-table-body tr.selected-resource,
#replay-table-body tr.selected-resource { background: var(--selected-bg); }

/* Status code colors */
.history-status { font-weight: 600; text-align: center; }
.status-2xx { color: #10b981; }
.status-4xx { color: #f59e0b; }
.status-5xx { color: #ef4444; }

/* History time */
.history-time { text-align: right; color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* History action buttons */
.history-actions { display: flex; gap: 8px; }
.history-action-btn {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    transition: color 0.15s;
}
.history-action-btn:hover { color: var(--primary); }

/* History duration and source columns */
.history-duration { text-align: right; color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* Replay match column (key fields) and match-values heading */
.replay-match {
    color: var(--text-muted);
    font-size: 12px;
    font-family: monospace;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.replay-match-heading {
    margin: 12px 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Response status badge */
.response-status-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
}
.response-status-badge.status-2xx { color: #10b981; background: rgba(16, 185, 129, 0.12); }
.response-status-badge.status-3xx { color: #3b82f6; background: rgba(59, 130, 246, 0.12); }
.response-status-badge.status-4xx { color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.response-status-badge.status-5xx { color: #ef4444; background: rgba(239, 68, 68, 0.12); }
.response-status-badge:empty { display: none; }

/* Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
::-webkit-scrollbar-corner { background: var(--scrollbar-track); }

