/* WIA Live - UI/UX v2.1.0 Complete */

/* === CSS Variables === */
:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --secondary: #10B981;
    --secondary-dark: #059669;
    --accent: #F59E0B;
    --success: #22C55E;
    --error: #EF4444;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
}

/* === Theme Variables === */
[data-theme="high-contrast"] {
    --bg-primary: #000000;
    --bg-secondary: #0d0d0d;
    --bg-tertiary: #1a1a1a;
    --bg-card: #111111;
    --text-primary: #FFFF00;
    --text-secondary: #00FFFF;
    --text-muted: #CCCCCC;
    --border-color: #FFFF00;
    --border-light: #444444;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #475569;
    --border-light: #334155;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
}

/* === Font Size === */
[data-font-size="small"] { font-size: 14px; }
[data-font-size="medium"] { font-size: 16px; }
[data-font-size="large"] { font-size: 20px; }
[data-font-size="xlarge"] { font-size: 24px; }

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    line-height: 1.6;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* === Skip Links === */
.skip-links {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10000;
}

.skip-links a {
    position: absolute;
    left: -9999px;
    padding: 1rem 2rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 0;
}

.skip-links a:focus {
    left: 0;
    top: 0;
}

/* === Header === */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
    font-weight: 400;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.header-actions button {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.header-actions button:hover {
    background: rgba(255,255,255,0.3);
}

/* === Keyboard Shortcuts === */
.keyboard-shortcuts {
    background: var(--bg-secondary);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-light);
}

.keyboard-shortcuts h2 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.keyboard-shortcuts ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.keyboard-shortcuts li {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.keyboard-shortcuts kbd {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    margin-right: 4px;
}

/* === Main Content === */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* === Status Bar === */
.status-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-light);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-item .label {
    color: var(--text-muted);
}

.status-item .value {
    color: var(--text-primary);
    font-weight: 600;
}

.status-item .value.active {
    color: var(--success);
}

/* === Input Grid (2 columns) === */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
}

/* === Input Panels === */
.input-panel {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 2px solid var(--border-light);
    transition: all 0.3s ease;
}

.input-panel:hover {
    border-color: var(--border-color);
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.input-panel.deaf-panel {
    border-left: 4px solid var(--primary);
}

.input-panel.blind-panel {
    border-left: 4px solid var(--secondary);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.panel-header .icon {
    font-size: 1.75rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* === Camera Container === */
.camera-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/10;
    margin-bottom: 1rem;
}

.camera-container video,
.camera-container canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.8);
    color: white;
}

.camera-placeholder .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.camera-placeholder p {
    font-size: 0.95rem;
    opacity: 0.8;
}

/* === Voice Container === */
.voice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.voice-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    color: white;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
    transition: all 0.3s ease;
}

.voice-button:hover {
    transform: scale(1.08);
}

.voice-button.recording {
    background: linear-gradient(135deg, var(--error), #dc2626);
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
    50% { box-shadow: 0 0 0 20px rgba(239,68,68,0); }
}

.voice-status {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* === Control Buttons === */
.control-buttons {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--error), #dc2626);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

/* === Status Display === */
.status-display {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.status-display .label {
    color: var(--text-secondary);
}

/* === Output Section === */
.output-section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 2px solid var(--border-light);
    margin-bottom: 2rem;
}

.output-section h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === Conversation Container === */
.conversation-container {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.conversation-placeholder {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.message {
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

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

.message.deaf {
    text-align: left;
}

.message.blind {
    text-align: right;
}

.message-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
}

.message.deaf .message-bubble {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-bottom-left-radius: 4px;
}

.message.blind .message-bubble {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    color: white;
    border-bottom-right-radius: 4px;
}

.message-sender {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    opacity: 0.9;
}

.message-text {
    font-size: 1.1rem;
    line-height: 1.5;
}

.message-braille {
    font-size: 1.3rem;
    margin-top: 0.5rem;
    font-family: 'Noto Sans Symbols 2', monospace;
    letter-spacing: 3px;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

/* === Result Section === */
.result-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .result-section {
        grid-template-columns: 1fr;
    }
}

.result-panel {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 2px solid var(--border-light);
}

.result-panel h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-item {
    margin-bottom: 1rem;
}

.result-item .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.result-item .value {
    font-size: 1rem;
    color: var(--text-primary);
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    min-height: 2.5rem;
}

.result-item .value.braille {
    font-size: 1.5rem;
    font-family: 'Noto Sans Symbols 2', monospace;
    letter-spacing: 4px;
    text-align: center;
}

/* === Settings Panel === */
.settings-panel {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 2px solid var(--border-light);
}

.settings-panel h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-group {
    margin-bottom: 1.25rem;
}

.setting-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.setting-group select {
    width: 100%;
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.setting-group input[type="range"] {
    width: 100%;
    margin-top: 0.5rem;
}

.speed-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.setting-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    cursor: pointer;
}

/* === Footer === */
footer {
    background: var(--bg-secondary);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-light);
    margin-top: 2rem;
}

footer h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

footer p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.footer-features {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
}

.footer-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer-features .check {
    color: var(--success);
}

/* === Help Section === */
.help-section {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
    border: 2px solid var(--border-light);
}

.help-section h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.help-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 1.5rem 0 0.75rem;
}

.help-section ol,
.help-section ul {
    margin-left: 1.5rem;
    color: var(--text-muted);
}

.help-section li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
}

.help-table th,
.help-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.help-table th {
    color: var(--text-secondary);
    font-weight: 600;
}

.help-table td {
    color: var(--text-muted);
}

.help-table kbd {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
}

/* === Responsive === */
@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
    }
    
    .header-container {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .input-panel {
        padding: 1rem;
    }
    
    .message-bubble {
        max-width: 95%;
    }
}

/* === Focus States (Accessibility) === */
:focus {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

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

/* 캔버스 오버레이 - 비디오 위에 정확히 겹침 */
#gestureCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#webcam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
