/* Linear-style UI Design System */
:root {
    --bg-primary: #08090a;          /* Deep dark base background */
    --bg-secondary: #0f1012;        /* Sidebar / Container background */
    --card-bg: #121316;             /* Card background */
    --card-hover-bg: #16171a;       /* Hover state for list items/cards */
    --accent-purple: #5e6ad2;       /* Linear primary purple brand color */
    --accent-blue: #0066cc;
    --accent-pink: #e0245e;
    --text-primary: #f7f8f8;        /* Near white high contrast text */
    --text-secondary: #8a8f98;      /* Muted gray text */
    --text-tertiary: #4b4e56;       /* Subdued gray details */
    --border-color: #1f2023;        /* Thin sharp border */
    --border-hover: #2e3035;        /* Accentuated hover border */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Lucide Icons Integration */
.lucide {
    display: inline-block;
    stroke-width: 2px;
    vertical-align: middle;
}

/* Reset and Core Styling */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: stretch;
    -webkit-font-smoothing: antialiased;
}

/* Container Layout (Linear Style) */
.glass-container {
    width: 100%;
    max-width: 960px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple);
}

.logo-icon svg {
    width: 26px;
    height: 26px;
    stroke-width: 1.8px;
}

.logo-text h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.logo-text p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

/* Linear-style Flat Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.badge-disconnected {
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.badge-connecting {
    background: rgba(245, 158, 11, 0.08);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.15);
    animation: pulse 1.5s infinite;
}

.badge-connected {
    background: rgba(16, 185, 129, 0.08);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 0; /* Keep children height-constrained */
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .desktop-body {
        padding: 1rem;
    }
    .glass-container {
        padding: 1.2rem;
        border-radius: 8px;
    }
}

/* Linear-style Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* Keep card contained */
}

.card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    letter-spacing: -0.1px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 1.2rem;
}

/* QR Code & Pairing (Linear-style clean outline) */
.qr-wrapper {
    background: #0b0c0e;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 0 auto 1rem;
    width: 170px;
    height: 170px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.qr-code canvas {
    width: 100% !important;
    height: 100% !important;
}

.qr-loading {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.pairing-details {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.6rem;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 500;
}

.copy-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.font-mono {
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Buttons (Linear Minimalist Buttons) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    outline: none;
}

.btn-primary {
    background-color: var(--accent-purple);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #4f5bcf;
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
}

.btn-tertiary {
    background: transparent;
    color: var(--text-secondary);
}

.btn-tertiary:hover {
    color: var(--text-primary);
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
    border-radius: 4px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s, color 0.15s;
    color: var(--text-secondary);
}

.btn-icon:hover {
    opacity: 1;
    color: var(--text-primary);
}

.btn-icon svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.2px;
}

.btn-icon-inside {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.2rem;
}

.btn-icon-inside svg {
    width: 14px;
    height: 14px;
    stroke-width: 2px;
}

/* Dictation Log Feed (Clean List View) */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.log-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    margin-bottom: 1rem;
}

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

.empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.35;
    color: var(--text-secondary);
}

.empty-icon svg {
    width: 36px;
    height: 36px;
    stroke-width: 1.5px;
}

.log-item {
    padding: 0.7rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.01);
    border-left: 2px solid var(--accent-purple);
    border-top: 1px solid rgba(255,255,255,0.01);
    border-right: 1px solid rgba(255,255,255,0.01);
    border-bottom: 1px solid rgba(255,255,255,0.01);
    margin-bottom: 0.6rem;
    animation: slideIn 0.2s ease-out;
}

.log-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.log-text {
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-all;
    color: var(--text-primary);
}

/* Settings Sections */
.settings-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.2rem;
}

.settings-section h3 {
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.setting-title {
    font-size: 0.85rem;
    font-weight: 500;
}

.setting-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* Toggle Switch Button (Precision Toggle) */
.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1f2023;
    transition: .15s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: .15s;
}

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

input:checked + .slider:before {
    transform: translateX(18px);
    background-color: #ffffff;
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Toast Alerts (Minimal Linear Toast) */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 1000;
}

.toast {
    background: #16171a;
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    color: var(--text-primary);
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: toastIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    border-left: 3px solid var(--accent-blue);
}

.toast-success {
    border-left-color: #10b981;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke-width: 2.2px;
}

/* Mobile Dictation UI Styles (Linear aesthetics on Phone) */
.mobile-body {
    padding: 1rem;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    background-color: var(--bg-primary);
}

.mobile-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    gap: 1.2rem;
}

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

.mobile-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.2px;
}

/* Mobile Editor Card */
.editor-card {
    flex-grow: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.editor-textarea {
    width: 100%;
    flex-grow: 1;
    background: transparent;
    border: none;
    resize: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.5;
    outline: none;
}

.editor-textarea::placeholder {
    color: var(--text-tertiary);
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.72rem;
    border-top: 1px solid rgba(255,255,255,0.02);
    padding-top: 0.5rem;
}

/* Mic Recording Area */
.record-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.mic-section {
    position: relative;
    width: 110px;
    height: 110px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-mic {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background-color: var(--accent-purple);
    border: none;
    outline: none;
    cursor: pointer;
    font-size: 1.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(94, 106, 210, 0.2);
    z-index: 2;
    transition: all 0.2s ease;
}

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

.btn-mic svg {
    width: 28px;
    height: 28px;
    color: white;
    stroke-width: 2px;
    transition: transform 0.2s ease;
}

.btn-mic.recording {
    background-color: var(--accent-pink);
    box-shadow: 0 4px 16px rgba(224, 36, 94, 0.3);
}

/* Flat Ripple Rings */
.ripple-ring {
    position: absolute;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--accent-purple);
    opacity: 0.2;
    z-index: 1;
}

.recording ~ .ripple-ring-1 {
    animation: ripple 2s infinite linear;
}

.recording ~ .ripple-ring-2 {
    animation: ripple 2s infinite linear 0.6s;
}

.recording ~ .ripple-ring-3 {
    animation: ripple 2s infinite linear 1.2s;
}

.record-status {
    font-size: 0.85rem;
    font-weight: 500;
}

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

.status-listening {
    color: var(--accent-pink);
}

.lang-selector {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.45rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}

.lang-selector:hover {
    background: rgba(255, 255, 255, 0.08);
}

.mobile-actions {
    display: grid;
    grid-template-columns: 1.1fr 2.2fr;
    gap: 0.6rem;
    width: 100%;
}

/* Pairing Code Inputs */
.pair-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.8rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.pair-card h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.input-code-row {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.code-input-char {
    width: 40px;
    height: 48px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    color: white;
    outline: none;
    transition: all 0.15s;
}

.code-input-char:focus {
    border-color: var(--accent-purple);
    background: rgba(94, 106, 210, 0.03);
}

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

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

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

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- QR Scanner --- */

.pair-actions {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.5rem;
}

.btn-scan {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.7rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-hover);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    transition: all 0.15s ease;
    outline: none;
}

.btn-scan:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(94, 106, 210, 0.5);
    color: #fff;
}

.btn-scan .lucide {
    width: 16px;
    height: 16px;
    stroke: var(--accent-purple);
}

/* Fullscreen Scanner Overlay */
.qr-scanner-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-scanner-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.qr-scanner-title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}

.btn-close-scanner {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    outline: none;
    transition: background 0.15s;
}

.btn-close-scanner:hover {
    background: rgba(255,255,255,0.15);
}

.btn-close-scanner .lucide {
    width: 18px;
    height: 18px;
}

.qr-scanner-body {
    flex: 1;
    position: relative;
    width: 100%;
    overflow: hidden;
}

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

/* Guide frame */
.qr-guide-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(65vw, 240px);
    height: min(65vw, 240px);
    pointer-events: none;
}

.qr-corner {
    position: absolute;
    width: 22px;
    height: 22px;
    border-color: var(--accent-purple);
    border-style: solid;
}

.qr-corner-tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.qr-corner-tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.qr-corner-bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.qr-corner-br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

/* Animated scan line */
.qr-scan-line {
    position: absolute;
    left: 4px;
    right: 4px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-purple), transparent);
    border-radius: 2px;
    animation: scanMove 2s ease-in-out infinite;
}

@keyframes scanMove {
    0%   { top: 8px; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { top: calc(100% - 8px); opacity: 0; }
}

.qr-scanner-hint {
    padding: 1rem;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    background: rgba(0,0,0,0.6);
    width: 100%;
}
