/* Modern light admin design system for AlarmApps.Admin.Web.
   Replaces scattered inline styles with reusable, responsive component classes.
   Shepherd-facing Blazor pages use the separate BibleWake theme (bw-shepherd.css). */

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-contrast: #ffffff;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warn: #d97706;
    --warn-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --info: #0284c7;
    --info-bg: #e0f2fe;

    --sidebar-bg: #0f172a;
    --sidebar-fg: #cbd5e1;
    --sidebar-fg-muted: #64748b;
    --sidebar-active-bg: #1e293b;
    --sidebar-active-fg: #ffffff;

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.1);

    --sidebar-w: 248px;
    --topbar-h: 60px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
}

h1, h2, h3, h4 {
    color: var(--text);
    line-height: 1.25;
}

/* ---------- Shell / layout ---------- */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-nav-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.admin-sidebar {
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar__brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 1.5rem;
    padding: 0 0.5rem;
}

.admin-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.admin-nav__item {
    margin-bottom: 0.15rem;
}

.admin-nav__link {
    display: block;
    padding: 0.55rem 0.65rem;
    border-radius: var(--r-sm);
    color: var(--sidebar-fg);
    text-decoration: none;
    font-size: 0.92rem;
    transition: background 0.15s, color 0.15s;
}

.admin-nav__link:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-fg);
}

.admin-nav__link.active {
    background: var(--primary);
    color: #fff;
}

.admin-nav__section {
    margin: 1rem 0 0.35rem;
    padding: 0 0.65rem;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-fg-muted);
    border-top: 1px solid #1e293b;
    padding-top: 0.85rem;
}

.admin-sidebar__footer {
    border-top: 1px solid #1e293b;
    padding-top: 0.85rem;
    margin-top: 0.85rem;
    font-size: 0.85rem;
}

.admin-sidebar__user {
    color: var(--sidebar-fg);
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.admin-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.admin-topbar__brand {
    font-weight: 700;
    display: none;
}

.admin-topbar__spacer {
    flex: 1;
}

.admin-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    user-select: none;
}

.admin-scrim {
    display: none;
}

.admin-main {
    padding: 1.75rem;
    flex: 1;
}

@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 50;
        box-shadow: var(--shadow-md);
    }

    .admin-nav-toggle:checked ~ .admin-sidebar {
        transform: translateX(0);
    }

    .admin-nav-toggle:checked ~ .admin-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 40;
    }

    .admin-hamburger {
        display: inline-flex;
    }

    .admin-topbar__brand {
        display: block;
    }

    .admin-main {
        padding: 1.1rem;
    }
}

/* ---------- Page header ---------- */
.page-header {
    margin-bottom: 1.5rem;
}

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

.page-header__sub {
    color: var(--text-muted);
    margin: 0;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.card + .card,
.card-stack > * + * {
    margin-top: 1.25rem;
}

/* ---------- Stat grid ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stat-card__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card__label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stat-card--success .stat-card__value { color: var(--success); }
.stat-card--muted .stat-card__value { color: var(--text-subtle); }

/* ---------- Tables ---------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 520px;
}

.table th,
.table td {
    padding: 0.7rem 1rem;
    text-align: left;
    vertical-align: top;
}

.table thead th {
    background: var(--surface-3);
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.table tbody tr + tr td {
    border-top: 1px solid var(--border);
}

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

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.field--full {
    grid-column: 1 / -1;
}

.label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.textarea {
    resize: vertical;
    min-height: 84px;
}

.field__hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: filter 0.15s, background 0.15s;
}

.btn:hover { filter: brightness(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: var(--primary-contrast); }
.btn--success { background: var(--success); color: #fff; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--secondary { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

.btn--link {
    background: none;
    border: none;
    padding: 0.25rem 0.35rem;
    color: var(--primary);
    font-weight: 600;
}
.btn--link:hover { text-decoration: underline; filter: none; }
.btn--link.btn--success { color: var(--success); }
.btn--link.btn--warn { color: var(--warn); }
.btn--link.btn--danger { color: var(--danger); }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--draft { background: var(--surface-3); color: var(--text-muted); }
.badge--published { background: var(--success-bg); color: var(--success); }
.badge--archived { background: var(--warn-bg); color: var(--warn); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--neutral { background: var(--surface-3); color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--r-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert--error { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert--success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert--warn { background: var(--warn-bg); color: #92400e; border-color: #fde68a; }
.alert--info { background: var(--info-bg); color: #075985; border-color: #bae6fd; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.tab {
    padding: 0.55rem 0.95rem;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Filter bar ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}

.filter-bar .field {
    margin-bottom: 0;
    min-width: 150px;
}

/* ---------- Language switcher ---------- */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem;
    background: var(--surface-2);
}

.lang-switch__item {
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.lang-switch__item.active {
    background: var(--primary);
    color: #fff;
}

/* Language switcher variant for the dark sidebar */
.admin-sidebar .lang-switch {
    background: transparent;
    border-color: #1e293b;
    margin-bottom: 0.75rem;
}

.admin-sidebar .lang-switch__item {
    color: var(--sidebar-fg);
}

.admin-sidebar .lang-switch__item.active {
    background: var(--primary);
    color: #fff;
}

/* ---------- Standalone auth pages (Razor Pages) ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    gap: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    padding: 2.25rem;
}

.auth-card h1 {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.auth-actions {
    margin-top: 0.5rem;
}

.auth-actions .btn {
    width: 100%;
}

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.75rem; }
.mb-2 { margin-bottom: 1.25rem; }
.nowrap { white-space: nowrap; }
