/* ActivTrak Productivity Dashboard */
:root {
    --clr-bg: #F8FAFC;
    --clr-surface: #FFFFFF;
    --clr-border: #E2E8F0;
    --clr-text: #1E293B;
    --clr-text-muted: #64748B;
    --clr-text-light: #94A3B8;
    --clr-primary: #2563EB;
    --clr-green: #16A34A;
    --clr-green-bg: #F0FDF4;
    --clr-yellow: #D97706;
    --clr-yellow-bg: #FFFBEB;
    --clr-red: #DC2626;
    --clr-red-bg: #FEF2F2;
    --clr-purple: #7C3AED;
}

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

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

/* --- Layout --- */
.nav {
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.nav h1 { font-size: 18px; font-weight: 700; }
.nav-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--clr-text-muted); }
.nav-right a { color: var(--clr-primary); text-decoration: none; }
.nav-right a:hover { text-decoration: underline; }

.controls {
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    padding: 12px 24px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.controls label {
    font-size: 12px;
    font-weight: 600;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.controls select,
.controls input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--clr-surface);
    color: var(--clr-text);
}
.controls select:focus,
.controls input:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.main { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* --- Stat cards --- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--clr-border);
    background: var(--clr-surface);
}
.stat .sv {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}
.stat .sl {
    font-size: 11px;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* --- Chart --- */
.chart-section {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}
.chart-section img {
    width: 100%;
    height: auto;
}

/* --- Tables --- */
.tables-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.tbl-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    padding: 14px;
}
.tbl-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
}
table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
table .col-name { width: 55%; }
table .col-time { width: 22%; }
table .col-pct  { width: 23%; }
td.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;
}
th {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    letter-spacing: 0.3px;
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--clr-border);
    font-weight: 600;
}
td {
    padding: 5px 8px;
    border-bottom: 1px solid #F1F5F9;
    font-size: 13px;
}
td.right, th.right { text-align: right; }
.text-muted { color: var(--clr-text-muted); }

/* --- AI Summary --- */
.ai-section {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}
.ai-section .section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--clr-text-muted);
    margin-bottom: 8px;
}
.ai-section .ai-text {
    font-size: 14px;
    line-height: 1.6;
    color: #334155;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--clr-border);
    background: var(--clr-surface);
    color: var(--clr-text);
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover { background: var(--clr-bg); }
.btn-primary {
    background: var(--clr-primary);
    color: white;
    border-color: var(--clr-primary);
}
.btn-primary:hover { background: #1D4ED8; }
.btn-green {
    background: var(--clr-green);
    color: white;
    border-color: var(--clr-green);
}
.btn-green:hover { background: #15803D; }

/* --- HTMX loading indicator --- */
.htmx-indicator {
    display: none;
    margin-left: 8px;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--clr-border);
    border-top-color: var(--clr-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Modal / Lightbox --- */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
}
.modal-backdrop.active { display: flex; }
.modal {
    background: var(--clr-surface);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h2 {
    font-size: 18px;
    margin-bottom: 16px;
}
.modal .user-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 16px;
}
.modal .user-list label {
    display: block;
    padding: 4px 8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
}
.modal .user-list label:hover { background: var(--clr-bg); }
.modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Login page --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.login-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-card h1 { margin-bottom: 8px; }
.login-card p { color: var(--clr-text-muted); margin-bottom: 24px; }

/* --- Progress bar for export --- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--clr-bg);
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
}
.progress-bar .fill {
    height: 100%;
    background: var(--clr-primary);
    width: 0%;
    transition: width 0.3s;
    border-radius: 4px;
}
