/* ═══════════════════════════════════════════ */
/* Universal Translator — Smartphone UI       */
/* ═══════════════════════════════════════════ */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --blue: #3b82f6;
    --blue-dark: #2563eb;
    --red: #ef4444;
    --red-dark: #dc2626;
    --green: #22c55e;
    --green-dark: #16a34a;
    --orange: #f59e0b;
    --border: #334155;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
}

/* Light Mode */
.light {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

/* ═══════ STATUS BAR ═══════ */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-secondary);
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-icon {
    font-size: 14px;
}

.battery-text {
    font-size: 10px;
    color: var(--text-secondary);
}

/* ═══════ APP CONTAINER ═══════ */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 100px;
    min-height: calc(100vh - 50px);
}

/* ═══════ HEADER ═══════ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

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

.logo-icon {
    font-size: 36px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text p {
    font-size: 11px;
    color: var(--text-muted);
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: var(--accent);
    transform: scale(1.1);
}

/* ═══════ LANGUAGE PAIR ═══════ */
.language-pair {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.lang-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.lang-box:hover {
    border-color: var(--accent);
}

.lang-box.active {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.lang-flag {
    font-size: 24px;
}

.lang-name {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}

.lang-code {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.swap-btn {
    background: var(--accent);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.swap-btn:hover {
    background: var(--accent-dark);
    transform: rotate(180deg);
}

.swap-btn:active {
    transform: rotate(360deg) scale(0.9);
}

.swap-icon {
    font-weight: 800;
}

/* ═══════ MAIN CONTENT ═══════ */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ═══════ INPUT/OUTPUT SECTIONS ═══════ */
.input-section, .output-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.input-label, .output-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.input-actions, .output-actions {
    display: flex;
    gap: 4px;
}

.action-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.action-btn:hover {
    background: var(--bg-primary);
}

#input-text {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 100px;
}

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

.char-count {
    padding: 6px 14px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    border-top: 1px solid var(--border);
}

.output-text {
    padding: 14px;
    font-size: 15px;
    min-height: 100px;
    line-height: 1.6;
}

.output-text .placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* ═══════ MAIN ACTION BUTTONS ═══════ */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.main-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    font-family: inherit;
    box-shadow: var(--shadow);
}

.main-btn:active {
    transform: scale(0.95);
}

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

.btn-blue:hover {
    background: linear-gradient(135deg, var(--blue-dark), #1d4ed8);
}

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

.btn-red:hover {
    background: linear-gradient(135deg, var(--red-dark), #b91c1c);
}

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

.btn-green:hover {
    background: linear-gradient(135deg, var(--green-dark), #15803d);
}

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

.btn-label {
    font-size: 14px;
    font-weight: 700;
}

.btn-sublabel {
    font-size: 10px;
    opacity: 0.8;
    font-weight: 500;
}

/* ═══════ BOTTOM NAVIGATION ═══════ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 8px 0 env(safe-area-inset-bottom, 8px);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    transition: all 0.2s;
    font-family: inherit;
}

.nav-btn.active {
    color: var(--accent);
}

.nav-btn.active .nav-icon {
    transform: scale(1.2);
}

.nav-icon {
    font-size: 22px;
    transition: transform 0.2s;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
}

.nav-btn:hover {
    color: var(--accent);
    background: var(--bg-tertiary);
}

/* ═══════ PAGES ═══════ */
.page {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.hidden {
    display: none !important;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
}

.page-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 700;
}

.back-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--accent);
    color: white;
}

.clear-btn {
    background: var(--red);
    border: none;
    color: white;
    padding: 8px 14px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
}

/* ═══════ VOICE PAGE ═══════ */
.voice-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 40px 0;
}

.voice-status {
    font-size: 16px;
    color: var(--text-secondary);
    text-align: center;
}

.voice-wave {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 60px;
    opacity: 0;
    transition: opacity 0.3s;
}

.voice-wave.active {
    opacity: 1;
}

.wave-bar {
    width: 6px;
    height: 20px;
    background: var(--accent);
    border-radius: 3px;
    animation: wave 0.5s ease-in-out infinite;
}

.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { height: 20px; }
    50% { height: 60px; }
}

.voice-text {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    min-height: 50px;
    color: var(--text-primary);
}

.voice-buttons {
    display: flex;
    gap: 20px;
}

.voice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 30px;
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    box-shadow: var(--shadow);
}

.voice-btn:active {
    transform: scale(0.95);
}

.voice-btn.recording {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 0 20px rgba(99, 102, 241, 0); }
}

/* ═══════ CAMERA PAGE ═══════ */
.camera-container {
    position: relative;
}

#camera-feed {
    width: 100%;
    border-radius: var(--radius);
    background: #000;
    min-height: 300px;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 80%;
    height: 60%;
    border: 3px solid var(--accent);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

.camera-controls {
    display: flex;
    gap: 12px;
    padding: 16px 0;
}

.camera-btn {
    flex: 1;
    padding: 14px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

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

.ocr-result {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
    border: 1px solid var(--border);
}

.ocr-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
    max-height: 150px;
    overflow-y: auto;
}

.translate-btn {
    width: 100%;
    padding: 12px;
    background: var(--green);
    border: none;
    border-radius: var(--radius-xs);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

/* ═══════ MAPS PAGE ═══════ */
.maps-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#map {
    height: 350px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 1;
}

.maps-info {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
}

.location-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.location-icon {
    font-size: 18px;
}

.nearby-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.nearby-btn {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.nearby-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ═══════ EMERGENCY PAGE ═══════ */
.emergency-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.emergency-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.emergency-item:hover {
    border-color: var(--red);
    background: rgba(239, 68, 68, 0.1);
}

.emergency-phrase {
    font-size: 14px;
    font-weight: 500;
}

.emergency-speak {
    background: var(--red);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════ HISTORY PAGE ═══════ */
.history-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--accent);
}

.history-langs {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.history-lang {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent);
    color: white;
}

.history-input {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-output {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ═══════ SETTINGS PAGE ═══════ */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-group {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
}

.setting-group h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.setting-item:last-child {
    border-bottom: none;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    transition: 0.3s;
    border-radius: 26px;
    border: 1px solid var(--border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--accent);
    border-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.setting-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.setting-btn {
    background: var(--accent);
    border: none;
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.setting-btn.danger {
    background: var(--red);
}

/* ═══════ MODAL ═══════ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

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

#lang-search {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}

#lang-search::placeholder {
    color: var(--text-muted);
}

.lang-list {
    max-height: 50vh;
    overflow-y: auto;
    padding: 8px;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 0.2s;
}

.lang-option:hover {
    background: var(--bg-tertiary);
}

.lang-option.selected {
    background: var(--accent);
    color: white;
}

.lang-option .lang-flag {
    font-size: 24px;
}

.lang-option .lang-name {
    font-size: 15px;
    font-weight: 500;
}

.lang-option .lang-native {
    font-size: 12px;
    color: var(--text-muted);
}

/* ═══════ TOAST ═══════ */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    z-index: 300;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--blue); }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 360px) {
    .action-buttons {
        gap: 6px;
    }
    .main-btn {
        padding: 12px 8px;
    }
    .btn-icon {
        font-size: 24px;
    }
    .btn-label {
        font-size: 12px;
    }
}

@media (min-width: 481px) {
    .app-container {
        padding: 0 24px 100px;
    }
}

/* ═══════ SCROLLBAR ═══════ */
::-webkit-scrollbar {
    width: 4px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

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