/* =========================================================================
   REST Client - DevUtils Style
   ========================================================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark theme (default) */
    --primary: #6366F1;
    --primary-light: #818CF8;
    --primary-dim: #4F46E5;
    --bg: #0A0E1A;
    --bg-card: #12182A;
    --bg-card-hover: #1A2240;
    --bg-input: #0D1220;
    --border: rgba(99, 102, 241, 0.12);
    --border-hover: rgba(99, 102, 241, 0.25);
    --text: #E8ECFF;
    --text-dim: #8090BB;
    --text-muted: #506090;
    --success: #22C55E;
    --error: #EF4444;
    --warning: #F59E0B;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --container: 1200px;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-theme="light"] {
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F1F5F9;
    --bg-input: #F1F5F9;
    --border: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.3);
    --text: #1E293B;
    --text-dim: #64748B;
    --text-muted: #94A3B8;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Navigation --- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

[data-theme="light"] .nav {
    background: rgba(248, 250, 252, 0.85);
}

.nav-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    transition: color 0.2s var(--ease-out);
}

.nav-logo:hover {
    color: var(--primary-light);
}

.nav-icon {
    font-size: 20px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--bg-card-hover);
}

.icon-moon {
    display: none;
}

[data-theme="light"] .icon-sun {
    display: none;
}

[data-theme="light"] .icon-moon {
    display: block;
}

.lang-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    color: var(--text-dim);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s var(--ease-out);
}

.lang-select:hover {
    border-color: var(--border-hover);
}

/* --- Main --- */
.main {
    flex: 1;
    padding: 32px 24px 48px;
}

.container {
    max-width: var(--container);
    margin: 0 auto;
}

/* --- Header --- */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 15px;
}

/* --- Bento Grid --- */
.bento-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Bento Card --- */
.bento-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: border-color 0.2s var(--ease-out);
}

.bento-card:hover {
    border-color: var(--border-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Request Row --- */
.request-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.method-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s var(--ease-out);
    min-width: 110px;
}

.method-select:hover {
    border-color: var(--border-hover);
}

.method-select:focus {
    outline: none;
    border-color: var(--primary);
}

.url-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    transition: border-color 0.2s var(--ease-out);
}

.url-input:hover {
    border-color: var(--border-hover);
}

.url-input:focus {
    outline: none;
    border-color: var(--primary);
}

.url-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s var(--ease-out), transform 0.1s var(--ease-out);
}

.send-btn:hover {
    background: var(--primary-light);
}

.send-btn:active {
    transform: scale(0.98);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Section --- */
.section {
    margin-bottom: 16px;
}

.section:last-child {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.section-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.add-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.add-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* --- Headers List --- */
.headers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.header-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-key,
.header-value {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    transition: border-color 0.2s var(--ease-out);
}

.header-key:hover,
.header-value:hover {
    border-color: var(--border-hover);
}

.header-key:focus,
.header-value:focus {
    outline: none;
    border-color: var(--primary);
}

.header-key::placeholder,
.header-value::placeholder {
    color: var(--text-muted);
}

.remove-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* --- Body Editor --- */
.raw-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-dim);
}

.raw-toggle input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.body-editor {
    width: 100%;
    min-height: 140px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s var(--ease-out);
}

.body-editor:hover {
    border-color: var(--border-hover);
}

.body-editor:focus {
    outline: none;
    border-color: var(--primary);
}

.body-editor::placeholder {
    color: var(--text-muted);
}

/* --- Response Tabs --- */
.response-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.tab-btn {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.tab-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --- Response Meta --- */
.response-meta {
    display: flex;
    gap: 10px;
    align-items: center;
}

.status-badge {
    padding: 4px 10px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-card-hover);
    color: var(--text-dim);
}

.status-badge.success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.status-badge.redirect {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.time-badge {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Response Body --- */
.response-body-wrapper {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    max-height: 300px;
    overflow: auto;
}

.response-body {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

.response-body .placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
}

.response-headers {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    max-height: 300px;
    overflow: auto;
}

.response-headers .placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 13px;
}

.response-headers .header-item {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 12px;
}

.response-headers .header-item:last-child {
    border-bottom: none;
}

.response-headers .header-name {
    color: var(--primary-light);
    font-weight: 500;
    min-width: 180px;
}

.response-headers .header-val {
    color: var(--text);
    word-break: break-all;
}

/* --- History --- */
.history-card {
    margin-top: 20px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: border-color 0.2s var(--ease-out), background 0.2s var(--ease-out);
}

.history-item:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.history-method {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
}

.history-method.GET { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.history-method.POST { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.history-method.PUT { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.history-method.DELETE { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.history-method.PATCH { background: rgba(168, 85, 247, 0.15); color: #A855F7; }

.history-url {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
}

.history-status.success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.history-status.error { background: rgba(239, 68, 68, 0.15); color: var(--error); }

.history-placeholder {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.clear-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}

.clear-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* --- Placeholder Text --- */
.placeholder {
    color: var(--text-muted);
}

/* --- Syntax Highlighting --- */
.json-key { color: #818CF8; }
.json-string { color: #22C55E; }
.json-number { color: #F59E0B; }
.json-boolean { color: #EC4899; }
.json-null { color: #6B7280; }

/* --- Responsive --- */
@media (max-width: 600px) {
    .request-row {
        flex-wrap: wrap;
    }
    
    .method-select {
        width: 100%;
    }
    
    .url-input {
        width: 100%;
    }
    
    .send-btn {
        width: 100%;
    }
    
    .header h1 {
        font-size: 24px;
    }
}
