/* BSL Sign Language Translation - High Contrast Accessible Styles */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #1a1a2e;
    --bg-surface: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0cc;
    --accent: #00d4ff;
    --accent-hover: #00a8cc;
    --success: #00e676;
    --warning: #ffab40;
    --error: #ff5252;
    --border: #2a2a4e;
    --overlay: rgba(0, 0, 0, 0.7);
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-contrast: more) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #111111;
        --bg-surface: #1a1a1a;
        --text-primary: #ffffff;
        --text-secondary: #e0e0e0;
        --accent: #00ffff;
        --border: #ffffff;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* Focus indicators for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ============ NAV ============ */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.nav-modes {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-btn:hover, .nav-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-auth {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
}

/* ============ MAIN LAYOUT ============ */
.app-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
}

/* ============ LIVE TRANSLATION MODE ============ */
.live-mode {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
}

.video-area {
    flex: 1;
    position: relative;
    background: #000;
}

.video-area video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.video-area canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: scaleX(-1);
}

.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    gap: 1rem;
}

.camera-placeholder svg { width: 64px; height: 64px; opacity: 0.5; }

.btn-start-camera {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border: 2px solid var(--accent);
    border-radius: 12px;
    background: var(--accent);
    color: var(--bg-primary);
    cursor: pointer;
    font-weight: 600;
}

/* Caption bar */
.caption-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--overlay);
    padding: 1rem 1.5rem;
    min-height: 60px;
    backdrop-filter: blur(8px);
}

.caption-text {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.4;
    min-height: 2rem;
}

.caption-confidence {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.nmf-indicators {
    display: inline-flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
}

.nmf-indicators .nmf-tag {
    background: var(--accent);
    color: var(--bg-primary);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Sentence transcript bar */
.sentence-bar {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    background: rgba(0, 20, 40, 0.85);
    padding: 0.5rem 1.5rem;
    min-height: 0;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: min-height 0.2s;
    z-index: 5;
}

.sentence-bar:empty { display: none; }

.sentence-text {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.02em;
    overflow-x: auto;
    white-space: nowrap;
}

.sentence-text .sign-word {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    margin: 0 0.15rem;
    background: rgba(0, 212, 255, 0.15);
    border-radius: 4px;
    animation: signAppear 0.3s ease-out;
}

.sentence-text .sign-word.nmf-sign {
    background: rgba(255, 171, 64, 0.2);
    color: var(--warning);
}

@keyframes signAppear {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sentence-clear {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    white-space: nowrap;
}

.sentence-clear:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* PiP video overlay */
.pip-overlay {
    position: absolute;
    bottom: 80px;
    right: 16px;
    width: 240px;
    height: 180px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--accent);
    background: #000;
    z-index: 10;
    display: none;
}

.pip-overlay video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Text input panel */
.text-panel {
    width: 400px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.text-panel.collapsed { width: 0; overflow: hidden; }

.text-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-panel-header h3 { font-size: 1rem; }

.text-input-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.75rem;
}

.text-input-area textarea {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 0.75rem;
    font-size: 1rem;
    font-family: var(--font-main);
    resize: none;
    min-height: 120px;
}

.btn-translate {
    padding: 0.75rem;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-translate:hover { background: var(--accent-hover); }

.gloss-output {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 60px;
}

.gloss-word {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    margin: 0.15rem;
    background: var(--bg-surface);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.95rem;
}

.gloss-word.fingerspell { color: var(--warning); border: 1px dashed var(--warning); }

.btn-speak {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.9rem;
}

/* Toggle button */
.btn-toggle-panel {
    position: absolute;
    top: 50%;
    right: 400px;
    transform: translateY(-50%);
    width: 32px;
    height: 64px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* ============ PRACTICE MODE ============ */
.practice-mode {
    display: none;
    flex: 1;
    padding: 1.5rem;
    gap: 1.5rem;
}

.practice-mode.active { display: grid; grid-template-columns: 1fr 1fr; }

.practice-target {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.practice-target h2 { font-size: 2rem; color: var(--accent); }

.practice-target video {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
}

.practice-camera {
    background: var(--bg-surface);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.practice-camera video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.practice-score {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--overlay);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 1.5rem;
}

.star { color: var(--text-secondary); }
.star.filled { color: var(--warning); }

.practice-sets {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
}

.practice-set-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.practice-set-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.practice-progress {
    grid-column: 1 / -1;
    background: var(--bg-surface);
    border-radius: 8px;
    padding: 1rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

/* ============ KIOSK MODE ============ */
.kiosk-mode {
    display: none;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 3rem;
}

.kiosk-mode.active { display: flex; flex-direction: column; }

.kiosk-title {
    font-size: 3rem;
    font-weight: 700;
    text-align: center;
    color: var(--accent);
}

.kiosk-buttons {
    display: flex;
    gap: 3rem;
}

.kiosk-btn {
    width: 300px;
    height: 300px;
    border: 3px solid var(--accent);
    border-radius: 24px;
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    transition: all 0.3s;
}

.kiosk-btn:hover {
    background: var(--accent);
    color: var(--bg-primary);
    transform: scale(1.05);
}

.kiosk-btn svg { width: 80px; height: 80px; }

.kiosk-timeout {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--overlay);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    display: none;
}

/* ============ STATUS INDICATOR ============ */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--error);
    display: inline-block;
}

.status-dot.connected { background: var(--success); }
.status-dot.processing { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============ LOADING ============ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    /* Hide text→BSL panel and toggle on mobile */
    .text-panel { display: none; }
    .btn-toggle-panel { display: none; }

    /* Nav: compact layout */
    .nav {
        padding: 0.4rem 0.75rem;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .nav-brand {
        font-size: 0.9rem;
        flex-shrink: 0;
    }
    .nav-modes {
        gap: 0.25rem;
        order: 1;
        width: 100%;
        justify-content: center;
    }
    .nav-btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.78rem;
    }
    .nav-user {
        gap: 0.5rem;
        margin-left: auto;
    }
    .btn-auth {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    /* Camera: fill available height */
    .app-container {
        height: calc(100vh - 80px); /* account for taller wrapped nav */
    }
    .video-area {
        height: 100%;
    }

    /* Caption bar: tighter on mobile */
    .caption-bar {
        padding: 0.6rem 0.75rem;
        min-height: 48px;
    }
    .caption-text {
        font-size: 1.15rem;
    }
    .caption-confidence {
        font-size: 0.75rem;
    }

    /* Sentence bar: tighter on mobile */
    .sentence-bar {
        bottom: 60px;
        padding: 0.35rem 0.75rem;
    }
    .sentence-text {
        font-size: 0.95rem;
    }

    /* PiP overlay: smaller on mobile */
    .pip-overlay {
        width: 160px;
        height: 120px;
        bottom: 60px;
        right: 8px;
    }

    /* Practice & Kiosk */
    .practice-mode.active { grid-template-columns: 1fr; }
    .kiosk-buttons { flex-direction: column; }
    .kiosk-btn { width: 100%; height: 200px; }
}

@media (min-resolution: 200dpi) {
    /* High-DPI touch devices — larger touch targets */
    .nav-btn { padding: 0.75rem 1.25rem; font-size: 1rem; }
    .kiosk-btn { width: 350px; height: 350px; }
}
