/*
 * Shared design system for both UI surfaces of this app:
 *  - the Django admin (/admin/) — loaded via tracker/templates/admin/base_site.html,
 *    which also re-points the *structural* tokens below at Django's own dark-mode-aware
 *    CSS custom properties (see the token-bridge block in that template).
 *  - the plain CRUD pages (/projects/, /tasks/, etc.) — loaded standalone via
 *    tracker/templates/tracker/base.html, where the tokens below apply directly.
 *
 * Everything past the token block only ever references --ds-* custom properties, so
 * components never need to know which surface they're rendered on.
 */

:root {
    /* structural — light-mode defaults (overridden for admin pages, see base_site.html) */
    --ds-bg: #fff;
    --ds-surface: #f8f8f8;
    --ds-text: #333;
    --ds-text-quiet: #6b7280;
    --ds-border: #ccc;
    --ds-hairline: #e5e7eb;
    --ds-primary: #417690;
    --ds-primary-fg: #fff;
    --ds-accent: #264b5d;

    /* semantic status colors — centralizes what used to be duplicated across
       PROJECT_STATUS_COLORS / TESTCASE_PRIORITY_COLORS / TESTCASE_STATUS_COLORS /
       REVIEW_STATUS_COLORS in tracker/admin.py. Constant across both surfaces. */
    --ds-success: #16a34a;
    --ds-success-fg: #fff;
    --ds-warning: #f59e0b;
    --ds-warning-fg: #1a1a1a;
    --ds-danger: #dc2626;
    --ds-danger-fg: #fff;
    --ds-info: #3b82f6;
    --ds-info-fg: #fff;
    --ds-neutral: #6b7280;
    --ds-neutral-fg: #fff;

    /* spacing / radius / shadow / type */
    --ds-space-1: 4px;
    --ds-space-2: 8px;
    --ds-space-3: 12px;
    --ds-space-4: 16px;
    --ds-space-5: 24px;
    --ds-space-6: 32px;
    --ds-radius-sm: 4px;
    --ds-radius-md: 8px;
    --ds-radius-pill: 999px;
    --ds-shadow-sm: 0 1px 2px rgba(0, 0, 0, .08);
    --ds-shadow-md: 0 4px 12px rgba(0, 0, 0, .12);
    --ds-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ds-bg: #121212;
        --ds-surface: #1e1e1e;
        --ds-text: #eee;
        --ds-text-quiet: #9ca3af;
        --ds-border: #444;
        --ds-hairline: #333;
        --ds-primary: #79aec8;
        --ds-primary-fg: #111;
        --ds-accent: #a3c7d8;
    }
}

html[data-theme="dark"] {
    --ds-bg: #121212;
    --ds-surface: #1e1e1e;
    --ds-text: #eee;
    --ds-text-quiet: #9ca3af;
    --ds-border: #444;
    --ds-hairline: #333;
    --ds-primary: #79aec8;
    --ds-primary-fg: #111;
    --ds-accent: #a3c7d8;
}

html[data-theme="light"] {
    --ds-bg: #fff;
    --ds-surface: #f8f8f8;
    --ds-text: #333;
    --ds-text-quiet: #6b7280;
    --ds-border: #ccc;
    --ds-hairline: #e5e7eb;
    --ds-primary: #417690;
    --ds-primary-fg: #fff;
    --ds-accent: #264b5d;
}

/* ── Utilities ─────────────────────────────────────────────────────────── */

.ds-text-quiet {
    color: var(--ds-text-quiet);
}

.ds-text-danger {
    color: var(--ds-danger);
}

/* ── Badge ─────────────────────────────────────────────────────────────── */

.ds-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--ds-radius-md);
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.ds-badge--solid.ds-badge--success { background: var(--ds-success); color: var(--ds-success-fg); }
.ds-badge--solid.ds-badge--warning { background: var(--ds-warning); color: var(--ds-warning-fg); }
.ds-badge--solid.ds-badge--danger  { background: var(--ds-danger);  color: var(--ds-danger-fg); }
.ds-badge--solid.ds-badge--info    { background: var(--ds-info);    color: var(--ds-info-fg); }
.ds-badge--solid.ds-badge--neutral { background: var(--ds-neutral); color: var(--ds-neutral-fg); }

.ds-badge--outline {
    background: transparent;
    border: 2px solid currentColor;
    padding: 0 8px;
}
.ds-badge--outline.ds-badge--success { color: var(--ds-success); }
.ds-badge--outline.ds-badge--warning { color: var(--ds-warning); }
.ds-badge--outline.ds-badge--danger  { color: var(--ds-danger); }
.ds-badge--outline.ds-badge--info    { color: var(--ds-info); }
.ds-badge--outline.ds-badge--neutral { color: var(--ds-neutral); }

/* Small variant used for the overdue-task flag — same family, tighter footprint. */
.ds-flag {
    border-radius: var(--ds-radius-pill);
    padding: 1px 6px;
    font-size: 0.9em;
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */

.ds-tabs {
    display: flex;
    border-bottom: 2px solid var(--ds-hairline);
    margin-bottom: 24px;
    gap: 2px;
}

.ds-tabs__link {
    display: inline-block;
    padding: 10px 22px;
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 600;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -2px;
    border-radius: var(--ds-radius-md) var(--ds-radius-md) 0 0;
    color: var(--ds-primary);
    background: transparent;
}

.ds-tabs__link.is-active {
    border-color: var(--ds-hairline);
    color: var(--ds-text);
    background: var(--ds-bg);
}

/* Button-driven tab variant (JS click handler toggles .active, not a URL) */
.ds-tabs--buttons {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--ds-hairline);
    margin-bottom: 20px;
}

.ds-tabs__btn {
    padding: 10px 20px;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--ds-primary);
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--ds-radius-md) var(--ds-radius-md) 0 0;
    margin-bottom: -2px;
}

.ds-tabs__btn.active {
    border-color: var(--ds-hairline);
    color: var(--ds-text);
    background: var(--ds-bg);
}

.ds-tabs__panel {
    display: none;
}

.ds-tabs__panel.is-active,
.ds-tabs__panel.active {
    display: block;
}

/* ── Segmented toggle (Day/Month style pill switch) ───────────────────── */

.ds-inline-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 14px;
    vertical-align: middle;
}

.ds-toggle-label {
    font-weight: 600;
    font-size: 0.8em;
    color: var(--ds-text-quiet);
}

.ds-toggle {
    display: inline-flex;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-pill);
    padding: 3px;
}

.ds-toggle__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.ds-toggle__option {
    display: inline-block;
    padding: 5px 16px;
    border-radius: var(--ds-radius-pill);
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    color: var(--ds-text-quiet);
    transition: background 0.15s ease, color 0.15s ease;
}

.ds-toggle__input:checked + .ds-toggle__option {
    background: var(--ds-primary);
    color: var(--ds-primary-fg);
}

.ds-toggle__input:focus-visible + .ds-toggle__option {
    outline: 2px solid var(--ds-primary);
    outline-offset: 2px;
}

/* ── Table ─────────────────────────────────────────────────────────────── */

.ds-table {
    width: 100%;
    border-collapse: collapse;
}

.ds-table th,
.ds-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--ds-hairline);
}

.ds-table th {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--ds-text-quiet);
}

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

.ds-table-wrapper {
    overflow-x: auto;
}

/* ── Pagination ────────────────────────────────────────────────────────── */

.ds-pagination {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--ds-space-4);
}

.ds-pagination a,
.ds-pagination .this-page {
    display: inline-block;
    padding: 6px 12px;
    margin-left: 4px;
    border-radius: var(--ds-radius-sm);
    text-decoration: none;
    color: var(--ds-primary);
}

.ds-pagination a:hover {
    background: var(--ds-surface);
}

.ds-pagination .this-page {
    background: var(--ds-primary);
    color: var(--ds-primary-fg);
    font-weight: 600;
}

.ds-pagination__disabled {
    padding: 6px 12px;
    color: var(--ds-text-quiet);
}

/* ── Card / panel ──────────────────────────────────────────────────────── */

.ds-card {
    background: var(--ds-bg);
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius-md);
    box-shadow: var(--ds-shadow-sm);
    padding: var(--ds-space-4) var(--ds-space-5);
}

.ds-list {
    list-style: none;
    margin: 0 0 var(--ds-space-3);
    padding: 0;
}

.ds-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--ds-hairline);
}

.ds-empty-state {
    padding: 20px;
    text-align: center;
    color: var(--ds-text-quiet);
    font-style: italic;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.ds-btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--ds-radius-sm);
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.4;
}

.ds-btn--sm {
    padding: 4px 10px;
    font-size: 0.8em;
}

.ds-btn--primary {
    background: var(--ds-primary);
    color: var(--ds-primary-fg);
}

.ds-btn--primary:hover {
    filter: brightness(0.92);
}

.ds-btn--secondary {
    background: var(--ds-surface);
    color: var(--ds-text);
    border-color: var(--ds-border);
}

.ds-btn--secondary:hover {
    background: var(--ds-hairline);
}

.ds-btn--danger {
    background: var(--ds-danger);
    color: var(--ds-danger-fg);
}

.ds-btn--danger:hover {
    filter: brightness(0.92);
}

.ds-inline-form {
    display: inline;
}

/* ── Plain-site chrome: topbar / nav / container ──────────────────────── */

.ds-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-4);
    padding: var(--ds-space-3) var(--ds-space-5);
    background: var(--ds-surface);
    border-bottom: 1px solid var(--ds-hairline);
    font-family: var(--ds-font);
}

.ds-topbar__brand {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--ds-text);
    text-decoration: none;
}

.ds-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-1) var(--ds-space-4);
}

.ds-nav a {
    color: var(--ds-text-quiet);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 600;
}

.ds-nav a:hover {
    color: var(--ds-primary);
}

.ds-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: var(--ds-space-5) var(--ds-space-4) var(--ds-space-6);
    font-family: var(--ds-font);
    color: var(--ds-text);
    background: var(--ds-bg);
}

body {
    background: var(--ds-bg);
    margin: 0;
}

/* ── Plain-site form baseline (admin's own inputs are already styled) ──── */

.ds-form p {
    margin: 0 0 var(--ds-space-3);
}

.ds-form label {
    display: block;
    margin-bottom: var(--ds-space-1);
    font-weight: 600;
    font-size: 0.9em;
    color: var(--ds-text);
}

.ds-form input[type="text"],
.ds-form input[type="date"],
.ds-form input[type="time"],
.ds-form input[type="month"],
.ds-form input[type="number"],
.ds-form input[type="email"],
.ds-form input[type="password"],
.ds-form select,
.ds-form textarea {
    width: 100%;
    max-width: 480px;
    padding: 8px 10px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-bg);
    color: var(--ds-text);
    font-family: inherit;
    font-size: 0.95em;
    box-sizing: border-box;
}

.ds-form input:focus,
.ds-form select:focus,
.ds-form textarea:focus {
    outline: 2px solid var(--ds-primary);
    outline-offset: 1px;
}
