@import url("https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap");

/* ═══════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════ */
:root {
    /* Palette */
    --bg: #0c0d0f;
    --surface-1: #131518;
    --surface-2: #1a1c21;
    --surface-3: #21242b;
    --border: #252830;
    --border-strong: #333743;

    /* Text */
    --text-1: #edeef0;
    --text-2: #8c909e;
    --text-3: #525660;

    /* Accent — warm amber */
    --accent: #f0b429;
    --accent-light: #f0b42918;
    --accent-hover: #ffc93d;
    --accent-text: #0c0d0f;

    /* Danger */
    --danger: #e05252;
    --danger-light: #e0525218;

    /* Radii */
    --r-sm: 5px;
    --r-md: 8px;
    --r-lg: 14px;
    --r-xl: 20px;

    /* Transitions */
    --t: 150ms ease;
    --t-slow: 280ms ease;

    /* Layout */
    --topbar-h: 56px;

    font-family: "Geist", sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════
   RESET
═══════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    height: 100%;
}
body {
    min-height: 100%;
    background: var(--bg);
    color: var(--text-1);
    line-height: 1.5;
}
button,
input,
select,
textarea {
    font: inherit;
}
a {
    color: inherit;
}

/* ═══════════════════════════════════════════════════════════
   UTILITY
═══════════════════════════════════════════════════════════ */
.accent {
    color: var(--accent);
}
em {
    font-style: normal;
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.005em;
    padding: 9px 18px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition:
        background var(--t),
        border-color var(--t),
        color var(--t),
        box-shadow var(--t),
        transform 80ms ease;
    outline: none;
    line-height: 1;
}
.btn:active {
    transform: translateY(1px);
}
.btn svg {
    flex-shrink: 0;
}

/* Primary */
.btn--primary {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
    font-weight: 600;
}
.btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-light);
}

/* Secondary */
.btn--secondary {
    background: var(--surface-2);
    color: var(--text-1);
    border-color: var(--border-strong);
}
.btn--secondary:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
}

/* Ghost */
.btn--ghost {
    background: transparent;
    color: var(--text-2);
    border-color: transparent;
}
.btn--ghost:hover {
    background: var(--surface-2);
    color: var(--text-1);
    border-color: var(--border);
}

/* Danger ghost */
.btn--danger-ghost {
    background: transparent;
    color: var(--danger);
    border-color: transparent;
}
.btn--danger-ghost:hover {
    background: var(--danger-light);
    border-color: var(--danger);
}

/* Danger filled */
.btn--danger {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}
.btn--danger:hover {
    background: var(--danger);
    color: #fff;
}

/* Sizes */
.btn--sm {
    font-size: 0.8rem;
    padding: 6px 13px;
}
.btn--lg {
    font-size: 0.95rem;
    padding: 11px 24px;
}
.btn--full {
    width: 100%;
    justify-content: center;
}

/* Disabled / in-flight */
.btn:disabled,
.btn--loading {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Submit input styled as btn--primary */
input[type="submit"].btn--primary {
    cursor: pointer;
}

/* Keep the stop button on the right of the action bar */
#stop-button {
    margin-left: auto;
}

/* ═══════════════════════════════════════════════════════════
   APP SHELL — DASHBOARD LAYOUT
═══════════════════════════════════════════════════════════ */
.page-dashboard {
    background: var(--bg);
}

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: rgba(12, 13, 15, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar__logo {
    width: 22px;
    height: 22px;
    color: var(--accent);
    flex-shrink: 0;
}

.topbar__app-name {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-1);
}

.topbar__nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* User avatar initial */
.avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--accent);
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   VIEWS (dashboard / entries toggled by JS)
═══════════════════════════════════════════════════════════ */
.app-main {
    flex: 1;
    padding: 48px 28px 80px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.view {
    display: none;
    animation: viewIn var(--t-slow) both;
}
.view--active {
    display: block;
}

@keyframes viewIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Hero ─────────────────────────────────────────────── */
.hero {
    margin-bottom: 40px;
}

.hero__greeting {
    font-size: clamp(1.7rem, 4vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.1;
    color: var(--text-1);
    margin-bottom: 8px;
}

.hero__sub {
    font-size: 0.95rem;
    color: var(--text-2);
    font-weight: 400;
}

/* ── Work status banner ───────────────────── */
.work-status {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 12px 18px;
    margin-bottom: 32px;
    font-size: 0.875rem;
    transition: border-color var(--t);
    animation: viewIn var(--t-slow) both;
}

/* Inactive: static gray dot */
.work-status__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-3);
    flex-shrink: 0;
    transition: background var(--t);
}

.work-status--active {
    position: relative;
    border-color: var(--border);
    border-left-color: var(--accent);
}

.work-status--active::before,
.work-status--active::after {
    content: "";
    position: absolute;
    left: 1px;
    width: 30%;
    height: 0.8px;
    background: linear-gradient(to right, var(--accent), var(--border));
    pointer-events: none;
}

.work-status--active::before {
    top: 0;
    border-top-right-radius: inherit;
}

.work-status--active::after {
    bottom: 0;
    border-bottom-right-radius: inherit;
}

/* Active: dot pulses subtly */
.work-status--active .work-status__dot {
    background: var(--accent);
    animation: pulse 1.6s ease infinite;
}

@keyframes pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(140, 144, 158, 1);
    }
    50% {
        box-shadow: 0 0 25px 5px black;
    }
}

.work-status__label {
    color: var(--text-3);
    transition: color var(--t);
}

.work-status--active .work-status__label {
    color: var(--text-2);
}

.work-status__timer {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-1);
    font-variant-numeric: tabular-nums;
    margin-right: auto;
}

.work-status__timer[hidden] {
    display: none;
}

/* ── Action strip ─────────────────────────────────────── */
.action-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.add-entry-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.add-entry-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 30;
    width: min(360px, calc(100vw - 32px));
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    padding: 16px;
    animation: viewIn 180ms ease both;
}

.add-entry-menu[hidden] {
    display: none;
}

.add-entry-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.add-entry-menu__hint {
    font-size: 0.8rem;
    color: var(--text-3);
    line-height: 1.4;
}

.add-entry-menu__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Session notice ──────────────────────────── */
.session-notice {
    margin-top: 16px;
    font-size: 0.85rem;
    padding: 10px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--danger);
    background: var(--danger-light);
    color: var(--danger);
    animation: viewIn 180ms ease both;
}

.session-notice[data-type="info"] {
    border-color: var(--border-strong);
    background: var(--surface-2);
    color: var(--text-2);
}

.session-notice[hidden] {
    display: none;
}

/* ── View header (entries back-bar) ───────────────────── */
.view-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.view-header__title {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text-1);
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════
   DATA TABLE
═══════════════════════════════════════════════════════════ */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--t);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--surface-1);
}

.data-table td {
    padding: 13px 16px;
    color: var(--text-2);
    white-space: nowrap;
}

.data-table .col-pay {
    color: var(--text-1);
    font-weight: 500;
    text-align: right;
}

.data-table .col-time {
    font-variant-numeric: tabular-nums;
}

/* Totals row */
.data-table tfoot .row-total {
    border-top: 1px solid var(--border-strong);
}

.data-table tfoot td {
    padding: 14px 16px;
    background: var(--surface-1);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-2);
}

.data-table tfoot .col-pay {
    color: var(--accent);
    font-size: 0.95rem;
}

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal[hidden] {
    display: none;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal__card {
    position: relative;
    z-index: 1;
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xl);
    padding: 32px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6);
    animation: modalIn 220ms ease both;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background var(--t),
        color var(--t);
    line-height: 1;
}
.modal__close:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

/* Avatar row inside modal */
.modal__avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.modal__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--accent);
    flex-shrink: 0;
}

.modal__title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-1);
}

.modal__email {
    font-size: 0.82rem;
    color: var(--text-3);
    margin-top: 2px;
}

/* Profile data list */
.profile-dl {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-dl__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    background: var(--surface-2);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}

.profile-dl dt {
    font-size: 0.8rem;
    color: var(--text-3);
    font-weight: 500;
    letter-spacing: 0.03em;
}

.profile-dl dd {
    font-size: 0.875rem;
    color: var(--text-1);
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   AUTH PAGES (login / register)
═══════════════════════════════════════════════════════════ */
.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;

    /* Radial glow */
    background:
        radial-gradient(
            ellipse 60% 50% at 50% -10%,
            rgba(240, 180, 41, 0.12) 0%,
            transparent 70%
        ),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 40px 36px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    animation: viewIn 300ms ease both;
}

.auth-card__brand {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 28px;
}

.auth-card__app-name {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-1);
}

.auth-card__title {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--text-1);
    margin-bottom: 6px;
    line-height: 1.1;
}

.auth-card__sub {
    font-size: 0.875rem;
    color: var(--text-2);
    margin-bottom: 32px;
    line-height: 1.5;
}

/* ── Form fields ──────────────────────────────────────── */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.01em;
}

.form-field__aside-link {
    font-size: 0.78rem;
    color: var(--text-3);
    text-decoration: none;
    transition: color var(--t);
}
.form-field__aside-link:hover {
    color: var(--accent);
}

.form-field__input {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-1);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition:
        border-color var(--t),
        box-shadow var(--t);
    outline: none;
    width: 100%;
}

.form-field__input::placeholder {
    color: var(--text-3);
}

.form-field__input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-field__input:focus-visible {
    border-color: var(--accent);
}

/* Error message */
.form-error {
    font-size: 0.82rem;
    color: var(--danger);
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--r-md);
    padding: 9px 13px;
    margin: 0;
    animation: viewIn 200ms ease both;
}

.form-error[hidden] {
    display: none;
}

/* Auth actions */
.auth-form__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .topbar {
        padding: 0 16px;
    }

    .app-main {
        padding: 32px 16px 60px;
    }

    .action-strip {
        flex-direction: column;
    }
    .action-strip .btn {
        width: 100%;
        justify-content: center;
    }

    .add-entry-shell {
        width: 100%;
    }

    .add-entry-menu {
        position: static;
        width: 100%;
        margin-top: 10px;
    }

    .view-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .auth-card {
        padding: 28px 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal__card {
        padding: 24px 20px;
    }
}

@media (max-width: 360px) {
    .hero__greeting {
        font-size: 1.5rem;
    }
}
