/* ═══════════════════════════════════════════════════════════════════════════
   EyeGuide — Accessible UI Styles
   Designed for visually impaired users: high contrast, large touch targets,
   clear focus indicators, and screen reader friendly.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── CSS Variables ──────────────────────────────────────────────────────── */
:root {
    /* Colors - Dark theme (easier on eyes) */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    
    --text-primary: #f0f6fc;
    --text-secondary: #b1bac4;
    --text-muted: #6e7681;
    
    --accent-primary: #58a6ff;
    --accent-success: #3fb950;
    --accent-warning: #d29922;
    --accent-danger: #f85149;
    --accent-purple: #bc8cff;
    
    /* Status colors */
    --status-connected: #3fb950;
    --status-disconnected: #f85149;
    --status-connecting: #d29922;
    
    /* Sizes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.3);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    
    /* Font */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ─── High Contrast Mode ─────────────────────────────────────────────────── */
.high-contrast {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #1a1a1a;
    --bg-card: #111111;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #aaaaaa;
    --accent-primary: #66bbff;
    --accent-success: #55dd66;
    --accent-danger: #ff6666;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── Accessibility ──────────────────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-primary);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    z-index: 1000;
    text-decoration: none;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 10px;
}

/* Focus styles - extra visible for accessibility */
*:focus-visible {
    outline: 3px solid var(--accent-primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ─── App Container ──────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-disconnected);
    transition: background var(--transition-normal);
}

.status-dot.connected {
    background: var(--status-connected);
    box-shadow: 0 0 8px var(--status-connected);
}

.status-dot.connecting {
    background: var(--status-connecting);
    animation: pulse 1.5s infinite;
}

.status-text {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Main Content ───────────────────────────────────────────────────────── */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
}

/* ─── Camera Section ─────────────────────────────────────────────────────── */
.camera-section {
    width: 100%;
}

.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--bg-tertiary);
    overflow: hidden;
}

#cameraPreview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    transition: opacity var(--transition-normal);
}

.camera-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    color: var(--text-muted);
}

.overlay-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.overlay-content p {
    font-size: 14px;
}

/* Mode badge on camera */
.mode-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.mode-icon {
    font-size: 16px;
}

/* Audio indicator on camera */
.audio-indicator {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 24px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.audio-indicator.active {
    opacity: 1;
}

.audio-bar {
    width: 4px;
    background: var(--accent-success);
    border-radius: 2px;
    transition: height 100ms ease;
    height: 4px;
}

.audio-indicator.active .audio-bar {
    animation: audioBar 0.8s ease-in-out infinite;
}

.audio-indicator.active .audio-bar:nth-child(1) { animation-delay: 0ms; }
.audio-indicator.active .audio-bar:nth-child(2) { animation-delay: 150ms; }
.audio-indicator.active .audio-bar:nth-child(3) { animation-delay: 300ms; }
.audio-indicator.active .audio-bar:nth-child(4) { animation-delay: 150ms; }
.audio-indicator.active .audio-bar:nth-child(5) { animation-delay: 0ms; }

/* ─── Transcript Section ─────────────────────────────────────────────────── */
.transcript-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 150px;
    max-height: 300px;
}

.transcript-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.transcript-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.transcript-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    scroll-behavior: smooth;
}

.transcript-welcome {
    text-align: center;
    padding: 20px 16px;
    color: var(--text-secondary);
}

.transcript-welcome strong {
    color: var(--accent-primary);
}

.transcript-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

/* Transcript messages */
.transcript-msg {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeInUp 0.2s ease;
}

.transcript-msg.agent {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 3px solid var(--accent-primary);
}

.transcript-msg.user {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent-primary);
    border-left: 3px solid var(--accent-purple);
    font-style: italic;
}

.transcript-msg.system {
    background: rgba(210, 153, 34, 0.1);
    color: var(--accent-warning);
    text-align: center;
    font-size: 12px;
    border-left: none;
}

.transcript-msg .msg-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    display: block;
}

.transcript-msg.agent .msg-label { color: var(--accent-primary); }
.transcript-msg.user .msg-label { color: var(--accent-purple); }

/* ─── Action Section (Main Button) ───────────────────────────────────────── */
.action-section {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.btn-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    padding: 18px 32px;
    background: linear-gradient(135deg, var(--accent-primary), #3d8bfd);
    color: white;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    /* Large touch target for accessibility */
    min-height: 64px;
}

.btn-main:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(88, 166, 255, 0.4);
}

.btn-main:active {
    transform: translateY(0);
}

.btn-main.active {
    background: linear-gradient(135deg, var(--accent-danger), #dc3545);
    box-shadow: var(--shadow-md), 0 0 20px rgba(248, 81, 73, 0.3);
}

.btn-main.active:hover {
    box-shadow: var(--shadow-lg), 0 0 30px rgba(248, 81, 73, 0.4);
}

.btn-main-icon {
    font-size: 24px;
}

.btn-main.active .btn-main-icon {
    animation: pulse 1.5s infinite;
}

/* ─── Mode Selector ──────────────────────────────────────────────────────── */
.mode-selector {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    justify-content: center;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
    flex: 1;
    max-width: 100px;
    /* Minimum touch target */
    min-height: 56px;
}

.mode-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.mode-btn.active {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mode-btn-icon {
    font-size: 20px;
}

.mode-btn-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Text Input Section ─────────────────────────────────────────────────── */
.text-input-section {
    padding: 8px 16px 16px;
    border-top: 1px solid var(--bg-tertiary);
}

.text-input-form {
    display: flex;
    gap: 8px;
}

.text-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 15px;
    font-family: var(--font-family);
    transition: border-color var(--transition-fast);
    min-height: 48px;
}

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

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

.btn-send {
    width: 48px;
    height: 48px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.btn-send:hover {
    background: #3d8bfd;
}

/* ─── Settings Panel ─────────────────────────────────────────────────────── */
.settings-panel {
    position: fixed;
    top: 0;
    right: -350px;
    width: 320px;
    max-width: 90vw;
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--bg-tertiary);
    z-index: 200;
    transition: right var(--transition-normal);
    overflow-y: auto;
}

.settings-panel.open {
    right: 0;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
}

.settings-content {
    padding: 24px;
}

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

.settings-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.btn-close {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

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

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.setting-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 2px solid var(--bg-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    min-height: 44px;
}

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

.setting-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.btn-settings {
    position: fixed;
    top: 14px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 18px;
    cursor: pointer;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.btn-settings:hover {
    background: var(--bg-secondary);
}

/* ─── Animations ─────────────────────────────────────────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes audioBar {
    0%, 100% { height: 4px; }
    50% { height: 20px; }
}

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

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

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

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

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

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

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (min-width: 768px) {
    .app-container {
        max-width: 600px;
        border-left: 1px solid var(--bg-tertiary);
        border-right: 1px solid var(--bg-tertiary);
    }
    
    .camera-container {
        border-radius: 0;
    }
}

@media (max-width: 360px) {
    .mode-btn-label {
        font-size: 10px;
    }
    
    .mode-btn {
        padding: 8px 10px;
    }
    
    .btn-main {
        font-size: 16px;
        padding: 14px 24px;
    }
}

/* ─── Reduced Motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
