/* VAO Time Tracker — V2 Stylesheet
   - Full light + dark theme support
   - Mobile-first with bottom nav on phones
   - Improved contrast and readability throughout */

:root {
    --font: 'Montserrat', system-ui, -apple-system, sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;
}

/* ─── DARK THEME (default) ───────────────── */
[data-theme="dark"] {
    --bg:           #0a0a0a;
    --bg-soft:      #141414;
    --bg-card:      #1a1a1a;
    --bg-elev:      #222222;
    --border:       #2a2a2a;
    --border-soft:  #232323;
    --text:         #f5f0e8;
    --text-soft:    #c5c0b8;
    --text-muted:   #888880;
    --text-faint:   #555550;
    --accent:       #c0392b;
    --accent-soft:  #e0594d;
    --success:      #2ecc71;
    --shadow:       rgba(0, 0, 0, 0.4);
}

/* ─── LIGHT THEME ────────────────────────── */
[data-theme="light"] {
    --bg:           #f5f0e8;
    --bg-soft:      #ebe5da;
    --bg-card:      #ffffff;
    --bg-elev:      #faf6ee;
    --border:       #d8d0c2;
    --border-soft:  #e6dfd0;
    --text:         #1a1a1a;
    --text-soft:    #3a3a3a;
    --text-muted:   #6a6a60;
    --text-faint:   #9a9a90;
    --accent:       #c0392b;
    --accent-soft:  #a82d20;
    --success:      #1e8449;
    --shadow:       rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    background: var(--bg); color: var(--text);
    font-family: var(--font); -webkit-font-smoothing: antialiased;
    transition: background 0.2s ease, color 0.2s ease;
}
body { min-height: 100vh; min-height: 100dvh; font-weight: 400; font-size: 15px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea { color-scheme: light dark; }

/* ─── AUTH ─────────────────────────────── */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; min-height: 100dvh; padding: 24px;
}
.auth-wrap { width: 100%; max-width: 400px; text-align: center; }
.auth-brand { margin-bottom: 32px; }
.auth-logo { font-size: 42px; font-weight: 700; letter-spacing: 6px; color: var(--text); }
.auth-tag { font-size: 11px; letter-spacing: 4px; text-transform: uppercase; color: var(--text-muted); margin-top: 6px; }
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: left;
    box-shadow: 0 1px 3px var(--shadow);
}
.auth-tabs {
    display: flex; gap: 4px; margin-bottom: 24px;
    background: var(--bg-soft); padding: 4px; border-radius: var(--radius);
}
.auth-tab {
    flex: 1; text-align: center; padding: 10px 12px;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    border-radius: 6px; transition: all .15s;
}
.auth-tab.active {
    background: var(--bg-card); color: var(--text);
    box-shadow: 0 1px 2px var(--shadow);
}
.auth-form label {
    display: block; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase;
    color: var(--text-muted); margin: 16px 0 6px; font-weight: 500;
}
.auth-form label:first-of-type { margin-top: 0; }
.auth-form .opt { text-transform: none; letter-spacing: 0; color: var(--text-faint); font-size: 11px; font-weight: 400; }
.auth-form input {
    width: 100%; padding: 12px 14px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text);
    font-weight: 400; font-size: 15px;
    transition: border-color .15s, background .15s;
}
.auth-form input:focus { outline: none; border-color: var(--text-soft); background: var(--bg-elev); }
.auth-error {
    margin-top: 14px; padding: 10px 12px;
    background: rgba(192, 57, 43, 0.1); border: 1px solid rgba(192, 57, 43, 0.3);
    border-radius: var(--radius); color: var(--accent-soft); font-size: 13px;
}
.btn-primary {
    width: 100%; margin-top: 20px; padding: 14px;
    background: var(--text); color: var(--bg);
    border: none; border-radius: var(--radius);
    font-weight: 600; font-size: 14px; letter-spacing: 0.5px;
    transition: opacity .15s, transform .1s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { transform: scale(0.98); }
.auth-foot { margin-top: 24px; font-size: 11px; color: var(--text-faint); letter-spacing: 1px; }

/* ─── APP HEADER ───────────────────────── */
.app-body { padding-bottom: 32px; }
.app-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.app-header-inner {
    max-width: 1100px; margin: 0 auto; padding: 14px 20px;
    display: flex; align-items: center; gap: 20px;
}
.app-brand { display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; }
.logo-mark { font-size: 18px; font-weight: 700; letter-spacing: 3px; color: var(--text); }
.logo-sub { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); }

.app-nav { display: flex; gap: 4px; flex: 1; }
.nav-btn {
    background: none; border: none; padding: 10px 14px;
    font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
    color: var(--text-muted); border-radius: var(--radius);
    transition: all .15s; font-weight: 500;
}
.nav-btn:hover { color: var(--text); background: var(--bg-soft); }
.nav-btn.active { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }

.app-tools { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.theme-toggle {
    width: 38px; height: 38px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-soft); font-size: 16px;
    transition: all .15s;
}
.theme-toggle:hover { background: var(--bg-elev); color: var(--text); }
.user-name { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.user-logout {
    width: 38px; height: 38px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 14px;
    transition: all .15s;
}
.user-logout:hover { color: var(--text); background: var(--bg-elev); }

/* ─── MAIN / VIEWS ─────────────────────── */
.app-main { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.view { display: none; }
.view.active { display: block; }

/* ─── NOW VIEW ─────────────────────────── */
.now-grid { display: grid; gap: 16px; }
.timer-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 32px 24px;
    text-align: center;
    transition: border-color .3s;
    box-shadow: 0 1px 3px var(--shadow);
}
.timer-card.working { border-color: var(--success); }
.timer-status {
    font-size: 11px; letter-spacing: 3px; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 8px; font-weight: 500;
}
.timer-card.working .timer-status { color: var(--success); }
.timer-clock {
    font-family: var(--mono); font-size: 56px; font-weight: 500;
    letter-spacing: -1px; color: var(--text);
    margin-bottom: 4px; line-height: 1.1;
}
.timer-meta {
    font-size: 13px; color: var(--text-muted); margin-bottom: 24px; min-height: 18px;
    line-height: 1.5;
}
.timer-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    margin-bottom: 20px; text-align: left;
}
.timer-fields .field.full { grid-column: 1 / -1; }
.field label {
    display: block; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 6px; font-weight: 500;
}
.field .opt { text-transform: none; letter-spacing: 0; color: var(--text-faint); font-weight: 400; }
.field input, .field select, .field textarea {
    width: 100%; padding: 11px 12px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text);
    font-weight: 400; font-size: 14px;
    transition: border-color .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--text-soft); background: var(--bg-elev);
}
.field select {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%23888880' d='M0 0l5 6 5-6z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
[data-theme="light"] .field select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236a6a60' d='M0 0l5 6 5-6z'/></svg>");
}

.timer-btn {
    width: 100%; padding: 16px;
    background: var(--text); color: var(--bg);
    border: none; border-radius: var(--radius);
    font-weight: 600; font-size: 14px; letter-spacing: 1px; text-transform: uppercase;
    transition: all .15s;
    min-height: 52px;
}
.timer-btn:hover { opacity: 0.85; }
.timer-btn:active { transform: scale(0.98); }
.timer-card.working .timer-btn {
    background: var(--accent); color: #ffffff;
}

.stats-row {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.stat {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    text-align: center;
}
.stat-label {
    font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 6px; font-weight: 500;
}
.stat-value { font-size: 22px; font-weight: 600; color: var(--text); }
.mono { font-family: var(--mono); }

.chart-card, .sessions-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
}
.card-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.card-head h3 {
    font-size: 14px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
    color: var(--text);
}
.card-sub { font-size: 12px; color: var(--text-muted); }

.bar-chart {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
    align-items: end; height: 140px; margin-bottom: 10px;
}
.bar {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    position: relative;
    min-height: 6px;
    transition: all .2s;
}
.bar.has-data { background: var(--text); border-color: var(--text); }
.bar.today { background: var(--accent); border-color: var(--accent); }
.bar-tip {
    position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
    font-family: var(--mono); font-size: 10px; color: var(--text-muted); white-space: nowrap;
    font-weight: 500;
}
.bar-labels {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
}
.bar-label {
    text-align: center; font-size: 11px; color: var(--text-muted); font-weight: 500;
}
.bar-label.today { color: var(--text); font-weight: 700; }

/* Sessions list */
.sessions-list .empty {
    text-align: center; padding: 24px; font-size: 13px; color: var(--text-muted);
}
.session-row {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 0;
    border-top: 1px solid var(--border-soft);
    transition: background .15s;
    cursor: pointer;
}
.session-row:first-child { border-top: none; }
.session-row:hover { background: var(--bg-soft); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 6px; border-color: transparent; }
.sessions-list.large .session-row { padding: 18px 12px; }
.session-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted); flex-shrink: 0;
}
.session-dot.live { background: var(--success); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.session-main { flex: 1; min-width: 0; }
.session-time { font-family: var(--mono); font-size: 14px; color: var(--text); font-weight: 500; }
.session-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.session-tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px;
    background: var(--bg-soft); border-radius: var(--radius-pill);
    font-size: 11px; letter-spacing: 0.3px;
    color: var(--text-soft); font-weight: 500;
}
.session-tag-dot { width: 6px; height: 6px; border-radius: 50%; }
.session-client-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11px;
    background: var(--bg-soft); color: var(--text-soft); font-weight: 500;
}
.session-client-dot { width: 6px; height: 6px; border-radius: 50%; }
.session-notes { font-size: 12px; color: var(--text-muted); margin-top: 6px; font-style: italic; line-height: 1.4; }
.session-duration {
    font-family: var(--mono); font-size: 14px; font-weight: 600;
    color: var(--text); flex-shrink: 0;
}

/* ─── HISTORY ───────────────────────────── */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px;
}
.btn-field { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.btn-secondary {
    flex: 1; padding: 11px 12px;
    background: var(--bg-soft); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 12px; font-weight: 500; letter-spacing: 0.3px;
    transition: all .15s;
    min-height: 42px;
    white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg-elev); border-color: var(--text-soft); }
.history-summary {
    display: flex; gap: 32px; padding: 16px 20px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); margin-bottom: 16px;
    flex-wrap: wrap;
}
.history-summary .item { display: flex; flex-direction: column; gap: 4px; }
.history-summary .item-label { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 500; }
.history-summary .item-value { font-family: var(--mono); font-size: 20px; font-weight: 600; color: var(--text); }

/* ─── REPORTS ───────────────────────────── */
.reports-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .reports-grid { grid-template-columns: 1fr; } }
.breakdown-list { display: flex; flex-direction: column; gap: 12px; }
.breakdown-row { padding: 10px 0; border-top: 1px solid var(--border-soft); }
.breakdown-row:first-child { border-top: none; padding-top: 0; }
.breakdown-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px; gap: 12px;
}
.breakdown-name { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); font-weight: 500; }
.breakdown-color { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.breakdown-value { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.breakdown-pct { font-size: 11px; color: var(--text-muted); margin-left: 6px; font-weight: 500; }
.breakdown-bar {
    height: 5px; background: var(--bg-soft); border-radius: 3px; overflow: hidden;
}
.breakdown-bar-fill { height: 100%; background: var(--text); transition: width .3s; }
.breakdown-parent { font-size: 10px; color: var(--text-muted); margin-left: 18px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── CLIENTS & PROJECT TYPES ──────────── */
.add-form {
    display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px;
}
.add-form input[type="text"], .add-form select {
    flex: 1; min-width: 160px; padding: 11px 12px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px;
}
.add-form input[type="color"] {
    width: 48px; height: 42px; padding: 2px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); cursor: pointer;
}
.add-form .btn-primary { width: auto; margin: 0; padding: 11px 22px; font-size: 13px; min-height: 42px; }

.list-section { margin-bottom: 28px; }
.list-section h4 {
    font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 10px; font-weight: 600;
    padding: 0 4px;
}
.editable-list { display: flex; flex-direction: column; gap: 6px; }
.editable-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 14px;
    transition: all .15s;
}
.editable-row.indent { margin-left: 24px; background: var(--bg-elev); }
.editable-row.archived { opacity: 0.55; }
.editable-row .row-color { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; cursor: pointer; }
.editable-row .row-name {
    flex: 1; min-width: 0;
    font-size: 14px; color: var(--text);
    background: transparent; border: none; padding: 6px 0;
    font-weight: 500;
}
.editable-row .row-name:focus { outline: none; border-bottom: 1px solid var(--text-soft); }
.editable-row .row-name.archived { text-decoration: line-through; color: var(--text-muted); }
.editable-row.parent .row-name { font-weight: 600; }
.row-actions { display: flex; gap: 6px; }
.row-actions button {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-muted); padding: 6px 10px;
    border-radius: 6px; font-size: 11px; letter-spacing: 0.3px;
    transition: all .15s; font-weight: 500;
}
.row-actions button:hover { color: var(--text); border-color: var(--text-soft); background: var(--bg-soft); }
.row-actions .danger:hover { color: var(--accent-soft); border-color: var(--accent); background: rgba(192, 57, 43, 0.08); }

.add-sub-link {
    margin-left: 24px; padding: 8px 14px;
    font-size: 12px; color: var(--text-muted);
    background: transparent; border: 1px dashed var(--border);
    border-radius: var(--radius); text-align: left;
    transition: all .15s; cursor: pointer;
}
.add-sub-link:hover { color: var(--text); border-color: var(--text-soft); }

/* ─── MODAL ────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 20px;
    backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none; }
.modal-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 32px var(--shadow);
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 14px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.modal-close {
    background: transparent; border: none; color: var(--text-muted); font-size: 24px;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: 6px; transition: all .15s;
}
.modal-close:hover { color: var(--text); background: var(--bg-soft); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot {
    padding: 16px 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; gap: 10px;
}
.modal-foot .btn-primary { width: auto; margin: 0; padding: 11px 22px; font-size: 13px; }
.btn-danger {
    background: transparent; color: var(--accent-soft);
    border: 1px solid rgba(192, 57, 43, 0.4); border-radius: var(--radius);
    padding: 11px 18px; font-size: 13px; font-weight: 500; letter-spacing: 0.3px;
    transition: all .15s;
}
.btn-danger:hover { background: rgba(192, 57, 43, 0.1); border-color: var(--accent); }

/* ─── MOBILE — bottom nav, larger taps ──── */
@media (max-width: 720px) {
    body { padding-bottom: 70px; font-size: 16px; }
    .timer-clock { font-size: 48px; }
    .timer-fields { grid-template-columns: 1fr; gap: 14px; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .stats-row .stat:nth-child(3) { grid-column: 1 / -1; }
    .field-row { grid-template-columns: 1fr; }
    .app-main { padding: 16px; }

    /* HEADER: hide nav (moves to bottom), keep brand + theme toggle + logout */
    .app-header-inner { padding: 12px 16px; gap: 10px; }
    .app-nav { display: none; }
    .user-name { display: none; }

    /* BOTTOM NAV BAR */
    .mobile-nav {
        display: flex !important;
        position: fixed; left: 0; right: 0; bottom: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border);
        padding: 8px 0 max(8px, env(safe-area-inset-bottom));
        z-index: 60;
        justify-content: space-around;
    }
    .mobile-nav-btn {
        flex: 1; background: none; border: none;
        display: flex; flex-direction: column; align-items: center; gap: 4px;
        padding: 8px 4px; color: var(--text-muted); font-size: 11px;
        font-weight: 500; letter-spacing: 0.3px;
        transition: color .15s;
    }
    .mobile-nav-btn .icon {
        width: 22px; height: 22px;
        display: flex; align-items: center; justify-content: center;
    }
    .mobile-nav-btn.active { color: var(--text); }
    .mobile-nav-btn.active .icon svg { stroke: var(--text); }
    .mobile-nav-btn .icon svg { stroke: var(--text-muted); transition: stroke .15s; }

    .timer-card { padding: 24px 18px; }
    .modal-overlay { padding: 12px; align-items: flex-end; }
    .modal-card { max-height: 85vh; }
    .filters { padding: 12px; gap: 10px; }
    .add-form { padding: 12px; }
}
.mobile-nav { display: none; }

@media (max-width: 380px) {
    .timer-clock { font-size: 40px; }
    .stat-value { font-size: 18px; }
    .history-summary { gap: 16px; }
    .history-summary .item-value { font-size: 17px; }
}
