@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   ShulMgmt – Global Stylesheet
   A unified design system for all pages.
   ============================================================ */

/* ── Zone + Mode Design Tokens ───────────────────────────────
   Zones:  admin (blue-slate) | config (violet) | public (teal)
   Themes: light (default)   | dark
   Applied by JS in sidebar.html via data-zone and data-theme
   on <html>. All existing var(--color-*) references work as-is.
   ─────────────────────────────────────────────────────────── */

/* ── Shared invariants (all zones, light mode) ─────────────── */
:root {
    --color-danger:       #b91c1c;
    --color-danger-bg:    #fef2f2;
    --color-success:      #047857;
    --color-success-bg:   #ecfdf5;
    --color-warn-bg:      #fff8e1;
    --color-warn-border:  #ffd54f;

    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   16px;
    --radius-xl:   24px;

    --shadow-card: 0 10px 24px rgba(15, 23, 42, 0.08);
    --shadow-focus: 0 0 0 4px rgba(59, 130, 246, 0.12);

    --font-sans:   Inter, Arial, sans-serif;
    --max-width:   1200px;
    --max-width-narrow: 900px;
    --max-width-form: 700px;

    --color-primary:      var(--color-accent);
    --color-card-bg:      var(--color-surface);

    /* ── Zone: Admin (blue-slate) — default ── */
    --color-accent:           #2563eb;
    --color-accent-dark:      #1d4ed8;
    --color-accent-light:     #dbeafe;

    --color-bg:               #f1f4f8;
    --color-surface:          #ffffff;
    --color-surface-muted:    #f8fafc;
    --color-background-offset:#f1f5f9;

    --color-border:           #e2e8f0;
    --color-border-input:     #cbd5e1;

    --color-text:             #0f172a;
    --color-text-muted:       #475569;
    --color-text-subtle:      #64748b;
    --color-text-head:        #334155;
    --color-input-bg:         #f8fafc;

    /* Sidebar tokens — overridden per zone */
    --sidebar-bg:             #f1f4f8;
    --sidebar-text:           #0f172a;
    --sidebar-border:         #e2e8f0;
    --sidebar-hover-bg:       #e2e8f0;
    --sidebar-active-bg:      #dbeafe;
    --sidebar-logo-bg:        #2563eb;
    --sidebar-logo-color:     #ffffff;
}

/* ── Zone: Config (deep violet) ─────────────────────────────── */
:root[data-zone="config"] {
    --color-accent:           #7c3aed;
    --color-accent-dark:      #6d28d9;
    --color-accent-light:     #ede9fe;
    --shadow-focus:           0 0 0 4px rgba(124, 58, 237, 0.14);

    --color-bg:               #f5f3ff;
    --color-surface:          #ffffff;
    --color-surface-muted:    #faf8ff;
    --color-background-offset:#f0ebff;

    --color-border:           #ddd6fe;
    --color-border-input:     #c4b5fd;

    --color-text-head:        #3b0764;
    --color-text-subtle:      #7e22ce;
    --color-text-muted:       #6d28d9;

    --sidebar-bg:             #1e1b4b;
    --sidebar-text:           #a5b4fc;
    --sidebar-border:         #312e81;
    --sidebar-hover-bg:       #312e81;
    --sidebar-active-bg:      #4338ca;
    --sidebar-logo-bg:        #a78bfa;
    --sidebar-logo-color:     #1e1b4b;
}

/* ── Zone: Public / Member Portal (teal-emerald) ─────────────── */
:root[data-zone="public"] {
    --color-accent:           #0f766e;
    --color-accent-dark:      #0d6460;
    --color-accent-light:     #ccfbf1;
    --shadow-focus:           0 0 0 4px rgba(15, 118, 110, 0.14);

    --color-bg:               #f0fdfa;
    --color-surface:          #ffffff;
    --color-surface-muted:    #f0fdf9;
    --color-background-offset:#e6fdf8;

    --color-border:           #99f6e4;
    --color-border-input:     #5eead4;

    --color-text-head:        #134e4a;
    --color-text-subtle:      #0f766e;
    --color-text-muted:       #0d6460;

    --sidebar-bg:             #0d4f4a;
    --sidebar-text:           #99f6e4;
    --sidebar-border:         #134e4a;
    --sidebar-hover-bg:       #134e4a;
    --sidebar-active-bg:      #0f766e;
    --sidebar-logo-bg:        #2dd4bf;
    --sidebar-logo-color:     #0d4f4a;
}

/* ════════════════════════════════════════════════════════════
   DARK MODE — base (admin zone in dark)
   ══════════════════════════════════════════════════════════ */
:root[data-theme="dark"] {
    --color-accent:           #3b82f6;
    --color-accent-dark:      #2563eb;
    --color-accent-light:     #1e3a8a;

    --color-bg:               #0a0f1e;
    --color-surface:          #1e293b;
    --color-surface-muted:    #162032;
    --color-background-offset:#162032;

    --color-border:           #334155;
    --color-border-input:     #475569;
    --color-input-bg:         #1e293b;

    --color-text:             #f1f5f9;
    --color-text-muted:       #94a3b8;
    --color-text-subtle:      #64748b;
    --color-text-head:        #cbd5e1;

    --sidebar-bg:             #020617;
    --sidebar-text:           #94a3b8;
    --sidebar-border:         #0f172a;
    --sidebar-hover-bg:       #0f172a;
    --sidebar-active-bg:      #1e293b;

    --shadow-card: 0 10px 24px rgba(0, 0, 0, 0.4);
}

/* ── Dark + Config ────────────────────────────────────────── */
:root[data-theme="dark"][data-zone="config"] {
    --color-accent:           #a78bfa;
    --color-accent-dark:      #8b5cf6;
    --color-accent-light:     #2e1065;

    --color-bg:               #0d0a1a;
    --color-surface:          #1e1a3a;
    --color-surface-muted:    #150f2e;
    --color-background-offset:#1a1535;

    --color-border:           #3730a3;
    --color-border-input:     #4c1d95;

    --color-text-head:        #e9d5ff;
    --color-text-subtle:      #a78bfa;
    --color-text-muted:       #c4b5fd;
    --color-input-bg:         #1e1a3a;

    --sidebar-bg:             #080620;
    --sidebar-text:           #a5b4fc;
    --sidebar-border:         #1e1b4b;
    --sidebar-hover-bg:       #1e1b4b;
    --sidebar-active-bg:      #312e81;
}

/* ── Dark + Public ────────────────────────────────────────── */
:root[data-theme="dark"][data-zone="public"] {
    --color-accent:           #2dd4bf;
    --color-accent-dark:      #14b8a6;
    --color-accent-light:     #0d3330;

    --color-bg:               #020f0e;
    --color-surface:          #0d2a28;
    --color-surface-muted:    #0a2220;
    --color-background-offset:#0d2a28;

    --color-border:           #134e4a;
    --color-border-input:     #0f766e;

    --color-text-head:        #ccfbf1;
    --color-text-subtle:      #2dd4bf;
    --color-text-muted:       #5eead4;
    --color-input-bg:         #0d2a28;

    --sidebar-bg:             #020f0e;
    --sidebar-text:           #5eead4;
    --sidebar-border:         #0d4f4a;
    --sidebar-hover-bg:       #0d4f4a;
    --sidebar-active-bg:      #134e4a;
}



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

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    background: var(--color-bg);
    color: var(--color-text);
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
    color: var(--color-text);
    margin-top: 0;
}

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

a:hover {
    text-decoration: underline;
}

/* ── Layout Containers ──────────────────────────────────────── */
.page-shell {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.page-shell--narrow {
    max-width: var(--max-width-narrow);
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.page-shell--form {
    max-width: var(--max-width-form);
    margin: 0 auto;
    padding: 24px 20px 48px;
}

/* ── Breadcrumbs ────────────────────────────────────────────── */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.breadcrumbs a {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    color: var(--color-accent);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--color-accent-light);
    font-weight: 500;
    transition: background 0.15s;
}

.breadcrumbs a:hover {
    background: #bfdbfe;
    text-decoration: none;
}

.breadcrumbs .separator {
    color: var(--color-text-subtle);
    font-weight: 600;
    user-select: none;
}

.breadcrumbs .current {
    color: var(--color-text-head);
    background: var(--color-surface);
    font-weight: 700;
}

/* ── Toolbar (page heading + action buttons row) ────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.toolbar h1 {
    margin: 0;
    flex: 1 1 280px;
    font-size: 2rem;
    color: var(--color-text);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: 2rem;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
}

.card--flat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: none;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text-head);
    margin-bottom: 12px;
}

.card-title--lg {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 14px;
}

/* ── Grid layouts ───────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-cards .card h2 {
    margin: 0 0 6px;
    font-size: 0.9rem;
    color: var(--color-text-subtle);
    font-weight: 500;
}

.summary-cards .card p {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--color-text);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.btn-primary,
.button {
    background: var(--color-accent);
    color: #fff;
    border: 1px solid transparent;
}

.btn-primary:hover,
.button:hover {
    background: var(--color-accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    text-decoration: none;
    color: #fff;
}

.btn-secondary,
.button.secondary {
    background: #6c757d;
    color: #fff;
    border: 1px solid transparent;
}

.btn-secondary:hover,
.button.secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
    text-decoration: none;
    color: #fff;
}

.btn-outline {
    background: var(--color-surface);
    color: var(--color-text-head);
    border: 1px solid var(--color-border-input);
}

.btn-outline:hover {
    background: var(--color-surface-muted);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--color-text-head);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border: 1px solid transparent;
}

.btn-danger:hover {
    background: #991b1b;
    transform: translateY(-1px);
    text-decoration: none;
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--color-text-head);
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border-input);
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--shadow-focus);
    background: var(--color-surface);
}

input[readonly] {
    background: #f1f5f9;
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.form-group {
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}

.form-grid-full {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    align-items: center;
}

.field-note {
    font-size: 0.85rem;
    color: var(--color-text-subtle);
    margin-top: 4px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

thead {
    background: var(--color-border);
}

th,
td {
    padding: 8px 12px;
    text-align: left;
}

th {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-head);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background-color 0.15s ease-in-out, border-left-color 0.15s ease-in-out;
}

.data-table tbody tr:nth-child(odd),
table:not(.logbook-table) tbody tr:nth-child(odd) {
    background: var(--color-surface-muted);
}

.data-table tbody tr:nth-child(even),
table:not(.logbook-table) tbody tr:nth-child(even) {
    background: var(--color-surface);
}

tbody tr:hover {
    background: var(--color-accent-light);
}

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

/* ── Transaction Row Styles & Hover Effects ─────────────────── */
tbody tr.row-pledge {
    background-color: #fef2f2 !important;
}
tbody tr.row-pledge:hover {
    background-color: #fee2e2 !important;
}

tbody tr.row-payment-direct {
    background-color: #ecfdf5 !important;
}
tbody tr.row-payment-direct:hover {
    background-color: #d1fae5 !important;
}

tbody tr.row-payment-by-other {
    background-color: #ecfdf5 !important;
    border-left: 4px solid var(--color-success);
}
tbody tr.row-payment-by-other:hover {
    background-color: #d1fae5 !important;
}

tbody tr.row-payment-for-other {
    background-color: #f8fafc !important;
}
tbody tr.row-payment-for-other:hover {
    background-color: #f1f5f9 !important;
}

/* ── Transaction Badges ─────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-sm {
    padding: 2px 6px;
    font-size: 0.68rem;
    letter-spacing: 0.02em;
}

.badge-pledge {
    background-color: #fca5a5;
    color: #7f1d1d;
}

.badge-payment-direct {
    background-color: #86efac;
    color: #064e3b;
}

.badge-payment-by-other {
    background-color: #99f6e4;
    color: #115e59;
}

.badge-payment-for-other {
    background-color: #cbd5e1;
    color: #1e293b;
}

.no-impact-note {
    font-size: 0.75rem;
    color: var(--color-text-subtle);
    margin-top: 4px;
    font-style: italic;
}

.status-neutral {
    color: var(--color-text-muted);
    font-weight: 500;
}

/* ── Action links in tables ─────────────────────────────────── */
.action-links {
    white-space: nowrap;
    display: flex;
    gap: 12px;
    align-items: center;
}

.action-links a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.action-links a:hover {
    text-decoration: underline;
}

.action-links span {
    color: var(--color-text-subtle);
}

/* ── Filters bar ────────────────────────────────────────────── */
.filters {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    margin-bottom: 20px;
}

.filters input,
.filters select {
    width: 100%;
}

/* ── Status badges ──────────────────────────────────────────── */
.status-positive {
    color: var(--color-success) !important;
    font-weight: 600;
}

.status-negative {
    color: var(--color-danger) !important;
    font-weight: 600;
}

/* ── Alerts / Banners ───────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    font-size: 0.95rem;
}

.alert-error {
    background: var(--color-danger-bg);
    border: 1px solid #fca5a5;
    color: #7f1d1d;
}

.alert-success {
    background: var(--color-success-bg);
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.alert-warn {
    background: var(--color-warn-bg);
    border: 1px solid var(--color-warn-border);
    color: #78350f;
}

.alert-info {
    background: var(--color-accent-light);
    border: 1px solid #93c5fd;
    color: #1e3a8a;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    padding: 16px;
    background: var(--color-warn-bg);
    border: 1px solid var(--color-warn-border);
    border-radius: var(--radius-md);
    color: #78350f;
    font-size: 0.95rem;
}

/* ── Hint / Info box ────────────────────────────────────────── */
.hint-box {
    margin-top: 18px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: var(--color-text-head);
    font-size: 0.93rem;
}

.hint-box strong {
    display: block;
    margin-bottom: 6px;
}

/* ── Muted / small text ─────────────────────────────────────── */
.muted {
    color: var(--color-text-subtle);
    font-size: 0.88rem;
}

.footer-note {
    margin-top: 14px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ── Login page specific ────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 20px;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 36px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
}

.login-card h1 {
    margin: 0 0 4px;
    font-size: 1.7rem;
}

.login-card .subtitle {
    color: var(--color-text-subtle);
    margin-bottom: 28px;
    font-size: 0.95rem;
}

.login-message-error {
    color: var(--color-danger);
    background: var(--color-danger-bg);
    border: 1px solid #fca5a5;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.login-message-success {
    color: var(--color-success);
    background: var(--color-success-bg);
    border: 1px solid #6ee7b7;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* ── Hebrew times page ──────────────────────────────────────── */
.times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.time-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.95rem;
}

.time-item:last-child {
    border-bottom: none;
}

.time-label {
    font-weight: 600;
    color: var(--color-text-head);
    min-width: 140px;
}

.time-value {
    text-align: right;
    color: var(--color-text);
}

/* ── Home page menu ─────────────────────────────────────────── */
.home-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.home-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s, transform 0.2s;
}

.home-card:hover {
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
}

.home-card h2 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.home-card p {
    margin: 0 0 12px;
    color: var(--color-text-muted);
    font-size: 0.93rem;
}

.home-card a {
    color: var(--color-accent);
    font-weight: 600;
    font-size: 0.93rem;
}

.times-list {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.times-list li {
    padding: 5px 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.times-list li strong {
    min-width: 110px;
    display: inline-block;
    color: var(--color-text-head);
}

/* ── Error page ─────────────────────────────────────────────── */
.error-heading {
    color: var(--color-danger);
}

.error-details {
    background: #f8f9fa;
    padding: 20px;
    border-radius: var(--radius-md);
    margin-top: 16px;
    border: 1px solid var(--color-border);
}

.error-details pre {
    white-space: pre-wrap;
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.8rem;
}

/* ── Balance overview – sidebar layout ──────────────────────── */
.balance-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
}

.balance-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.balance-summary .card {
    min-width: 160px;
    flex: 1;
}

.balance-summary .card h2 {
    font-size: 0.85rem;
    color: var(--color-text-subtle);
    margin: 0 0 4px;
    font-weight: 500;
}

.balance-summary .card div {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 960px) {
    .balance-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid-full {
        grid-column: span 1;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .login-card {
        padding: 28px 24px;
    }

    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Sidebar Layout System ──────────────────────────────────── */
.layout-with-sidebar {
    display: flex;
    min-height: 100vh;
}

.layout-content-area {
    flex: 1;
    margin-left: 240px;
    width: calc(100% - 240px);
    max-width: calc(100% - 240px);
    padding: 24px;
    background-color: var(--color-bg);
    min-width: 0;
    transition: background-color 0.3s ease;
}

.sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    width: 240px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.18);
    z-index: 100;
    transition: background-color 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo-icon {
    background-color: var(--sidebar-logo-bg, #eab308);
    color: var(--sidebar-logo-color, #0f172a);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
}

.sidebar-header-text {
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    line-height: 1.2;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    opacity: 0.75;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex-grow: 1;
    margin-right: -8px;
    padding-right: 8px;
}

/* Custom scrollbar for modern, clean aesthetics */
.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-section-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
}

.sidebar-section-group summary.sidebar-section {
    list-style: none;
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    margin-bottom: 6px;
}

.sidebar-section-group summary::-webkit-details-marker {
    display: none;
}

.sidebar-section-group summary::after {
    content: '▾';
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    opacity: 0.6;
    margin-left: 6px;
}

.sidebar-section-group[open] summary::after {
    transform: rotate(-180deg);
}

.sidebar-section {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    opacity: 0.6;
    font-weight: 700;
    width: 100%;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.sidebar-menu-item a:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text);
    opacity: 1;
}

.sidebar-menu-item.active a {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text);
    font-weight: 600;
}

/* ── Dark mode toggle button in sidebar ─────────────────────── */
.sidebar-theme-toggle {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    background: transparent;
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.theme-toggle-btn:hover {
    background: var(--sidebar-hover-bg);
    color: #ffffff;
}

@media (max-width: 1024px) {
    .layout-with-sidebar {
        flex-direction: column;
    }
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        padding: 16px;
    }
    .layout-content-area {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        padding: 20px;
    }
}

/* Print Overrides */
@media print {
    .sidebar {
        display: none !important;
    }
    .layout-content-area {
        margin-left: 0 !important;
        padding: 0 !important;
        background-color: transparent !important;
    }
    .layout-with-sidebar {
        display: block !important;
        min-height: auto !important;
    }
}

/* ── Modal Overlay & Card System ────────────────────────────── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: var(--color-surface, #ffffff);
    color: var(--color-text, #0f172a);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-card, 0 10px 24px rgba(15, 23, 42, 0.15));
    border: 1px solid var(--color-border, #e2e8f0);
    width: 100%;
    max-width: 520px;
    padding: 24px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;          /* never taller than the viewport */
    box-shadow: var(--shadow-card);
    transform: scale(0.97);
    transition: transform 0.25s ease-in-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;          /* clips children to rounded corners */
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-muted);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-head);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-subtle);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.btn-close:hover {
    color: var(--color-text);
}

.modal-card > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;          /* body scrolls when content is tall */
    flex: 1 1 auto;            /* grows to fill available space */
    min-height: 0;             /* allows flex child to shrink below content size */
}

/* Modal and list custom scrollbars */
.modal-body::-webkit-scrollbar,
.permissions-grid::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track,
.permissions-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb,
.permissions-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.permissions-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-muted);
}

.site-footer {
    margin-top: auto;
    padding-top: 24px;
    margin-top: 48px;
    border-top: 1px solid var(--color-border);
    font-size: 0.825rem;
    color: var(--color-text-muted);
    text-align: center;
    line-height: 1.5;
}

/* ── Toast Notifications ──────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.toast {
    background: var(--color-surface, #ffffff);
    color: var(--color-text, #1e293b);
    border: 1px solid var(--color-border, #e2e8f0);
    border-left: 4px solid var(--color-primary, #0f766e);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    padding: 12px 20px;
    border-radius: var(--radius-md, 8px);
    font-size: 0.95rem;
    font-weight: 500;
    min-width: 280px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: toastSlideIn 0.3s ease forwards;
    opacity: 0;
}
.toast.error {
    border-left-color: var(--color-danger, #ef4444);
}
.toast.success {
    border-left-color: var(--color-primary, #0f766e);
}
@keyframes toastSlideIn {
    from {
        transform: translateX(100%) translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
}
@keyframes toastFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}





/* Windows style folder icons */
.sidebar-style-windows summary::after {
    display: none; /* Hide the default right-aligned triangle */
}

.sidebar-style-windows summary::before {
    content: '+';
    font-size: 1rem;
    margin-right: 6px;
    font-family: monospace;
    font-weight: bold;
    opacity: 0.8;
}

.sidebar-style-windows[open] summary::before {
    content: '-';
}
