/**
 * Admin theme — modern professional UI layer
 * Builds on admin.css design tokens and components.
 */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --accent: #0ea5e9;
    --sidebar-bg: #0b1120;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: #2563eb;
    --sidebar-active-bg: rgba(37, 99, 235, 0.18);
    --sidebar-active-accent: #3b82f6;
    --surface: #eef2f6;
    --surface-subtle: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-sm: 6px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 16px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.08);
    --header-height: 60px;
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.22);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--surface);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ——— Sidebar ——— */
.sidebar {
    background: linear-gradient(180deg, #0b1120 0%, #0f172a 100%);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.sidebar-brand {
    padding: 1.1rem 1rem;
    min-height: var(--header-height);
    border-bottom: 1px solid var(--sidebar-border);
    justify-content: flex-start;
}

.sidebar-brand-inner {
    min-width: 0;
}

.sidebar-brand-text {
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.3;
}

.sidebar-brand-sub {
    margin: 0.2rem 0 0;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.sidebar-brand-short {
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.nav-section-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #475569;
    padding: 0.75rem 0.75rem 0.35rem;
    margin-top: 0.25rem;
}

.nav-subsection-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(148, 163, 184, 0.75);
    padding: 0.75rem 0.75rem 0.2rem;
    margin: 0;
}

.nav-subsection-label--first {
    padding-top: 0.25rem;
}

.nav-link--inset {
    padding-left: 1.5rem;
    font-size: 0.8125rem;
    color: #94a3b8;
}

.nav-link--inset:hover,
.nav-link--inset.active {
    color: #fff;
}

.nav-link,
.nav-group-toggle {
    border-radius: var(--radius-sm);
    transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.nav-link:hover,
.nav-group:hover > .nav-group-toggle,
.nav-group.is-open > .nav-group-toggle {
    background: var(--sidebar-hover);
    color: #f1f5f9;
}

.nav-link.active,
.nav-sublink.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--sidebar-active-accent);
}

.nav-sublink {
    border-radius: var(--radius-sm);
    color: #94a3b8;
    transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.nav-sublink:hover {
    background: var(--sidebar-hover);
    color: #f8fafc;
}

.nav-submenu {
    border-left-color: rgba(255, 255, 255, 0.08);
    margin-left: 0.65rem;
}

.sidebar-collapse-btn {
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sidebar-border);
}

.sidebar-collapse-btn:hover {
    background: var(--sidebar-hover);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ——— Header ——— */
.top-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.25rem;
    box-shadow: var(--shadow-xs);
}

.header-menu-btn {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    background: var(--surface-subtle);
    transition: all 0.18s var(--ease);
}

.header-menu-btn:hover {
    background: var(--primary-light);
    border-color: #bfdbfe;
    color: var(--primary-dark);
}

.breadcrumb {
    font-size: 0.8125rem;
    font-weight: 500;
}

.breadcrumb strong {
    color: var(--text);
    font-weight: 600;
}

.header-user-scope {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.25rem 0.6rem;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.header-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ——— Page layout ——— */
.page-content {
    padding: 1.25rem 1.5rem 1.75rem;
}

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ——— Cards ——— */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    background: var(--card);
}

.card-header {
    padding: 0.9rem 1.25rem;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.card-header-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.card-body {
    padding: 1.15rem 1.25rem;
}

.card-filter-bar {
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
}

.stat-card {
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

/* ——— Buttons ——— */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8125rem;
    transition: all 0.18s var(--ease);
    line-height: 1.25;
}

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

.btn-primary {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.btn-ghost {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

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

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
}

/* ——— Forms ——— */
.select-year,
.select-filter,
.select-month,
.search-input,
.date-input,
.auth-input,
.revenue-filter-select,
.revenue-filter-search-input {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.select-year:focus,
.select-filter:focus,
.search-input:focus,
.date-input:focus,
.auth-input:focus,
.revenue-filter-select:focus,
.revenue-filter-search-input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: var(--focus-ring);
}

.dash-period-field span {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* ——— Tables ——— */
.data-table th {
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border-strong);
}

.data-table td {
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
    transition: background 0.12s var(--ease);
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-pagination {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-subtle);
}

.pagination-nav .page-btn {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.15s var(--ease);
}

.pagination-nav .page-btn:hover:not(.is-disabled) {
    border-color: #93c5fd;
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* ——— Dashboard ——— */
.dash-tabs {
    background: #e2e8f0;
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    gap: 0.15rem;
}

.dash-tab {
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.18s var(--ease);
}

.dash-tab--active,
.dash-tab[aria-selected="true"] {
    background: #fff;
    color: var(--primary-dark);
    box-shadow: var(--shadow-xs);
}

.dash-period-chip {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-xs);
}

.dash-period-chip-live {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.revenue-filter-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.revenue-filter-body {
    background: var(--surface-subtle);
}

.revenue-matrix-card,
.revenue-list-card,
.list-page-card {
    border-radius: var(--radius-lg);
}

.dash-matrix-card,
.dash-kpi-card {
    border-radius: var(--radius-lg);
}

/* ——— Alerts & badges ——— */
.alert {
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.badge {
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ——— Login ——— */
.guest-body {
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37, 99, 235, 0.12), transparent),
        linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
}

.auth-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 2rem 2rem 1.75rem;
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-submit {
    margin-top: 0.25rem;
    padding: 0.65rem 1rem;
}

/* ——— Misc ——— */
.empty-note {
    border-radius: var(--radius);
    background: var(--surface-subtle);
    border: 1px dashed var(--border-strong);
    color: var(--text-muted);
}

.scope-notice {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.45rem 0.75rem;
    background: var(--primary-light);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-top: 0.5rem;
}

.revenue-detail-link {
    color: var(--primary);
    font-weight: 600;
}

.revenue-detail-link:hover {
    color: var(--primary-dark);
}

.revenue-back-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.revenue-back-link:hover {
    text-decoration: underline;
}

/* Sidebar collapsed */
body.sidebar-collapsed .sidebar-brand-inner {
    display: none;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 1rem 0.5rem;
}

/* Nav icons */
.nav-link .icon,
.nav-group-toggle .icon {
    opacity: 0.72;
    transition: opacity 0.18s var(--ease);
}

.nav-link:hover .icon,
.nav-link.active .icon,
.nav-group-toggle:hover .icon {
    opacity: 1;
}

/* Revenue reports */
.revenue-matrix-table thead th {
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-strong);
}

.revenue-matrix-table tfoot th,
.revenue-matrix-table tfoot td {
    background: #f1f5f9;
    font-weight: 600;
    border-top: 2px solid var(--border-strong);
}

.revenue-invoice-table thead th {
    background: var(--surface-subtle);
    color: var(--text-secondary);
    font-weight: 600;
}

.revenue-invoice-table tbody tr:hover td {
    background: #f8fafc;
}

.revenue-filter-toolbar {
    border-bottom: 1px solid var(--border);
}

.revenue-filter-bar {
    gap: 0.65rem;
}

.revenue-money,
.revenue-money-inline {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
}

/* Dashboard matrix */
.dash-matrix-table thead th {
    background: var(--surface-subtle);
}

.dash-kpi-card {
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

/* Scrollbar (WebKit) */
.page-content::-webkit-scrollbar,
.revenue-matrix-wrap::-webkit-scrollbar,
.dash-matrix-body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.page-content::-webkit-scrollbar-thumb,
.revenue-matrix-wrap::-webkit-scrollbar-thumb,
.dash-matrix-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.page-content::-webkit-scrollbar-thumb:hover,
.revenue-matrix-wrap::-webkit-scrollbar-thumb:hover,
.dash-matrix-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

@media (max-width: 900px) {
    .page-content {
        padding: 1rem;
    }

    .header-user-scope {
        display: none;
    }
}
