/*
   HTTP HEADER VIEWER - EXPERT WEB TOOLS
*/

@font-face { font-family: 'Inter';       src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Orbitron';    src: url('/fonts/orbitron-v35-latin-700.woff2')  format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Roboto Mono'; src: url('/fonts/roboto-mono-v31-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

/* === VARIABLES === */
:root {
    --bg-dark:          #0a0a0f;
    --primary-accent:   #3b82f6;
    --secondary-accent: #8b5cf6;
    --text-main:        #ffffff;
    --text-muted:       #94a3b8;
    --card-bg:          rgba(25, 25, 35, 0.6);
    --card-border:      rgba(255, 255, 255, 0.08);
    --input-bg:         rgba(255, 255, 255, 0.05);
    
    --status-2xx:       #34d399;
    --status-3xx:       #fbbf24;
    --status-4xx:       #f87171;
    --link-color:       #60a5fa;
    --link-hover:       #93c5fd;
    
    --font-heading:     'Orbitron', sans-serif;
    --font-body:        'Inter', sans-serif;
    --font-code:        'Roboto Mono', monospace;
}

/* Light Theme Overrides (Synchronized Architecture) */
html.light-theme {
    --bg-dark:          #f8fafc;
    --primary-accent:   #2563eb;
    --secondary-accent: #7c3aed;
    --text-main:        #0f172a;
    --text-muted:       #475569;
    --card-bg:          #ffffff;
    --card-border:      #cbd5e1;
    --input-bg:         #f1f5f9;
    
    --status-2xx:       #059669;
    --status-3xx:       #d97706;
    --status-4xx:       #dc2626;
    --link-color:       #2563eb;
    --link-hover:       #1d4ed8;
}

/* === BASE & RESET === */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; max-width: 100vw; overflow-x: hidden; }

/* STRICT CHROMIUM BUG FIX: transition background-color only */
html, body {
    background-color: var(--bg-dark);
    transition: background-color 0.2s ease;
}

body { 
    color: var(--text-main); 
    font-family: var(--font-body); 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

.code-inline {
    font-family: var(--font-code); 
    background: rgba(255,255,255,0.08);
    padding: 1px 5px; 
    border-radius: 4px; 
    font-size: 0.9em; 
    color: #93c5fd;
}
html.light-theme .code-inline { background: rgba(0,0,0,0.05); color: var(--primary-accent); }

/* === LAYOUT === */
.background-glow {
    position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59,130,246,0.08) 0%, rgba(10,10,15,0) 50%);
    z-index: -1; pointer-events: none; transition: opacity 0.3s;
}
html.light-theme .background-glow { opacity: 0.5; }

.tool-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem 5%; max-width: 1400px; margin: 0 auto; width: 100%;
}
.back-btn {
    color: var(--text-muted); text-decoration: none;
    display: flex; align-items: center; gap: 8px;
    transition: color 0.3s; border-radius: 4px; padding: 2px 4px;
}
.back-btn:hover, .back-btn:focus-visible { color: var(--primary-accent); outline-offset: 4px; }

.logo { font-family: var(--font-heading); font-size: 1.2rem; }
.logo span { color: var(--primary-accent); }

.theme-toggle-btn {
    background: transparent; border: 1px solid var(--card-border); 
    color: var(--text-muted); font-size: 1.2rem; cursor: pointer; 
    min-width: 44px; min-height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; 
    transition: color 0.2s, border-color 0.2s;
}
.theme-toggle-btn:hover { color: var(--primary-accent); border-color: var(--primary-accent); }

.main-content { flex-grow: 1; padding: 2rem 5%; max-width: 1000px; margin: 0 auto; width: 100%; }

.tool-container {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 16px; padding: 2rem; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    transition: background-color 0.3s, border-color 0.3s;
}

.tool-intro { text-align: center; margin-bottom: 2rem; }
.tool-intro h1 { font-family: var(--font-heading); margin-bottom: 0.5rem; font-size: 2rem; }
.tool-intro p { color: var(--text-muted); }

/* === FORM ELEMENTS === */
.url-input-wrapper { display: flex; gap: 10px; margin-bottom: 1rem; align-items: stretch; }

.identity-select {
    background: var(--input-bg); border: 1px solid var(--card-border);
    color: var(--text-main); padding: 12px 15px; border-radius: 8px;
    font-size: 0.9rem; font-family: var(--font-body);
    outline: none; cursor: pointer; transition: border-color 0.2s;
}
.identity-select option { background: var(--bg-dark); color: var(--text-main); }
html.light-theme .identity-select option { background: #ffffff; color: #0f172a; }
.identity-select:focus-visible { outline: 2px solid var(--primary-accent); }

.url-input {
    flex: 1; background: var(--input-bg); border: 1px solid var(--card-border);
    color: var(--text-main); padding: 12px 15px; border-radius: 8px;
    font-size: 1rem; font-family: var(--font-code); outline: none; transition: border-color 0.2s; min-width: 0;
}
.url-input:focus { border-color: var(--primary-accent); }

.fetch-btn {
    background: var(--primary-accent); color: white; border: none;
    padding: 0 24px; border-radius: 8px; font-weight: 600; cursor: pointer;
    transition: background 0.2s; font-size: 1rem; white-space: nowrap;
    display: flex; align-items: center; gap: 8px; min-height: 46px;
}
.fetch-btn:hover:not(:disabled) { background: #2563eb; }
.fetch-btn:disabled { background: #64748b; cursor: not-allowed; }

.tool-options-wrapper { margin-bottom: 1.5rem; padding: 0 5px; }
.checkbox-wrapper {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted); font-size: 0.9rem; cursor: pointer;
}
.checkbox-wrapper input[type="checkbox"] {
    width: 16px; height: 16px; accent-color: var(--primary-accent); cursor: pointer;
}

/* Accordion Custom Headers */
.custom-headers-section { margin-bottom: 2rem; }
.accordion-toggle {
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; display: flex; align-items: center; gap: 10px;
    font-size: 0.9rem; font-family: var(--font-body); padding: 4px 0; transition: color 0.2s;
}
.accordion-toggle:hover { color: var(--text-main); }
.accordion-content {
    margin-top: 1rem; padding: 1rem; background: rgba(0,0,0,0.1);
    border-radius: 8px; border: 1px solid var(--card-border);
}
.header-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; }
.header-row input {
    flex: 1; background: var(--input-bg); border: 1px solid var(--card-border);
    color: var(--text-main); padding: 8px 12px; border-radius: 6px;
    font-size: 0.9rem; font-family: var(--font-body); outline: none; min-width: 0;
}
.header-row input:focus { border-color: var(--primary-accent); }
.add-header-btn {
    background: transparent; border: 1px dashed var(--card-border);
    color: var(--text-muted); width: 100%; padding: 8px; border-radius: 6px;
    cursor: pointer; font-size: 0.9rem; transition: all 0.2s;
}
.add-header-btn:hover { border-color: var(--primary-accent); color: var(--primary-accent); }
.remove-header-btn {
    background: transparent; border: none; color: #ef4444; cursor: pointer;
    font-size: 1.2rem; padding: 0 10px; min-height: 44px; display: flex; align-items: center;
}

/* === LOADER & ERRORS === */
#loader { text-align: center; margin: 2rem 0; color: var(--text-muted); }
.spinner {
    width: 30px; height: 30px; border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary-accent); border-radius: 50%;
    animation: spin 1s linear infinite; margin: 0 auto 10px auto;
}
html.light-theme .spinner { border-color: rgba(0,0,0,0.1); border-top-color: var(--primary-accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
    background: rgba(239,68,68,0.1); color: #dc2626; border: 1px solid rgba(239,68,68,0.2);
    padding: 1rem; border-radius: 8px; margin-bottom: 2rem; display: flex; align-items: center; gap: 10px;
}
html.light-theme .error-banner { background: #fee2e2; }

/* === RESULTS === */
.results-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--card-border); flex-wrap: wrap; gap: 10px;
}
.view-toggle { background: rgba(0,0,0,0.1); padding: 4px; border-radius: 8px; display: inline-flex; }
html.light-theme .view-toggle { background: #e2e8f0; }
.toggle-btn {
    background: transparent; border: none; color: var(--text-muted);
    padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; transition: all 0.2s;
}
.toggle-btn.active { background: var(--primary-accent); color: #fff; }

.action-buttons { display: flex; gap: 8px; }
.action-buttons .icon-btn {
    background: transparent; border: 1px solid var(--card-border); color: var(--text-muted);
    min-width: 44px; min-height: 44px; border-radius: 8px; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.action-buttons .icon-btn:hover { border-color: var(--primary-accent); color: var(--primary-accent); }

.hop-container {
    background: rgba(0,0,0,0.1); border: 1px solid var(--card-border);
    border-radius: 12px; margin-bottom: 1.5rem; overflow: hidden;
}
html.light-theme .hop-container { background: #ffffff; }

.status-line {
    padding: 1rem; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid var(--card-border); flex-wrap: wrap;
}
.hop-number { background: rgba(255,255,255,0.1); font-size: 0.8rem; padding: 2px 8px; border-radius: 4px; color: var(--text-muted); }
html.light-theme .hop-number { background: rgba(0,0,0,0.1); color: #0f172a; }

.status-code { font-weight: bold; font-family: var(--font-code); }
.status-code.status-2xx { color: var(--status-2xx); }
.status-code.status-3xx { color: var(--status-3xx); }
.status-code.status-4xx, .status-code.status-5xx { color: var(--status-4xx); }
.hop-url { color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }

.headers-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-family: var(--font-code); table-layout: fixed; }
.headers-table th, .headers-table td { text-align: left; padding: 10px 1rem; border-bottom: 1px solid var(--card-border); }
.headers-table th { color: var(--text-muted); font-weight: 600; width: 35%; vertical-align: top; }
html.light-theme .headers-table th { color: var(--text-main); }
.headers-table td { color: var(--text-main); word-wrap: break-word; overflow-wrap: break-word; line-height: 1.5; }
html.light-theme .headers-table td { color: #334155; }
.headers-table td a { color: var(--link-color); text-decoration: none; border-bottom: 1px dotted var(--link-color); transition: all 0.2s; }
.headers-table td a:hover { color: var(--link-hover); border-bottom-style: solid; }
.info-icon { color: var(--primary-accent); margin-left: 5px; cursor: help; font-size: 0.8rem; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; font-weight: bold; margin-top: 4px; font-family: var(--font-body); letter-spacing: 0.5px; text-transform: uppercase; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger  { background: rgba(239, 68, 68, 0.15);  color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
html.light-theme .badge-success { background: #d1fae5; color: #065f46; border-color: #059669; }
html.light-theme .badge-warning { background: #fef3c7; color: #92400e; border-color: #d97706; }
html.light-theme .badge-danger  { background: #fee2e2; color: #991b1b; border-color: #dc2626; }

/* Raw Headers Output */
#raw-headers-output {
    background: rgba(0,0,0,0.2); padding: 1rem; border-radius: 8px;
    font-family: var(--font-code); color: var(--text-muted);
    font-size: 0.9rem; white-space: pre-wrap; word-wrap: break-word; display: block;
}
html.light-theme #raw-headers-output { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }

/* Toast */
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: #1e1e24; border: 1px solid var(--primary-accent);
    color: #fff; padding: 10px 20px; border-radius: 8px; z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); font-size: 0.9rem; pointer-events: none;
    white-space: nowrap; opacity: 0; transition: opacity 0.3s;
}
html.light-theme .toast { background: #ffffff; color: #0f172a; border: 1px solid var(--primary-accent); }
.toast.toast-visible { opacity: 1; pointer-events: auto; }
.hidden { display: none !important; }

/* === INFO & FAQ SECTION === */
.info-section { margin-top: 4rem; padding: 0 1rem; }
.info-section h2 { font-family: var(--font-heading); color: var(--text-main); margin-bottom: 2rem; font-size: 1.5rem; text-align: center; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; margin-bottom: 2rem; }
.info-grid h3 { color: var(--primary-accent); font-family: var(--font-heading); font-size: 1.1rem; margin-bottom: 0.5rem; }
.info-grid p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.faq-section { margin-top: 3rem; }
.faq-section h3 { 
    font-family: var(--font-heading); 
    font-size: 1.5rem; 
    margin-bottom: 1.5rem; 
    text-align: center; 
    color: var(--text-main);
}
details.faq-item {
    background: rgba(0,0,0,0.2); 
    border: 1px solid var(--card-border);
    border-radius: 8px; 
    margin-bottom: 1rem; 
    overflow: hidden;
    transition: background-color 0.3s;
}
html.light-theme details.faq-item { background: #ffffff; }

details.faq-item summary {
    padding: 1.25rem 1.5rem; 
    font-weight: 600; 
    cursor: pointer; 
    list-style: none;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    color: var(--text-main); 
    font-family: var(--font-body);
    font-size: 1rem;
}
details.faq-item summary::-webkit-details-marker { display: none; }
.faq-icon {
    transition: transform 0.3s ease; 
    color: var(--text-muted);
}
details.faq-item[open] .faq-icon { 
    transform: rotate(180deg); 
    color: var(--primary-accent); 
}
.faq-content { 
    padding: 0 1.5rem 1.5rem 1.5rem; 
    color: var(--text-muted); 
    line-height: 1.6; 
    font-size: 0.95rem; 
}
html.light-theme .faq-content { color: #475569; }

/* === FOOTER === */
footer { text-align: center; padding: 3rem 0; color: var(--text-muted); font-size: 0.9rem; border-top: 1px solid var(--card-border); margin-top: 3rem; }
footer a { color: var(--text-main); text-decoration: none; }
footer a:hover { color: var(--primary-accent); }


/* ========================================= */
/* === MEDIA QUERIES === */
/* ========================================= */

@media (max-width: 768px) {
    .url-input-wrapper { flex-direction: column; }
    .identity-select, .url-input, .fetch-btn { width: 100%; }
    .fetch-btn { justify-content: center; }
    .status-line { flex-direction: column; align-items: flex-start; gap: 5px; }
    .hop-url { white-space: normal; word-break: break-all; }
    .headers-table th, .headers-table td { display: block; width: 100%; }
    .headers-table th { padding-bottom: 4px; border-bottom: none; color: var(--secondary-accent); }
    .headers-table td { padding-top: 4px; padding-bottom: 12px; }
    .results-toolbar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .tool-header { padding: 1rem; flex-direction: row; flex-wrap: wrap; }
    .tool-intro h1 { font-size: 1.5rem; }
    .action-buttons { flex-wrap: wrap; }
    .header-row { flex-direction: column; align-items: stretch; }
    .header-row input { width: 100%; }
    .remove-header-btn { align-self: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}