/* =============================================================
   TaskVoice AI -- design tokens
   Ink graphite surface, signal teal accent, voice-first identity.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --tv-bg:        #14171C;
    --tv-panel:     #1B1F27;
    --tv-panel-2:   #21262F;
    --tv-border:    #2A303B;
    --tv-text:      #EDEFF3;
    --tv-muted:     #8B93A3;
    --tv-accent:    #2DD4BF;
    --tv-accent-dim:#1B4C46;
    --tv-amber:     #F0A93E;
    --tv-red:       #F0603E;
    --tv-green:     #3EDC8F;

    --tv-radius-sm: 8px;
    --tv-radius:    14px;
    --tv-radius-lg: 20px;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body:    'Inter', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--tv-bg);
    color: var(--tv-text);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
}

button, input, textarea, select {
    font-family: inherit;
    color: inherit;
}

a { color: var(--tv-accent); }

::selection { background: var(--tv-accent-dim); color: var(--tv-text); }

/* Focus visibility for accessibility */
:focus-visible {
    outline: 2px solid var(--tv-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* -------------------------------------------------------------
   App shell
   ------------------------------------------------------------- */
#app {
    display: flex;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Sidebar (desktop) */
.tv-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--tv-panel);
    border-right: 1px solid var(--tv-border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.tv-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem 1.6rem 0.6rem;
}
.tv-brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--tv-accent), #1596A9);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.tv-brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}
.tv-brand-tagline {
    font-size: 0.72rem;
    color: var(--tv-muted);
    margin-top: -2px;
}

.tv-nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--tv-radius-sm);
    color: var(--tv-muted);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 500;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.tv-nav-item:hover { background: var(--tv-panel-2); color: var(--tv-text); }
.tv-nav-item.active {
    background: var(--tv-accent-dim);
    color: var(--tv-accent);
}
.tv-nav-icon { font-size: 1.05rem; width: 1.3rem; text-align: center; }

.tv-sidebar-footer {
    margin-top: auto;
    font-size: 0.72rem;
    color: var(--tv-muted);
    font-family: var(--font-mono);
    padding: 0.6rem;
    border-top: 1px solid var(--tv-border);
}

/* Main content */
.tv-main {
    flex: 1;
    min-width: 0;
    padding: 2.2rem 2.4rem 6rem 2.4rem;
    max-width: 980px;
}

.tv-page-header h1 {
    font-family: var(--font-display);
    font-size: 1.7rem;
    margin: 0 0 0.2rem 0;
    letter-spacing: -0.01em;
}
.tv-page-header p {
    color: var(--tv-muted);
    margin: 0 0 1.6rem 0;
    font-size: 0.95rem;
}

/* Bottom tab bar (mobile) */
.tv-tabbar {
    display: none;
}

/* -------------------------------------------------------------
   Cards & primitives
   ------------------------------------------------------------- */
.tv-card {
    background: var(--tv-panel);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius);
    padding: 1.1rem 1.3rem;
    margin-bottom: 0.85rem;
}

.tv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    border-radius: var(--tv-radius-sm);
    border: 1px solid var(--tv-border);
    background: var(--tv-panel-2);
    color: var(--tv-text);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease;
}
.tv-btn:hover { background: #262c37; }
.tv-btn:active { transform: scale(0.98); }
.tv-btn.tv-primary {
    background: var(--tv-accent);
    border-color: var(--tv-accent);
    color: #0A1613;
    font-weight: 600;
}
.tv-btn.tv-primary:hover { background: #26bfab; }
.tv-btn.tv-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--tv-muted);
}
.tv-btn.tv-danger { color: var(--tv-red); }
.tv-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tv-input, .tv-textarea, .tv-select {
    width: 100%;
    background: var(--tv-panel-2);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-sm);
    padding: 0.6rem 0.75rem;
    font-size: 0.92rem;
}
.tv-textarea { resize: vertical; min-height: 90px; }
.tv-field { margin-bottom: 0.9rem; }
.tv-label {
    display: block;
    font-size: 0.78rem;
    color: var(--tv-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tv-pill {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}
.tv-pill-low    { background: rgba(62,220,143,0.15); color: var(--tv-green); }
.tv-pill-medium { background: rgba(240,169,62,0.15); color: var(--tv-amber); }
.tv-pill-high   { background: rgba(240,96,62,0.15); color: var(--tv-red); }

.tv-tabs { display: flex; gap: 0.4rem; margin-bottom: 1.2rem; border-bottom: 1px solid var(--tv-border); }
.tv-tab {
    padding: 0.6rem 0.9rem;
    color: var(--tv-muted);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tv-tab.active { color: var(--tv-accent); border-bottom-color: var(--tv-accent); }

.tv-toast {
    position: fixed;
    bottom: 1.4rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tv-panel-2);
    border: 1px solid var(--tv-border);
    padding: 0.7rem 1.1rem;
    border-radius: var(--tv-radius-sm);
    font-size: 0.86rem;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.tv-toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.tv-toast.error { border-color: var(--tv-red); }
.tv-toast.warn { border-color: var(--tv-amber); }

/* -------------------------------------------------------------
   Dashboard
   ------------------------------------------------------------- */
.tv-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.4rem;
}
.tv-stat {
    text-align: left;
}
.tv-stat-emoji { font-size: 1.3rem; margin-bottom: 0.4rem; }
.tv-stat-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; }
.tv-stat-label { font-size: 0.75rem; color: var(--tv-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.tv-chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    margin-bottom: 0.9rem;
}
.tv-chart-card canvas { max-height: 240px; }
.tv-chart-title { font-size: 0.85rem; color: var(--tv-muted); margin-bottom: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* -------------------------------------------------------------
   Add task -- voice signature element
   ------------------------------------------------------------- */
.tv-mic-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.6rem 1rem 1.2rem 1rem;
}
.tv-mic-btn {
    width: 84px; height: 84px;
    border-radius: 50%;
    background: var(--tv-panel-2);
    border: 2px solid var(--tv-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.tv-mic-btn:hover { border-color: var(--tv-accent); }
.tv-mic-btn.recording {
    background: var(--tv-accent-dim);
    border-color: var(--tv-accent);
    animation: tv-pulse-ring 1.6s ease-out infinite;
}
@keyframes tv-pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(45,212,191,0.5); }
    100% { box-shadow: 0 0 0 18px rgba(45,212,191,0); }
}

.tv-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    margin-top: 0.9rem;
}
.tv-waveform .bar {
    width: 4px;
    border-radius: 2px;
    background: var(--tv-accent);
    height: 6px;
    opacity: 0.35;
}
.tv-waveform.active .bar {
    animation: tv-wave 1.1s ease-in-out infinite;
    opacity: 1;
}
.tv-waveform .bar:nth-child(1) { animation-delay: 0s; }
.tv-waveform .bar:nth-child(2) { animation-delay: 0.1s; }
.tv-waveform .bar:nth-child(3) { animation-delay: 0.2s; }
.tv-waveform .bar:nth-child(4) { animation-delay: 0.3s; }
.tv-waveform .bar:nth-child(5) { animation-delay: 0.4s; }
.tv-waveform .bar:nth-child(6) { animation-delay: 0.3s; }
.tv-waveform .bar:nth-child(7) { animation-delay: 0.2s; }
.tv-waveform .bar:nth-child(8) { animation-delay: 0.1s; }
.tv-waveform .bar:nth-child(9) { animation-delay: 0s; }
@keyframes tv-wave {
    0%, 100% { height: 6px; }
    50% { height: 26px; }
}
.tv-mic-caption {
    margin-top: 0.7rem;
    font-size: 0.82rem;
    color: var(--tv-muted);
    text-align: center;
}
.tv-transcript-preview {
    background: var(--tv-panel-2);
    border: 1px solid var(--tv-border);
    border-radius: var(--tv-radius-sm);
    padding: 0.7rem 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-top: 0.8rem;
    width: 100%;
}

/* -------------------------------------------------------------
   AI preview row
   ------------------------------------------------------------- */
.tv-preview-row {
    display: grid;
    grid-template-columns: auto 1fr 140px 120px 110px;
    gap: 0.6rem;
    align-items: center;
}
.tv-preview-row .tv-input, .tv-preview-row .tv-select { padding: 0.45rem 0.6rem; font-size: 0.85rem; }

/* -------------------------------------------------------------
   Task manager
   ------------------------------------------------------------- */
.tv-filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.tv-task-row {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}
.tv-task-row input[type="checkbox"] {
    margin-top: 0.3rem;
    width: 18px; height: 18px;
    accent-color: var(--tv-accent);
    cursor: pointer;
}
.tv-task-body { flex: 1; min-width: 0; }
.tv-task-title { font-size: 1rem; font-weight: 600; }
.tv-task-title.completed { text-decoration: line-through; color: var(--tv-muted); }
.tv-task-meta { font-size: 0.78rem; color: var(--tv-muted); margin-top: 0.2rem; font-family: var(--font-mono); }
.tv-task-desc { font-size: 0.82rem; color: var(--tv-muted); margin-top: 0.3rem; }
.tv-task-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.tv-icon-btn {
    background: transparent; border: none; color: var(--tv-muted);
    cursor: pointer; font-size: 1rem; padding: 0.3rem;
    border-radius: 6px;
}
.tv-icon-btn:hover { background: var(--tv-panel-2); color: var(--tv-text); }

/* -------------------------------------------------------------
   Settings
   ------------------------------------------------------------- */
.tv-settings-section { margin-bottom: 1.8rem; }
.tv-settings-section h3 { font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 0.3rem; }
.tv-settings-section p.tv-hint { color: var(--tv-muted); font-size: 0.85rem; margin: 0 0 0.8rem 0; }
.tv-key-row { display: flex; gap: 0.6rem; }
.tv-key-row .tv-input { flex: 1; }

/* -------------------------------------------------------------
   Empty state
   ------------------------------------------------------------- */
.tv-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--tv-muted);
}
.tv-empty .tv-empty-icon { font-size: 2.2rem; margin-bottom: 0.6rem; }

/* -------------------------------------------------------------
   Responsive
   ------------------------------------------------------------- */
@media (max-width: 860px) {
    .tv-sidebar { display: none; }
    .tv-main { padding: 1.2rem 1rem 5.5rem 1rem; max-width: 100%; }
    .tv-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .tv-chart-grid { grid-template-columns: 1fr; }
    .tv-filters { grid-template-columns: 1fr 1fr; }
    .tv-preview-row { grid-template-columns: 1fr; }

    .tv-tabbar {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: var(--tv-panel);
        border-top: 1px solid var(--tv-border);
        padding: 0.4rem 0.2rem calc(0.4rem + env(safe-area-inset-bottom)) 0.2rem;
        z-index: 100;
    }
    .tv-tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        background: none;
        border: none;
        color: var(--tv-muted);
        font-size: 0.65rem;
        padding: 0.35rem 0;
        cursor: pointer;
    }
    .tv-tab-item .tv-nav-icon { font-size: 1.25rem; }
    .tv-tab-item.active { color: var(--tv-accent); }
}
