/* ============================================================
   unified-v2.css — Judicial Modernism redesign
   All rules scoped to body.unified-page so other pages are unaffected.
   ============================================================ */

/* ===== 1 & 2. CSS Variables — Typography + Warm Judicial Palette ===== */
body.unified-page {
    /* Fonts */
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;

    /* Backgrounds — warm dark tones */
    --bg-deep: #0f0f14;
    --bg-surface: #1a1820;
    --bg-elevated: #252230;
    --bg-inset: #0d0c11;

    /* Accent — judicial gold & warm red */
    --accent-gold: #d4a853;
    --accent-gold-dim: rgba(212, 168, 83, 0.15);
    --accent-red: #c44b5c;
    --accent-red-dim: rgba(196, 75, 92, 0.12);
    --accent-blue: #5b8fb9;
    --accent-blue-dim: rgba(91, 143, 185, 0.12);
    --accent-green: #4a9e6e;

    /* Text */
    --text-primary: #e8e4df;
    --text-secondary: #9a9490;
    --text-dim: #5e5a56;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.10);

    /* Glow effects */
    --glow-gold: 0 0 20px rgba(212, 168, 83, 0.15);
    --glow-red: 0 0 20px rgba(196, 75, 92, 0.15);
    --glow-blue: 0 0 20px rgba(91, 143, 185, 0.15);
    --glow-live: 0 0 30px rgba(74, 158, 110, 0.2);
}

/* ===== Base Overrides ===== */
body.unified-page {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
}

/* ===== 4. Background Texture (noise overlay) ===== */
body.unified-page::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

body.unified-page > * {
    position: relative;
    z-index: 1;
}

/* ===== Header (Section 1, 4, 9) ===== */
.unified-page header {
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
    border-bottom: 1px solid var(--border-subtle);
}

.unified-page header h1 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2rem;
    color: var(--text-primary);
}

/* ===== 9. Nav Bar Refinement ===== */
.unified-page .nav-link {
    background: none;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.4rem 1rem;
    margin: 0 0.5rem;
    transition: color 0.2s, border-color 0.2s;
}

.unified-page .nav-link:hover {
    background: none;
    color: var(--text-primary);
}

.unified-page .nav-link.active {
    background: none;
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--accent-gold);
}

/* ===== 3a. Config Bar Redesign ===== */
.unified-page .unified-config {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 1.5rem;
    text-align: left;
    animation: fadeSlideUp 0.5s ease both;
}

.unified-page .config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.unified-page .config-languages {
    display: flex;
    gap: 1.5rem;
    flex: 1;
}

.unified-page .config-lang-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-surface);
    padding: 0.6rem 1rem;
    border-radius: 10px;
    border-left: 3px solid var(--accent-red);
}

.unified-page .config-lang-group.speaker-group {
    border-left-color: var(--accent-blue);
}

.unified-page .config-lang-group label {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.unified-page .config-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ===== 5. Select Dropdowns ===== */
.unified-page .lang-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-deep) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239a9490'/%3E%3C/svg%3E") no-repeat right 0.7rem center / 10px;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 0.4rem 2.2rem 0.4rem 0.7rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.unified-page .lang-select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px var(--accent-gold-dim);
}

.unified-page .lang-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ===== 5. Buttons ===== */
.unified-page .mic-btn {
    padding: 0.6rem 1.5rem;
    border: 1px solid var(--accent-green);
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-green), #3d8a5a);
    color: #fff;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(74, 158, 110, 0.25);
    letter-spacing: 0.5px;
}

.unified-page .mic-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(74, 158, 110, 0.35);
}

.unified-page .mic-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.unified-page .mic-btn.active {
    background: linear-gradient(135deg, var(--accent-red), #a33d4d);
    border-color: var(--accent-red);
    box-shadow: 0 2px 12px rgba(196, 75, 92, 0.35);
    animation: live-pulse 2s ease-in-out infinite;
}

/* Clear All — ghost button (Section 3d) */
.unified-page .clear-btn {
    padding: 0.5rem 1.2rem;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.unified-page .clear-btn:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* ===== 6b. Status Bar with Live Dot ===== */
.unified-page .status {
    border-top: none;
    text-align: left;
    padding: 0.6rem 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
}

.unified-page .status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    margin-right: 6px;
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}

.unified-page .status-dot.live {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(74, 158, 110, 0.6);
    animation: dot-breathe 2s ease-in-out infinite;
}

.unified-page .status-dot.demo {
    background: var(--accent-gold);
    box-shadow: 0 0 8px rgba(212, 168, 83, 0.6);
    animation: dot-breathe 2s ease-in-out infinite;
}

.unified-page .status-dot.error {
    background: var(--accent-red);
    box-shadow: 0 0 8px rgba(196, 75, 92, 0.6);
}

/* ===== Timeline Panel (adapted 3b for single-column layout) ===== */
.unified-page .diarized-main {
    padding: 1rem 1.5rem;
}

.unified-page .diarized-timeline-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-top: 3px solid var(--accent-gold);
    box-shadow:
        0 1px 3px rgba(0,0,0,0.3),
        0 4px 12px rgba(0,0,0,0.2),
        0 12px 40px rgba(0,0,0,0.15);
    animation: fadeSlideUp 0.5s ease 0.1s both;
}

.unified-page .diarized-timeline-header {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(15, 15, 20, 0.8) 100%);
    border-bottom: 1px solid var(--border-subtle);
}

.unified-page .diarized-timeline-header h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.unified-page .detected-lang {
    color: var(--accent-gold);
    font-family: var(--font-body);
    font-size: 0.8rem;
}

.unified-page .diarized-timeline-content {
    padding: 1rem;
}

/* ===== 3c. Timeline Entries ===== */
.unified-page .timeline-entry {
    background: var(--bg-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    border-left: 4px solid #333;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    padding: 0.75rem 1rem;
}

.unified-page .timeline-entry.timeline-interim {
    opacity: 0.5;
    border-left-style: dashed;
}

.unified-page .timeline-entry-judge {
    border-left-color: var(--accent-red);
}

.unified-page .timeline-entry-speaker {
    border-left-color: var(--accent-blue);
}

.unified-page .timeline-entry-attorney {
    border-left-color: var(--accent-gold);
}

.unified-page .timeline-entry-witness {
    border-left-color: var(--accent-green);
}

.unified-page .timeline-entry-clerk {
    border-left-color: #9b7ec8;
}

.unified-page .timeline-original {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.5;
}

.unified-page .timeline-translation {
    font-family: var(--font-body);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-gold);
    border-left: 3px solid var(--accent-gold);
    padding-left: 0.75rem;
    margin-top: 0.4rem;
    line-height: 1.4;
}

/* ===== 8. Role Badges ===== */
.unified-page .role-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.unified-page .role-badge.role-judge {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    border: 1px solid rgba(196, 75, 92, 0.3);
}

.unified-page .role-badge.role-speaker {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
    border: 1px solid rgba(91, 143, 185, 0.3);
}

/* Section icon (§) for intelligence header */
.unified-page .section-icon {
    font-family: var(--font-display);
    font-size: 1.1em;
    margin-right: 0.4rem;
    color: var(--accent-gold);
}

/* ===== 6c. Ambient State — Session Active ===== */
body.unified-page.session-active {
    --bg-deep: #11100f;
}

body.unified-page.session-active .diarized-timeline-panel {
    border-color: var(--border-medium);
    box-shadow: var(--glow-gold);
    transition: border-color 0.6s ease, box-shadow 0.6s ease;
}

/* ===== 7. Intelligence Panel Polish ===== */
.unified-page .intelligence-panel {
    margin: 0 1.5rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    animation: fadeSlideUp 0.5s ease 0.3s both;
}

.unified-page .intelligence-header {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(15, 15, 20, 0.8) 100%);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1rem;
}

.unified-page .intelligence-header h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.unified-page .intelligence-content {
    padding: 1rem;
    box-shadow: inset 0 4px 12px rgba(0,0,0,0.3);
}

.unified-page .intelligence-col h3,
.unified-page .intel-formalized-area h3 {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.unified-page .intelligence-btn {
    padding: 0.5rem 1.2rem;
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    background: transparent;
    color: var(--accent-gold);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.unified-page .intelligence-btn:hover:not(:disabled) {
    background: var(--accent-gold);
    color: var(--bg-deep);
}

.unified-page .intelligence-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.unified-page .intel-result {
    background: var(--bg-inset);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    color: var(--text-primary);
}

.unified-page .intelligence-status {
    color: var(--text-secondary);
}

.unified-page .collapse-toggle {
    color: var(--text-secondary);
    font-size: 1rem;
    transition: transform 0.3s ease;
    display: inline-block;
}

.unified-page .collapse-toggle.open {
    transform: rotate(90deg);
}

/* Moment cards with new palette */
.unified-page .moment-card {
    background: var(--bg-inset);
    border-left: 3px solid #555;
}

.unified-page .moment-card.moment-objection { border-left-color: var(--accent-red); }
.unified-page .moment-card.moment-ruling { border-left-color: var(--accent-green); }
.unified-page .moment-card.moment-motion { border-left-color: var(--accent-blue); }
.unified-page .moment-card.moment-other { border-left-color: var(--accent-gold); }

.unified-page .moment-badge.badge-objection { background: var(--accent-red); }
.unified-page .moment-badge.badge-ruling { background: var(--accent-green); }
.unified-page .moment-badge.badge-motion { background: var(--accent-blue); }
.unified-page .moment-badge.badge-other { background: var(--accent-gold); color: var(--bg-deep); }

.unified-page .moment-excerpt { color: var(--text-primary); }
.unified-page .moment-significance { color: var(--text-secondary); }

.unified-page .result-empty { color: var(--text-dim); }
.unified-page .result-preformatted { color: var(--text-primary); }
.unified-page .result-summary { color: var(--text-primary); }
.unified-page .error-msg { color: var(--accent-red); }
.unified-page .spinner { color: var(--accent-gold); }

/* Interim text */
.unified-page .interim {
    color: var(--text-dim);
    font-style: italic;
}

/* ===== 6. Animations ===== */

/* 6a. Page Load Stagger */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 6b. Status Dot Breathe */
@keyframes dot-breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 6d. New Text Line Animation */
@keyframes textFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.unified-page .line-enter {
    animation: textFadeIn 0.4s ease both;
}

/* 6e. Improved Pulse (smoother glow) */
@keyframes live-pulse {
    0%, 100% {
        box-shadow: 0 2px 12px rgba(196, 75, 92, 0.35);
    }
    50% {
        box-shadow: 0 2px 24px rgba(196, 75, 92, 0.55);
    }
}

/* ===== 3e. Responsive Breakpoints ===== */
@media (max-width: 768px) {
    body.unified-page .diarized-main {
        flex-direction: column;
        padding: 0.75rem;
    }

    body.unified-page .unified-config {
        padding: 0.75rem;
    }

    body.unified-page .config-row {
        flex-direction: column;
        align-items: stretch;
    }

    body.unified-page .config-languages {
        flex-direction: column;
    }

    body.unified-page .config-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    body.unified-page .intelligence-panel {
        margin: 0 0.75rem 0.75rem;
    }

    body.unified-page .intelligence-grid {
        grid-template-columns: 1fr;
    }

    body.unified-page header h1 {
        font-size: 1.4rem;
    }
}
