/* Pzishky — Global Stylesheet */

/* ── CSS Custom Properties (Mono theme default) ─────────────────────────── */
:root {
    --bg:          #f5f5f5;
    --surface:     #ffffff;
    --border:      #e0e0e0;
    --text:        #111111;
    --text-muted:  #666666;
    --accent:      #555555;
    --accent-soft: #ebebeb;
    --danger:      #c0392b;
    --success:     #1a7a4a;
    --radius-card: 8px;
    --radius-input: 6px;
    --transition:  150ms ease;
}

/* Warm theme */
[data-theme="warm"] {
    --bg:          #fdf6ec;
    --surface:     #fffaf4;
    --border:      #e8d8c4;
    --text:        #2c1a0e;
    --text-muted:  #7a5c3e;
    --accent:      #c97d3a;
    --accent-soft: #f5e8d6;
}

/* Cool theme */
[data-theme="cool"] {
    --bg:          #f0f4f8;
    --surface:     #ffffff;
    --border:      #d0dce8;
    --text:        #0d1f2d;
    --text-muted:  #4a6070;
    --accent:      #2a7d9c;
    --accent-soft: #ddeef5;
}

/* Dark mode overrides via media query */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:          #1a1a1a;
        --surface:     #242424;
        --border:      #333333;
        --text:        #f0f0f0;
        --text-muted:  #888888;
        --accent:      #aaaaaa;
        --accent-soft: #2e2e2e;
    }
    [data-theme="warm"] {
        --bg:          #1c1410;
        --surface:     #261c14;
        --border:      #3d2a1a;
        --text:        #f0e4d4;
        --text-muted:  #a07850;
        --accent:      #d4885a;
        --accent-soft: #3a2210;
    }
    [data-theme="cool"] {
        --bg:          #0d1820;
        --surface:     #142030;
        --border:      #1e3448;
        --text:        #d8eaf8;
        --text-muted:  #5a8aaa;
        --accent:      #4aadcc;
        --accent-soft: #102030;
    }
}

/* Manual dark toggle (class-based, overrides media query) */
[data-dark="true"] {
    --bg:          #1a1a1a;
    --surface:     #242424;
    --border:      #333333;
    --text:        #f0f0f0;
    --text-muted:  #888888;
    --accent:      #aaaaaa;
    --accent-soft: #2e2e2e;
}
[data-dark="true"][data-theme="warm"] {
    --bg:          #1c1410;
    --surface:     #261c14;
    --border:      #3d2a1a;
    --text:        #f0e4d4;
    --text-muted:  #a07850;
    --accent:      #d4885a;
    --accent-soft: #3a2210;
}
[data-dark="true"][data-theme="cool"] {
    --bg:          #0d1820;
    --surface:     #142030;
    --border:      #1e3448;
    --text:        #d8eaf8;
    --text-muted:  #5a8aaa;
    --accent:      #4aadcc;
    --accent-soft: #102030;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background var(--transition), color var(--transition);
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ── Top Navigation ───────────────────────────────────────────────────────── */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}
.nav-brand a { color: inherit; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.nav-username {
    font-weight: 600;
    color: var(--text);
}

.nav-link {
    color: var(--text-muted);
    transition: color var(--transition);
}
.nav-link:hover { color: var(--accent); text-decoration: none; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0.25rem;
    transition: color var(--transition);
    font-family: inherit;
}
.btn-icon:hover { color: var(--accent); }

/* ── Main Layout ─────────────────────────────────────────────────────────── */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

/* ── Module Grid (Dashboard) ─────────────────────────────────────────────── */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    text-decoration: none;
    display: block;
    color: var(--text);
}
.module-card:hover {
    border-color: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-decoration: none;
    color: var(--text);
}
.module-card.disabled {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

.module-icon {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    display: block;
}

.module-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

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

/* ── Generic Card ─────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Form Elements ─────────────────────────────────────────────────────────── */
.input, input[type="text"], input[type="password"], input[type="email"],
input[type="number"], select, textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-input);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    transition: border-color var(--transition);
    outline: none;
}
.input:focus, input[type="text"]:focus, input[type="password"]:focus,
input[type="email"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
    border-color: var(--accent);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-input);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity var(--transition), background var(--transition);
}
.btn:hover { opacity: 0.85; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-secondary {
    background: var(--accent-soft);
    color: var(--text);
    border-color: var(--border);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

/* ── Pomodoro ────────────────────────────────────────────────────────────── */
.pomo-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 800px) {
    .pomo-layout { grid-template-columns: 1fr; }
}

.pomo-timer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.pomo-mode-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.pomo-mode-tab {
    padding: 0.3rem 0.9rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}
.pomo-mode-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pomo-phase-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.75rem;
}
.pomo-phase-tab {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: none;
    background: none;
    font-family: inherit;
    transition: color var(--transition);
}
.pomo-phase-tab.active {
    color: var(--text);
    font-weight: 600;
}

.pomo-time {
    font-size: clamp(3.5rem, 10vw, 5.5rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, 'Courier New', monospace;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.pomo-task-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-height: 1.4em;
    margin-bottom: 1.75rem;
}

.pomo-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.pomo-start {
    font-size: 1rem;
    padding: 0.65rem 2.5rem;
    border-radius: var(--radius-input);
    min-width: 130px;
}

.pomo-overflow {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-height: 1.2em;
    font-variant-numeric: tabular-nums;
}

.pomo-distraction-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.pomo-distraction-overlay.open {
    display: flex;
}
.pomo-distraction-box {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    width: 360px;
    max-width: 95vw;
}
.pomo-distraction-box h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}
.pomo-distraction-box textarea {
    width: 100%;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 0.75rem;
}

/* ── Sidebar: tasks panel ────────────────────────────────────────────────── */
.tasks-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tasks-panel h3 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}
.task-item:last-child { border-bottom: none; }
.task-item.active { background: var(--accent-soft); border-radius: 4px; padding: 0.5rem; }
.task-item.done .task-title { text-decoration: line-through; opacity: 0.5; }

.task-check {
    width: 15px;
    height: 15px;
    margin-top: 2px;
    accent-color: var(--accent);
    flex-shrink: 0;
}
.task-info { flex: 1; min-width: 0; }
.task-title {
    font-size: 0.88rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.task-pomo-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.task-add-form {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.75rem;
}
.task-add-form input {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
}
.task-add-form .btn { flex-shrink: 0; }

/* ── Analytics ───────────────────────────────────────────────────────────── */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1rem;
    text-align: center;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1;
    margin-bottom: 0.3rem;
}
.stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-top: 0.5rem;
}
.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    background: var(--accent-soft);
    transition: background var(--transition);
}
.heatmap-cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 25%, var(--accent-soft)); }
.heatmap-cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 50%, var(--accent-soft)); }
.heatmap-cell[data-level="3"] { background: color-mix(in srgb, var(--accent) 75%, var(--accent-soft)); }
.heatmap-cell[data-level="4"] { background: var(--accent); }

/* ── Audio Controls ──────────────────────────────────────────────────────── */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.audio-controls select { font-size: 0.82rem; padding: 0.3rem 0.5rem; }
.audio-controls input[type="range"] {
    accent-color: var(--accent);
    flex: 1;
    max-width: 100px;
}

/* ── Break prompt ────────────────────────────────────────────────────────── */
.break-prompt {
    background: var(--accent-soft);
    border-radius: var(--radius-card);
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    color: var(--text);
    margin-top: 1rem;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Session fade (minimal UI during active timer) ───────────────────────── */
body.session-active .nav,
body.session-active .tasks-panel > *:not(.task-item.active) {
    opacity: 0.4;
    transition: opacity 1s ease;
}
body.session-active .nav:hover,
body.session-active .tasks-panel:hover > * {
    opacity: 1;
}

/* ── Admin table ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-soft); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-green  { background: #d4edda; color: #155724; }
.badge-red    { background: #f8d7da; color: #721c24; }
.badge-blue   { background: #cce5ff; color: #004085; }
.badge-gray   { background: var(--accent-soft); color: var(--text-muted); }

@media (prefers-color-scheme: dark) {
    .badge-green { background: #0d3320; color: #5acf84; }
    .badge-red   { background: #3d1215; color: #f06070; }
    .badge-blue  { background: #0d2040; color: #60a8f0; }
}

/* ── Reflection / Energy rating ─────────────────────────────────────────── */
.energy-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin: 0.75rem 0;
}
.energy-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-family: inherit;
}
.energy-btn.selected,
.energy-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 400;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 1.75rem;
    width: 420px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { font-size: 1.05rem; margin-bottom: 1rem; }

/* ── Misc utilities ──────────────────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
