/* =========================================================
   report-alfi — Master Style
   Single source of truth for all visual styling.
   Bootstrap 5.3.3 base. Custom namespace: --app-*
   ========================================================= */

/* =========================================================
   1. DESIGN TOKENS
   ========================================================= */
:root {
    /* ── Brand ── */
    --app-primary:            #15803d;
    --app-primary-dark:       #166534;
    --app-primary-light:      #22c55e;
    --app-primary-badge-bg:   #dcfce7;

    /* ── Text ── */
    --app-text:               #1e293b;
    --app-text-dark:          #0f172a;
    --app-text-muted:         #64748b;
    --app-text-subtle:        #94a3b8;

    /* ── Surface ── */
    --app-bg:                 #f8fafc;
    --app-surface:            #ffffff;
    --app-surface-muted:      #f1f5f9;

    /* ── Border ── */
    --app-border:             #e2e8f0;

    /* ── Semantic ── */
    --app-success:            #16a34a;
    --app-warning:            #d97706;
    --app-danger:             #dc2626;
    --app-info:               #0284c7;

    /* ── Shadow ── */
    --app-shadow-sm:          0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --app-shadow-md:          0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --app-shadow-auth:        0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    /* ── Radius ── */
    --app-radius-sm:          0.5rem;
    --app-radius-md:          0.75rem;
    --app-radius-lg:          1rem;
    --app-radius-pill:        9999px;

    /* ── Typography ── */
    --app-font-family:        system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --app-font-size-xs:       0.65rem;
    --app-font-size-2xs:      0.72rem;
    --app-font-size-sm:       0.75rem;
    --app-font-size-meta:     0.78rem;
    --app-font-size-helper:   0.80rem;
    --app-font-size-th:       0.82rem;
    --app-font-size-td:       0.90rem;

    /* ── Icon Sizes ── */
    --app-icon-sm:            32px;
    --app-icon-md:            48px;
    --app-icon-brand:         50px;
    --app-icon-login:         90px;
    --app-icon-error:         70px;

    /* ── Stat Card Accent Colors ── */
    --app-stat-green:         #059669;
    --app-stat-blue:          #3b82f6;
    --app-stat-indigo:        #6366f1;
    --app-stat-sky:           #0ea5e9;
    --app-stat-amber:         #f59e0b;
    --app-stat-emerald:       #10b981;

    /* ── Role Badge Colors ── */
    --app-role-dir-bg:        #ede9fe;
    --app-role-dir-text:      #6d28d9;
    --app-role-dir-border:    #ddd6fe;
    --app-role-unit-bg:       #e0f2fe;
    --app-role-unit-text:     #0369a1;
    --app-role-unit-border:   #bae6fd;
    /* ── Navbar ── */
    --app-navbar-height:      57px;

    /* ── Sidebar ── */
    --app-sidebar-bg:         #033830;
    --app-sidebar-text:       #94a3b8;
    --app-sidebar-active-bg:  #036a6c;
    --app-sidebar-active-text:#ffffff;

    /* ── Auth Gradient ── */
    --app-auth-grad-start:    #f0fdf4;
    --app-auth-grad-end:      #eff6ff;
}

/* =========================================================
   2. BASE
   ========================================================= */
body {
    font-family: var(--app-font-family);
    background-color: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body:not(.auth-wrapper) > .container-fluid {
    flex-grow: 1;
}

/* =========================================================
   3. LAYOUT — NAVBAR
   ========================================================= */
.navbar-brand-custom {
    font-weight: 700;
    color: var(--app-text-dark) !important;
}

.brand-badge {
    width: var(--app-icon-brand);
    height: var(--app-icon-brand);
    background-color: var(--app-primary-badge-bg);
    border-radius: var(--app-radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--app-font-size-2xs);
    font-weight: 600;
    color: var(--app-primary);
}

/* =========================================================
   3. LAYOUT — SIDEBAR (INDEPENDENT VIEWPORT SCROLL)
   ========================================================= */
.sidebar {
    background-color: var(--app-sidebar-bg);
    padding: 0;
}

@media (max-width: 767.98px) {
    .sidebar {
        min-height: auto;
    }
}

@media (min-width: 768px) {
    .sidebar {
        position: -webkit-sticky;
        position: sticky;
        top: var(--app-navbar-height, 57px);
        height: calc(100vh - var(--app-navbar-height, 57px));
        min-height: calc(100vh - var(--app-navbar-height, 57px));
        max-height: calc(100vh - var(--app-navbar-height, 57px));
        overflow-y: auto;
        overflow-x: hidden;
        z-index: 100;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    }

    .sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
    }

    .sidebar-inner {
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }

    .sidebar-user-card {
        margin-top: auto !important;
    }
}

.sidebar .nav-link {
    color: var(--app-sidebar-text);
    font-weight: 500;
    padding: 0.65rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: var(--app-radius-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar .nav-link:hover {
    background-color: var(--app-sidebar-active-bg);
    color: var(--app-sidebar-active-text);
}

.sidebar .nav-link.active {
    background-color: var(--app-primary);
    color: var(--app-sidebar-active-text);
    font-weight: 600;
}

.sidebar .nav-link.disabled {
    color: var(--app-text-subtle);
    pointer-events: none;
}

.sidebar .nav-heading {
    color: var(--app-text-subtle);
    font-size: var(--app-font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.75rem 1rem 0.25rem;
}

/* =========================================================
   4. COMPONENTS — CARDS
   ========================================================= */
.card {
    border-radius: var(--app-radius-md) !important;
}

.card-header {
    border-top-left-radius: var(--app-radius-md) !important;
    border-top-right-radius: var(--app-radius-md) !important;
}

/* ── Stat Cards ── */
.stat-card {
    border-left: 4px solid var(--app-primary-light, #22c55e);
    border-radius: var(--app-radius-md);
    box-shadow: var(--app-shadow-sm);
    background-color: var(--app-primary-dark, #166534);
    color: #fff;
    transition: box-shadow 0.15s;
}

.stat-card:hover {
    box-shadow: var(--app-shadow-md);
}

/* Stat card typography & contrast */
.stat-card h3,
.stat-card h4 {
    color: #fff !important;
}

.stat-card .text-muted,
.stat-card .text-meta {
    color: rgba(255, 255, 255, 0.75) !important;
}

.stat-card .text-white-50 {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Stat card color modifiers */
.stat-card--green {
    background-color: #0b8138;
    border-left-color: #22c55e !important;
}

.stat-card--blue {
    background-color: #2958db;
    border-left-color: #3b82f6 !important;
}

.stat-card--orange,
.stat-card--amber {
    background-color: #e85900;
    border-left-color: #f59e0b !important;
}

.stat-card--purple,
.stat-card--indigo {
    background-color: #8036b8;
    border-left-color: #a855f7 !important;
}

.stat-card--sky {
    background-color: #007ec2;
    border-left-color: #0ea5e9 !important;
}

.stat-card--emerald {
    background-color: #065f46;
    border-left-color: #10b981 !important;
}

/* Stat card icon wrapper */
.stat-icon-wrapper {
    width: var(--app-icon-md);
    height: var(--app-icon-md);
    border-radius: var(--app-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* ── Progress Bar ── */
.progress-sm {
    height: 6px;
}

/* ── Hero / Welcome Banner ── */
.app-hero {
    background: linear-gradient(135deg, var(--app-primary) 0%, var(--app-primary-dark) 100%);
    color: #ffffff;
}

.app-hero-watermark {
    font-size: 7rem;
}

/* =========================================================
   4. COMPONENTS — BUTTONS
   ========================================================= */
.btn-primary {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
    color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
    color: #ffffff;
}

/* =========================================================
   4. COMPONENTS — TABLES
   ========================================================= */
.table th {
    font-weight: 600;
    font-size: var(--app-font-size-th);
    color: var(--app-text-muted);
    background-color: var(--app-surface-muted);
}

.table td {
    font-size: var(--app-font-size-td);
    color: var(--app-text);
}

/* Semantic column width helpers */
.col-no     { width: 60px;  }
.col-code   { width: 130px; }
.col-status { width: 130px; }
.col-action { width: 200px; }
.col-action-sm { width: 120px; }
.col-number { width: 100px; }

/* =========================================================
   4. COMPONENTS — BADGES (Role)
   ========================================================= */
.badge-role-direktorat {
    background-color: var(--app-role-dir-bg);
    color: var(--app-role-dir-text);
    border: 1px solid var(--app-role-dir-border);
}

.badge-role-unit {
    background-color: var(--app-role-unit-bg);
    color: var(--app-role-unit-text);
    border: 1px solid var(--app-role-unit-border);
}

/* =========================================================
   5. REPORTING UI
   ========================================================= */
/* Reporting UI visual distinction is achieved via Bootstrap semantic colors.
   See: bg-info-subtle (Input Unit), bg-primary-subtle (Target),
        bg-success-subtle (Calculated), bg-secondary-subtle (Read Only). */

/* =========================================================
   6. UTILITIES — TYPOGRAPHY
   ========================================================= */

/* Micro label — for xs badge labels, sidebar items */
.text-micro {
    font-size: var(--app-font-size-xs);
}

/* Sub-label — brand subtitle, sidebar user info, mono badges */
.text-2xs {
    font-size: var(--app-font-size-2xs);
}

/* Caption — metric labels, table captions, small info text */
.text-sm-app {
    font-size: var(--app-font-size-sm);
}

/* Meta — footnotes, stat card subtitles, auth footer */
.text-meta {
    font-size: var(--app-font-size-meta);
}

/* Helper — alert info text, inline hints */
.text-helper {
    font-size: var(--app-font-size-helper);
}

/* =========================================================
   7. PAGE-SPECIFIC — AUTH
   ========================================================= */
.auth-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--app-auth-grad-start) 0%, #f8fafc 50%, var(--app-auth-grad-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    max-width: 420px;
    width: 100%;
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-auth);
}

.brand-icon-auth {
    width: var(--app-icon-login);
    height: var(--app-icon-login);
}

.sidebar-avatar {
    width: var(--app-icon-sm);
    height: var(--app-icon-sm);
    font-size: 0.85rem;
    font-weight: 700;
}

.error-card {
    max-width: 500px;
    border-radius: var(--app-radius-lg) !important;
}

.error-icon-wrapper {
    width: var(--app-icon-error);
    height: var(--app-icon-error);
}

/* =========================================================
   8. ACCESSIBILITY
   ========================================================= */

/* Focus indicator — ensure visible keyboard focus */
:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

/* Skip to main content (if added in future) */
.visually-hidden-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* =========================================================
   9. RESPONSIVE
   ========================================================= */

/* Stat card grid — consistent 2-up on mobile, 4-up on desktop */
@media (max-width: 767.98px) {
    .sidebar {
        min-height: auto;
    }
}
