/* ========================================
   Deep Work Timer — Styles
   Indigo/Amber dark theme
   ======================================== */

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

:root {
    --primary: #6366F1;
    --primary-hover: #818CF8;
    --primary-glow: rgba(99, 102, 241, 0.25);
    --accent: #F59E0B;
    --accent-hover: #FBBF24;
    --accent-glow: rgba(245, 158, 11, 0.2);
    --success: #22C55E;
    --danger: #EF4444;

    --bg-root: #0F172A;
    --bg-surface: #1E293B;
    --bg-elevated: #334155;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-hover: rgba(99, 102, 241, 0.06);

    --border: rgba(255, 255, 255, 0.06);
    --border-active: rgba(99, 102, 241, 0.4);

    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --shadow-glow: 0 0 24px var(--primary-glow);
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
}

body {
    font-family: var(--font-body);
    background: var(--bg-root);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ---------- App Layout ---------- */
.app {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 220px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* Daily Goal */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.daily-goal {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.goal-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.goal-bar {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.goal-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width var(--transition-smooth);
}

.goal-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ---------- Content ---------- */
.content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
}

.view {
    width: 100%;
    max-width: 680px;
    padding: 32px 24px;
}

.view[hidden] {
    display: none;
}

/* ---------- Timer ---------- */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.timer-ring-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-display {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.timer-time {
    font-family: var(--font-mono);
    font-size: 3.6rem;
    font-weight: 600;
    letter-spacing: 2px;
}

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

.timer-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.control-btn {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-glow);
}

.control-btn:hover {
    transform: scale(1.08);
}

.control-btn.secondary {
    width: 42px;
    height: 42px;
    background: var(--bg-elevated);
    box-shadow: none;
    color: var(--text-secondary);
}

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

.control-btn[hidden] {
    display: none;
}

/* Session Tags */
.session-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.tag-chip {
    padding: 7px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tag-chip:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
}

.tag-chip.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    border-color: var(--primary);
}

/* Ambient */
.ambient-section {
    width: 100%;
    max-width: 400px;
}

.section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    text-align: center;
}

.ambient-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 12px;
}

.ambient-chip {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.72rem;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ambient-chip:hover {
    border-color: var(--border-active);
}

.ambient-chip.active {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}

.volume-slider {
    display: flex;
    justify-content: center;
}

.slider {
    width: 160px;
    height: 4px;
    appearance: none;
    background: var(--bg-elevated);
    border-radius: 2px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-root);
}

/* Flow Indicator */
.flow-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-xl);
    font-size: 0.82rem;
    color: var(--accent);
    animation: fadeIn var(--transition-smooth);
}

.flow-indicator[hidden] {
    display: none;
}

.flow-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.5s infinite;
}

/* ---------- Analytics ---------- */
.analytics-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.analytics-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
}

.analytics-period {
    display: flex;
    gap: 4px;
}

.period-btn {
    padding: 5px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.72rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.period-btn.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-color: var(--primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-value {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.chart-card {
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.chart-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.tag-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tag-stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tag-stat-name {
    font-size: 0.8rem;
    width: 80px;
}

.tag-stat-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
}

.tag-stat-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--primary);
    transition: width var(--transition-smooth);
}

.tag-stat-value {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    min-width: 36px;
    text-align: right;
}

.session-log {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

.log-entry .le-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.log-entry .le-duration {
    font-family: var(--font-mono);
    color: var(--accent);
    margin-left: auto;
}

.log-entry .le-date {
    color: var(--text-tertiary);
    font-size: 0.7rem;
}

/* ---------- Settings ---------- */
#view-settings h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.setting-card {
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-card label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.text-field {
    padding: 9px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
}

.text-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.toggle-btn {
    padding: 7px 16px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-tertiary);
    font-family: var(--font-body);
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.toggle-btn[aria-pressed="true"] {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    border-color: var(--primary);
}

.settings-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary,
.btn-outline,
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--border-active);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    padding: 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideInRight var(--transition-smooth);
    max-width: 320px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--primary);
}

.toast.fade-out {
    animation: fadeOut var(--transition-base) forwards;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(60px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateX(60px);
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-title,
    .nav-item span,
    .sidebar-footer {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .sidebar-header {
        justify-content: center;
        padding: 16px 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}

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

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

::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}