/* =========================================================
   Management System - Base
   Design tokens (shadcn/ui style, light + dark), reset,
   buttons, form controls, alerts, guest layout, error page
   ========================================================= */

:root {
    --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 0.625rem;

    /* Brand colours (from logo) */
    --brand-saffron: #f97316;
    --brand-sun: #fbbf24;
    --brand-green: #3f9b23;
    --brand-navy: #12305e;
    --brand-red: #dc2626;

    --gradient-brand: linear-gradient(90deg, var(--brand-saffron) 0%, var(--brand-sun) 50%, var(--brand-green) 100%);
    --gradient-primary: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);

    /* Light theme */
    --background: #ffffff;
    --foreground: #0b1324;
    --surface: #f6f8fb;
    --card: #ffffff;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --accent: #f1f5f9;
    --accent-foreground: #0f172a;
    --border: #e2e8f0;
    --input: #cbd5e1;
    --ring: #f97316;
    --overlay: rgba(2, 6, 23, 0.5);

    --error-bg: #fef2f2;
    --error-fg: #b91c1c;
    --error-border: #fecaca;
    --success-bg: #f0fdf4;
    --success-fg: #15803d;
    --success-border: #bbf7d0;
    --warning-bg: #fffbeb;
    --warning-fg: #b45309;
    --warning-border: #fde68a;
    --info-bg: #eff6ff;
    --info-fg: #1d4ed8;
    --info-border: #bfdbfe;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.25);
    --shadow-primary: 0 6px 16px -6px rgba(234, 88, 12, 0.6);

    --sidebar-width: 16rem;
    --navbar-height: 4rem;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #070b14;
        --foreground: #f1f5f9;
        --surface: #070b14;
        --card: #0c1220;
        --muted: #111a2b;
        --muted-foreground: #94a3b8;
        --accent: #162036;
        --accent-foreground: #f8fafc;
        --border: #1e293b;
        --input: #334155;
        --overlay: rgba(0, 0, 0, 0.6);

        --error-bg: rgba(220, 38, 38, 0.12);
        --error-fg: #fca5a5;
        --error-border: rgba(220, 38, 38, 0.35);
        --success-bg: rgba(22, 163, 74, 0.12);
        --success-fg: #86efac;
        --success-border: rgba(22, 163, 74, 0.35);
        --warning-bg: rgba(217, 119, 6, 0.12);
        --warning-fg: #fcd34d;
        --warning-border: rgba(217, 119, 6, 0.35);
        --info-bg: rgba(37, 99, 235, 0.12);
        --info-fg: #93c5fd;
        --info-border: rgba(37, 99, 235, 0.35);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.7);

        color-scheme: dark;
    }
}

/* ---------- Reset ---------- */

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    background-color: var(--surface);
    color: var(--foreground);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
svg {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

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

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

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -100px;
    z-index: 100;
    padding: 0.5rem 1rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--foreground);
    color: var(--background);
    font-size: 0.875rem;
    font-weight: 500;
}

.skip-link:focus {
    top: 1rem;
}

/* ---------- Lucide icons ---------- */

i[data-lucide],
.lucide {
    display: inline-block;
    width: var(--icon-size, 1rem);
    height: var(--icon-size, 1rem);
    flex-shrink: 0;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
        box-shadow 0.15s ease, transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
}

.btn-outline {
    border-color: var(--border);
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.btn-ghost:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.btn-icon {
    width: 2.25rem;
    padding: 0;
}

.btn-block {
    width: 100%;
    height: 2.75rem;
}

/* ---------- Form controls ---------- */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
}

.input-wrap {
    position: relative;
}

.input-icon {
    position: absolute;
    top: 50%;
    left: 0.85rem;
    display: inline-flex;
    color: var(--muted-foreground);
    transform: translateY(-50%);
    pointer-events: none;
}

.form-control {
    width: 100%;
    height: 2.75rem;
    padding: 0 0.85rem 0 2.5rem;
    border: 1px solid var(--input);
    border-radius: calc(var(--radius) - 2px);
    background: var(--background);
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control--action {
    padding-right: 2.75rem;
}

.form-control::placeholder {
    color: var(--muted-foreground);
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-saffron);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.input-action {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 0;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    color: var(--muted-foreground);
    transform: translateY(-50%);
}

.input-action:hover {
    background: var(--accent);
    color: var(--foreground);
}

.password-toggle .icon-hide,
.password-toggle.is-visible .icon-show {
    display: none;
}

.password-toggle .icon-show,
.password-toggle.is-visible .icon-hide {
    display: inline-flex;
}

/* ---------- Alerts ---------- */

.alerts {
    display: grid;
    gap: 0.5rem;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    line-height: 1.45;
}

.alert .lucide,
.alert i[data-lucide] {
    margin-top: 0.1rem;
}

.alert-error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-fg);
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-fg);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-fg);
}

.alert-info {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-fg);
}

/* ---------- Guest layout (login + error pages) ---------- */

.guest-body {
    display: flex;
    flex-direction: column;
}

.guest-body::before {
    content: "";
    display: block;
    height: 4px;
    background: var(--gradient-brand);
}

.guest-main {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

/* ---------- Error page ---------- */

.error-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: 30rem;
    text-align: center;
}

.error-code {
    font-size: clamp(3.5rem, 12vw, 5.5rem);
    font-weight: 800;
    line-height: 1;
    color: var(--brand-saffron);
}

.error-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.error-text {
    margin-bottom: 0.75rem;
    color: var(--muted-foreground);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0s !important;
        transition-delay: 0s !important;
        animation-duration: 0s !important;
    }
}
