/* ==========================================================================
   PA-KASKAS - Base styles and design tokens
   Shared by the login page and the dashboard.
   ========================================================================== */

:root {
    color-scheme: light;

    /* Brand */
    --primary: #1f5af2;
    --primary-hover: #1848c9;
    --primary-soft: #e7eeff;
    --secondary: #0f766e;
    --secondary-soft: #e3f4f2;

    /* Surfaces */
    --background: #eef2f9;
    --surface: #ffffff;
    --surface-muted: #f5f7fc;
    --neutral-soft: #edf0f6;          /* chips, neutral badges, tracks */
    --row-hover: #f7f9fe;
    --row-highlight: #fff8e6;
    --overlay: rgba(10, 15, 30, 0.45);

    /* Sidebar (a floating card, like the other cards) */
    --sidebar-bg: #ffffff;
    --sidebar-hover: #f1f4fb;
    --sidebar-text: #4a556d;
    --sidebar-text-strong: #111a2e;
    --sidebar-muted: #8a94a8;
    --sidebar-line: #edf0f6;
    --sidebar-input-bg: #f3f5fa;
    --sidebar-input-border: #e3e7f0;
    --sidebar-active-bar: #1f5af2;

    /* Header and footer */
    --header-bg: rgba(238, 242, 249, 0.86);
    --footer-bg: transparent;

    /* Text */
    --text: #121a2e;
    --text-muted: #5b667d;
    --text-inverse: #ffffff;

    /* Borders */
    --border: #e3e7f0;
    --border-strong: #c9d0de;

    /* Feedback (base, soft background, border, text on the soft background) */
    --success: #15803d;
    --success-soft: #e7f6ec;
    --success-border: #b7e2c4;
    --success-text: #14532d;
    --warning: #b45309;
    --warning-soft: #fdf3e2;
    --warning-border: #f2d6a6;
    --warning-text: #78350f;
    --danger: #c62828;
    --danger-hover: #a51f1f;
    --danger-soft: #fdecec;
    --danger-border: #f3c0c0;
    --danger-text: #7f1d1d;
    --info: #0369a1;
    --info-soft: #e5f3fb;
    --info-border: #b9dcf0;
    --info-text: #0c4a6e;

    /* Shape and depth */
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 2px 10px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.16);
    --focus-ring: 0 0 0 3px rgba(31, 90, 242, 0.35);

    /* Design-system names (aliases of the tokens above) */
    --bg-primary: var(--background);
    --bg-secondary: var(--surface-muted);
    --text-primary: var(--text);
    --text-secondary: var(--text-muted);
    --border-color: var(--border);
    --button-primary: var(--primary);
    --button-hover: var(--primary-hover);
    --card-bg: var(--surface);

    /* Typography: system fonts, nothing to download */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --transition: 160ms ease;
}

/* Dark mode: <html data-theme="dark"> (set before paint from the saved choice; assets/js/theme). */
html[data-theme="dark"] {
    color-scheme: dark;

    --primary: #3d74ff;
    --primary-hover: #5a88ff;
    --primary-soft: #18264a;
    --secondary: #2bb3a4;
    --secondary-soft: #0f2e2b;

    --background: #070b16;
    --surface: #111829;
    --surface-muted: #161f33;
    --neutral-soft: #1e283e;
    --row-hover: #172137;
    --row-highlight: #2a2412;
    --overlay: rgba(0, 0, 0, 0.6);

    --sidebar-bg: #0c1222;
    --sidebar-hover: #172137;
    --sidebar-text: #a6b0c6;
    --sidebar-text-strong: #f2f5fb;
    --sidebar-muted: #6d7891;
    --sidebar-line: #1b2438;
    --sidebar-input-bg: #141c2f;
    --sidebar-input-border: #222c43;
    --sidebar-active-bar: #8fb0ff;

    --header-bg: rgba(7, 11, 22, 0.86);

    --text: #e8ecf5;
    --text-muted: #9aa5bd;
    --text-inverse: #ffffff;

    --border: #222c43;
    --border-strong: #33405e;

    --success: #3fca7d;
    --success-soft: #10291c;
    --success-border: #1f5136;
    --success-text: #9ce8bd;
    --warning: #f0a43a;
    --warning-soft: #2e2210;
    --warning-border: #5c4318;
    --warning-text: #f6cf93;
    --danger: #f26d6d;
    --danger-hover: #ff8a8a;
    --danger-soft: #331517;
    --danger-border: #5e2629;
    --danger-text: #f7b4b4;
    --info: #52b6f2;
    --info-soft: #0d2537;
    --info-border: #1c4763;
    --info-text: #a9dbf8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
    --focus-ring: 0 0 0 3px rgba(61, 116, 255, 0.45);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p {
    margin: 0;
}

h1, h2, h3, h4 {
    line-height: 1.25;
    font-weight: 650;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img,
svg {
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1em 0.35em;
    word-break: break-all;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

[hidden] {
    display: none !important;
}

/* ---------- Icons ---------- */
.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.icon--sm {
    width: 14px;
    height: 14px;
}

.icon--xl {
    width: 32px;
    height: 32px;
}

/* ---------- Utilities ---------- */
.text-muted {
    color: var(--text-muted);
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -48px;
    z-index: 1000;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--text-inverse);
    transition: top var(--transition);
}

.skip-link:focus {
    top: 12px;
}

.pre-line {
    white-space: pre-line;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.btn:hover {
    text-decoration: none;
}

.btn--primary {
    background: var(--primary);
    color: var(--text-inverse);
}

.btn--primary:hover {
    background: var(--primary-hover);
}

.btn--danger {
    background: var(--danger);
    color: var(--text-inverse);
}

.btn--danger:hover {
    background: var(--danger-hover);
}

/* Outline button for a destructive action next to other outline buttons. */
.btn--outline.btn--danger-outline {
    color: var(--danger);
    border-color: var(--danger);
}

.btn--outline.btn--danger-outline:hover {
    background: var(--danger-soft);
}

.btn--warning {
    background: var(--warning);
    color: var(--text-inverse);
}

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

.btn--outline {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn--outline:hover {
    background: var(--surface-muted);
    border-color: var(--text-muted);
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn--ghost:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.btn--sm {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 13px;
}

.btn--block {
    width: 100%;
}

/* No "busy" cursor (the spinning wheel on a Mac): a disabled button just cannot be clicked,
   and a saving button shows its own small spinner. */
.btn[disabled],
.btn.is-loading {
    opacity: 0.75;
    cursor: not-allowed;
}

.btn.is-loading {
    cursor: default;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Forms ---------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label,
.label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.required {
    color: var(--danger);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
    resize: vertical;
    min-height: 96px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--danger);
}

.field-help {
    font-size: 13px;
    color: var(--text-muted);
}

.field-error {
    font-size: 13px;
    font-weight: 500;
    color: var(--danger);
}

.char-count {
    float: right;
}

/* Input with a leading icon (and optional trailing button) */
.input-icon {
    position: relative;
}

.input-icon > .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-icon input {
    padding-left: 40px;
}

.input-icon--action input {
    padding-right: 46px;
}

.input-action {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.input-action:hover {
    color: var(--text);
    background: var(--surface-muted);
}

.input-action .when-shown,
.input-action[aria-pressed="true"] .when-hidden {
    display: none;
}

.input-action[aria-pressed="true"] .when-shown {
    display: inline;
}

/* Toggle switch */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch__track {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background-color var(--transition);
}

.switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition);
}

.switch input:checked + .switch__track {
    background: var(--success);
}

.switch input:checked + .switch__track::after {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch__track {
    box-shadow: var(--focus-ring);
}

/* ---------- Alerts / notifications ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.alert .icon {
    margin-top: 2px;
}

.alert p + p {
    margin-top: 4px;
}

.alert--success {
    background: var(--success-soft);
    border-color: var(--success-border);
    color: var(--success-text);
}

.alert--error {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.alert--warning {
    background: var(--warning-soft);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.alert--info {
    background: var(--info-soft);
    border-color: var(--info-border);
    color: var(--info-text);
}

/* ---------- Status labels (text + icon, not colour alone) ---------- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.status--success {
    background: var(--success-soft);
    color: var(--success);
}

.status--warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.status--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.status--muted {
    background: var(--neutral-soft);
    color: var(--text-muted);
}

.chip {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.chip--muted {
    background: var(--neutral-soft);
    color: var(--text-muted);
}

/* ---------- Brand mark ---------- */
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text-inverse);
}

.brand-mark--lg {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
}

.brand-mark--lg .icon {
    width: 28px;
    height: 28px;
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
}

.status-icon--danger {
    background: var(--danger-soft);
    color: var(--danger);
}
