/* Core Variables & Typography */
@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: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
    --bg-base: #0b0d10;
    --bg-surface: #14171d;
    --bg-surface-hover: #1f232b;
    --border-color: #272c36;
    --accent-primary: #3b82f6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

body { background-color: var(--bg-base); color: var(--text-primary); font-family: var(--font-ui); line-height: 1.6; overflow-x: hidden; }

h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
.hidden { display: none !important; }
.hide-desktop { display: none !important; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-success { color: var(--success) !important; }
.text-sm { font-size: 0.85rem; }
.font-mono { font-family: var(--font-mono); }

/* Layout Architecture */
.studio-wrapper { display: flex; flex-direction: column; height: 100vh; min-height: 100dvh; }
.studio-header { height: 60px; display: flex; justify-content: space-between; align-items: center; padding: 0 1.5rem; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.header-left { display: flex; align-items: center; gap: 15px; }
.back-link { color: var(--text-secondary); font-size: 1.2rem; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 6px; text-decoration: none; transition: 0.2s; }
.back-link:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.logo { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.logo i { color: var(--accent-primary); }
.logo span { color: var(--text-primary); }
.header-actions { display: flex; align-items: center; gap: 15px; }

.privacy-badge { font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; background: rgba(59, 130, 246, 0.1); color: var(--accent-primary); display: flex; align-items: center; gap: 6px; border: 1px solid rgba(59, 130, 246, 0.2); }
.badge { font-size: 0.75rem; padding: 4px 10px; border-radius: 6px; background: rgba(59, 130, 246, 0.1); color: var(--accent-primary); border: 1px solid rgba(59, 130, 246, 0.3); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.badge.csr { background: rgba(245, 158, 11, 0.1); color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0.6rem 1.4rem; border-radius: 9999px; font-weight: 500; cursor: pointer; transition: all 0.2s; border: none; font-family: var(--font-ui); min-height: 44px; }
.btn-ghost { background: transparent; color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-surface-hover); }
.btn-sm { min-height: 32px; padding: 0.3rem 0.85rem; font-size: 0.85rem; }

/* Layout & Editors */
.split-layout { display: flex; flex: 1; overflow: hidden; position: relative; }
.pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.pane-left { background: var(--bg-base); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 1.5rem; }
.pane-right { background: var(--bg-surface); padding: 0; }
.pane-header { margin-bottom: 1rem; flex-shrink: 0; }
.pane-right .pane-header { padding: 1.5rem 1.5rem 0 1.5rem; }
.pane-title-row { display: flex; justify-content: space-between; align-items: center; }
.pane-header h2 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); }

/* Dual Inputs */
.editor-wrapper { flex: 1; display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 0; overflow-y: auto; padding-right: 5px; }
.input-group { display: flex; flex-direction: column; }
.cert-group { flex: 1; min-height: 200px; }
.key-group { flex: 0.5; min-height: 120px; }
.input-label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px; }
.input-label span { font-weight: 400; text-transform: none; color: #64748b; letter-spacing: normal; }

.code-editor { 
    width: 100%; height: 100%; resize: none; font-family: var(--font-mono); font-size: 0.85rem;
    background: #0f1115; color: #cbd5e1; border: 1px solid var(--border-color); 
    border-radius: 8px; padding: 1rem; outline: none; transition: border-color 0.2s;
    line-height: 1.6; white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
.code-editor:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* Custom Checkbox Toggle */
.key-toggle-wrapper { margin-top: -0.5rem; margin-bottom: 0.25rem; }
.custom-checkbox { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; color: var(--text-secondary); font-size: 0.9rem; transition: color 0.2s; font-weight: 500; }
.custom-checkbox:hover { color: var(--text-primary); }
.custom-checkbox input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }
.checkmark { width: 18px; height: 18px; border: 2px solid var(--border-color); border-radius: 4px; display: flex; align-items: center; justify-content: center; background: var(--bg-surface); transition: 0.2s; flex-shrink: 0; }
.checkmark i { color: transparent; font-size: 0.75rem; transition: 0.2s; }
.custom-checkbox input:checked ~ .checkmark { background: var(--accent-primary); border-color: var(--accent-primary); }
.custom-checkbox input:checked ~ .checkmark i { color: white; }
.toggle-text i { color: var(--success); margin-right: 6px; }

/* Dashboard UI */
.panel-scroll-content { padding: 1.5rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1rem; }
.output-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-secondary); opacity: 0.6; text-align: center; }
.output-placeholder i { font-size: 3rem; margin-bottom: 1rem; }

/* Dynamic Chain Blocks */
#decodedItemsContainer { display: flex; flex-direction: column; gap: 2rem; }
.cert-block { display: flex; flex-direction: column; gap: 1rem; padding-bottom: 2rem; border-bottom: 1px dashed var(--border-color); }
.cert-block:last-child { border-bottom: none; padding-bottom: 0; }
.cert-block-header { font-size: 1.1rem; color: var(--text-primary); border-left: 4px solid var(--accent-primary); padding-left: 12px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }

.data-card { background: var(--bg-base); border: 1px solid var(--border-color); padding: 1.2rem; border-radius: 8px; }
.highlight-card { border-color: rgba(59, 130, 246, 0.3); background: rgba(59, 130, 246, 0.05); }
.data-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }

.card-label { display: flex; justify-content: space-between; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 0.5rem; }
.card-value { font-size: 1rem; color: var(--text-primary); word-break: break-all; }
.main-val { font-size: 1.25rem; font-weight: 600; color: var(--accent-primary); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* Key Match Badges */
.key-match-badge { font-size: 0.8rem; padding: 4px 10px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; border: 1px solid; }
.key-match-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border-color: rgba(16, 185, 129, 0.3); }
.key-match-fail { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }

.status-badge { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 0.85rem; font-weight: 600; }
.status-badge.valid { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-badge.expired { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.status-badge.pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.tags-container { display: flex; flex-wrap: wrap; gap: 8px; }
.san-tag, .eku-tag { background: var(--bg-surface-hover); color: var(--text-primary); font-family: var(--font-mono); font-size: 0.85rem; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border-color); }
.eku-tag { background: rgba(139, 92, 246, 0.1); color: #c4b5fd; border-color: rgba(139, 92, 246, 0.3); }

.details-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.details-table tr { border-bottom: 1px solid var(--border-color); }
.details-table tr:last-child { border-bottom: none; }
.details-table td { padding: 8px 0; }
.details-table td:first-child { width: 120px; color: var(--text-secondary); font-weight: 500; }
.details-table td:last-child { color: var(--text-primary); word-break: break-all; }

/* Action Area */
.desktop-action-area { display: flex; gap: 12px; padding: 1.5rem; border-top: 1px solid var(--border-color); justify-content: flex-end; flex-shrink: 0; background: var(--bg-surface); }

/* Toast */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 100px); background: var(--text-primary); color: var(--bg-base); padding: 12px 24px; border-radius: 8px; font-weight: 600; box-shadow: 0 10px 25px rgba(0,0,0,0.5); opacity: 0; transition: all 0.3s; z-index: 1000; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.mobile-bottom-nav { display: none; }

/* --- SEO FAQ SECTION --- */
.seo-section { background: var(--bg-base); padding: 5rem 1.5rem; border-top: 1px solid var(--border-color); }
.faq-container { max-width: 800px; margin: 0 auto; }
.faq-container h2 { font-size: 1.8rem; color: var(--text-primary); margin-bottom: 2rem; text-align: center; letter-spacing: -0.5px; }

.faq-item { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 1rem; overflow: hidden; }
.faq-item summary { padding: 1.25rem 1.5rem; font-size: 1.05rem; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; color: var(--text-primary); transition: background 0.2s; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { background: var(--bg-surface-hover); }

/* Native FontAwesome Icon Animation */
.icon-chevron { color: var(--text-secondary); font-size: 0.9rem; transition: transform 0.3s ease; }
.faq-item[open] summary .icon-chevron { transform: rotate(180deg); }

.faq-content { padding: 0 1.5rem 1.5rem 1.5rem; color: var(--text-secondary); line-height: 1.6; font-size: 0.95rem; }
.faq-content strong { color: var(--text-primary); }
.faq-content code { background: rgba(255,255,255,0.05); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-primary); }

/* Mobile View */
@media (max-width: 900px) {
    .hide-mobile { display: none !important; }
    
    .studio-wrapper { height: auto; min-height: 100vh; }
    .studio-layout { flex: none; overflow: visible; flex-direction: column; }
    .pane { flex: none; height: auto; border: none; padding: 1rem; }
    .pane-right { border-top: 1px solid var(--border-color); }
    .pane-right .pane-header { padding: 0 0 1rem 0; }
    .panel-scroll-content { padding: 0; overflow-y: visible; }
    
    .editor-wrapper { overflow: visible; }

    /* Leave room for mobile nav at the bottom of the page */
    .seo-section { padding-bottom: calc(5rem + 80px); }
    
    .mobile-bottom-nav { 
        position: fixed; bottom: 0; left: 0; right: 0;
        background: rgba(20, 23, 29, 0.95); backdrop-filter: blur(10px);
        display: flex; border-top: 1px solid var(--border-color); z-index: 900; 
        padding-bottom: env(safe-area-inset-bottom);
    }
    .nav-btn {
        flex: 1; background: transparent; border: none; color: var(--text-secondary);
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        padding: 12px 0; font-size: 0.7rem; font-family: var(--font-ui); cursor: pointer; gap: 4px; transition: 0.2s;
    }
    .nav-btn.active { color: var(--accent-primary); }
    .nav-btn i { font-size: 1.2rem; }
}