/**
 * SIPADU PTSP - Custom Stylesheet
 * Tema Resmi: Hijau Tua PTSP Kementerian Agama / Madrasah
 * Menggunakan Bootstrap 5 Utilities & Custom Tokens
 */

:root {
    /* Palette Warna Hijau Tua PTSP */
    --ptsp-primary: #14532d;       /* Emerald / Forest Green 900 */
    --ptsp-primary-dark: #0b341c;  /* Deep Forest Green */
    --ptsp-primary-light: #166534; /* Forest Green 800 */
    --ptsp-primary-hover: #166534; /* Forest Green 800 Hover */
    --ptsp-accent: #15803d;        /* Green 700 */
    --ptsp-accent-hover: #16a34a;  /* Green 600 */
    --ptsp-accent-subtle: #dcfce7; /* Green 100 */
    --ptsp-accent-text: #166534;
    
    /* Background & Surface */
    --ptsp-bg: #f8fafc;            /* Slate 50 */
    --ptsp-surface: #ffffff;
    --ptsp-border: #e2e8f0;        /* Slate 200 */
    --ptsp-border-strong: #cbd5e1; /* Slate 300 */
    
    /* Teks */
    --ptsp-text-main: #0f172a;     /* Slate 900 */
    --ptsp-text-muted: #64748b;    /* Slate 500 */
    --ptsp-text-light: #94a3b8;    /* Slate 400 */
    
    /* Dimensi Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 64px;
    --footer-height: 52px;
    
    /* Status Pelayanan SIPADU (6 Status Resmi) */
    --status-diterima-bg: #e0f2fe;
    --status-diterima-color: #0369a1;
    --status-menunggu-bg: #fef3c7;
    --status-menunggu-color: #b45309;
    --status-diproses-bg: #dbeafe;
    --status-diproses-color: #1d4ed8;
    --status-selesai-bg: #dcfce7;
    --status-selesai-color: #15803d;
    --status-ditolak-bg: #fee2e2;
    --status-ditolak-color: #b91c1c;
    --status-dibatalkan-bg: #f1f5f9;
    --status-dibatalkan-color: #475569;
}

/* Typography & Global */
body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--ptsp-bg);
    color: var(--ptsp-text-main);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* Link Reset */
a {
    color: var(--ptsp-accent);
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}
a:hover {
    color: var(--ptsp-primary);
}

/* App Wrapper */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Desktop */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--ptsp-surface);
    border-right: 1px solid var(--ptsp-border);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--ptsp-border);
    background: linear-gradient(135deg, var(--ptsp-primary) 0%, var(--ptsp-primary-light) 100%);
    color: #ffffff;
}

.sidebar-brand .brand-logo {
    width: 38px;
    height: 38px;
    background: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
    padding: 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.sidebar-brand .brand-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sidebar-brand .brand-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.sidebar-brand .brand-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Sidebar Nav */
.sidebar-menu-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.sidebar-menu-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ptsp-text-light);
    padding: 0.75rem 0.75rem 0.35rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    color: var(--ptsp-text-muted);
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
    color: var(--ptsp-text-light);
    transition: color 0.15s ease;
}

.sidebar-nav .nav-link:hover {
    color: var(--ptsp-primary);
    background-color: var(--ptsp-accent-subtle);
}

.sidebar-nav .nav-link:hover i {
    color: var(--ptsp-primary);
}

.sidebar-nav .nav-link.active {
    color: var(--ptsp-primary);
    background-color: var(--ptsp-accent-subtle);
    font-weight: 600;
}

.sidebar-nav .nav-link.active i {
    color: var(--ptsp-primary);
}

/* Main Content Area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0; /* Cegah flex-overflow */
    transition: margin-left 0.25s ease;
}

/* Topbar */
.app-topbar {
    height: var(--topbar-height);
    background-color: var(--ptsp-surface);
    border-bottom: 1px solid var(--ptsp-border);
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--ptsp-text-muted);
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-sidebar-toggle:hover {
    background-color: var(--ptsp-bg);
    color: var(--ptsp-primary);
}

.topbar-breadcrumb {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* User Profile Dropdown */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.625rem;
    border-radius: 9999px;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}
.topbar-user-btn:hover {
    background-color: var(--ptsp-bg);
    border-color: var(--ptsp-border);
}

.user-avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ptsp-primary) 0%, var(--ptsp-accent) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-meta {
    text-align: left;
    line-height: 1.2;
}
.user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ptsp-text-main);
}
.user-role-badge {
    font-size: 0.7rem;
    color: var(--ptsp-primary);
    font-weight: 500;
}

/* Content Area */
.app-content {
    flex: 1;
    padding: 1.5rem;
}

/* Footer */
.app-footer {
    height: var(--footer-height);
    background-color: var(--ptsp-surface);
    border-top: 1px solid var(--ptsp-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-size: 0.8125rem;
    color: var(--ptsp-text-muted);
}

/* Cards & Panels */
.ptsp-card {
    background: var(--ptsp-surface);
    border: 1px solid var(--ptsp-border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.ptsp-card:hover {
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
}

.ptsp-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--ptsp-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ptsp-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--ptsp-text-main);
}
.ptsp-card-body {
    padding: 1.25rem;
}

/* KPI Stat Cards */
.kpi-card {
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--ptsp-surface);
    border: 1px solid var(--ptsp-border);
    position: relative;
    overflow: hidden;
}
.kpi-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.kpi-title {
    font-size: 0.8125rem;
    color: var(--ptsp-text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ptsp-text-main);
    line-height: 1;
    margin: 0;
}

/* Status Badges SIPADU (6 Status Resmi) */
.badge-status,
.status-badge {
    padding: 0.35em 0.75em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.3;
}
.badge-status-diterima,
.status-diterima {
    background-color: var(--status-diterima-bg);
    color: var(--status-diterima-color);
}
.badge-status-menunggu,
.badge-status-menunggu_kelengkapan,
.status-menunggu,
.status-menunggu_kelengkapan {
    background-color: var(--status-menunggu-bg);
    color: var(--status-menunggu-color);
}
.badge-status-diproses,
.status-diproses {
    background-color: var(--status-diproses-bg);
    color: var(--status-diproses-color);
}
.badge-status-selesai,
.status-selesai {
    background-color: var(--status-selesai-bg);
    color: var(--status-selesai-color);
}
.badge-status-ditolak,
.status-ditolak {
    background-color: var(--status-ditolak-bg);
    color: var(--status-ditolak-color);
}
.badge-status-dibatalkan,
.status-dibatalkan {
    background-color: var(--status-dibatalkan-bg);
    color: var(--status-dibatalkan-color);
}

/* Service Card Item */
.service-card {
    background: var(--ptsp-surface);
    border: 1px solid var(--ptsp-border);
    border-radius: 12px;
    padding: 1.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease;
}
.service-card:hover {
    border-color: var(--ptsp-accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px -4px rgba(20, 83, 45, 0.12);
}

.service-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background-color: var(--ptsp-accent-subtle);
    color: var(--ptsp-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.875rem;
}

.service-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ptsp-text-main);
    margin-bottom: 0.35rem;
}

.service-card-desc {
    font-size: 0.8125rem;
    color: var(--ptsp-text-muted);
    margin-bottom: 1rem;
    flex-grow: 1;
}

/* Free Badge */
.badge-free {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    font-weight: 600;
    font-size: 0.725rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

/* Login Page Styling */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--ptsp-surface);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid var(--ptsp-border);
}

.auth-header {
    background: linear-gradient(135deg, var(--ptsp-primary) 0%, var(--ptsp-primary-light) 100%);
    padding: 2rem 1.5rem 1.75rem;
    text-align: center;
    color: #ffffff;
}

.auth-logo-badge {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.85rem;
    margin-bottom: 0.75rem;
}

.auth-brand-logos-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    background: #ffffff;
    padding: 0.5rem 0.875rem;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    margin-bottom: 0.875rem;
}

.auth-brand-logos-container .auth-logo-img {
    height: 48px;
    width: 48px;
    object-fit: contain;
    display: block;
}

.auth-brand-divider {
    width: 1px;
    height: 28px;
    background-color: #cbd5e1;
}

.auth-body {
    padding: 2rem 1.75rem;
}

/* Form Controls */
.form-control:focus, .form-select:focus {
    border-color: var(--ptsp-accent);
    box-shadow: 0 0 0 0.25rem rgba(20, 83, 45, 0.15);
}

/* ==========================================================================
   BUTTON HARDENING & ACCESSIBILITY (WCAG AA COMPLIANT)
   Menjamin kontras tinggi teks dan latar pada kondisi Normal, Hover, Focus, Active, Disabled
   ========================================================================== */

/* 1. Tombol Utama SIPADU (Login & Aksi Kunci) */
.btn-ptsp-primary,
.btn-login-submit {
    background-color: var(--ptsp-primary) !important;
    border-color: var(--ptsp-primary) !important;
    color: #ffffff !important;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.btn-ptsp-primary:hover,
.btn-login-submit:hover {
    background-color: var(--ptsp-primary-hover) !important; /* Forest Green 800 - Kontras tinggi > 4.5:1 terhadap #fff */
    border-color: #14532d !important;
    color: #ffffff !important;
}
.btn-ptsp-primary:focus,
.btn-ptsp-primary:focus-visible,
.btn-login-submit:focus,
.btn-login-submit:focus-visible {
    background-color: var(--ptsp-primary-hover) !important;
    border-color: #0b341c !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(20, 83, 45, 0.4) !important;
    outline: none !important;
}
.btn-ptsp-primary:active,
.btn-ptsp-primary.active,
.btn-login-submit:active,
.btn-login-submit.active {
    background-color: #0b341c !important; /* Deep Forest Green */
    border-color: #0b341c !important;
    color: #ffffff !important;
}
.btn-ptsp-primary:disabled,
.btn-ptsp-primary.disabled,
.btn-login-submit:disabled,
.btn-login-submit.disabled {
    background-color: #64748b !important;
    border-color: #64748b !important;
    color: #ffffff !important;
    opacity: 0.65;
    cursor: not-allowed;
}

/* 2. Tombol Success (Simpan, Terima, Selesai, Unduh Hasil) */
.btn-success {
    background-color: #15803d !important;
    border-color: #15803d !important;
    color: #ffffff !important;
}
.btn-success:hover {
    background-color: #166534 !important;
    border-color: #14532d !important;
    color: #ffffff !important;
}
.btn-success:focus,
.btn-success:focus-visible {
    background-color: #166534 !important;
    border-color: #0b341c !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(22, 101, 52, 0.4) !important;
    outline: none !important;
}
.btn-success:active,
.btn-success.active {
    background-color: #14532d !important;
    border-color: #0b341c !important;
    color: #ffffff !important;
}

/* 3. Tombol Outline Success */
.btn-outline-success {
    color: #15803d !important;
    border-color: #15803d !important;
    background-color: transparent !important;
}
.btn-outline-success:hover {
    background-color: #15803d !important;
    border-color: #15803d !important;
    color: #ffffff !important;
}
.btn-outline-success:focus,
.btn-outline-success:focus-visible {
    color: #15803d !important;
    background-color: #dcfce7 !important;
    border-color: #15803d !important;
    box-shadow: 0 0 0 0.25rem rgba(21, 128, 61, 0.35) !important;
    outline: none !important;
}
.btn-outline-success:active,
.btn-outline-success.active {
    background-color: #14532d !important;
    border-color: #14532d !important;
    color: #ffffff !important;
}

/* 4. Tombol Primary (Detail, Lacak, Verifikasi Berkas) */
.btn-primary {
    background-color: #0284c7 !important;
    border-color: #0284c7 !important;
    color: #ffffff !important;
}
.btn-primary:hover {
    background-color: #0369a1 !important;
    border-color: #075985 !important;
    color: #ffffff !important;
}
.btn-primary:focus,
.btn-primary:focus-visible {
    background-color: #0369a1 !important;
    border-color: #075985 !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(2, 132, 199, 0.4) !important;
    outline: none !important;
}
.btn-primary:active,
.btn-primary.active {
    background-color: #075985 !important;
    border-color: #0c4a6e !important;
    color: #ffffff !important;
}

/* 5. Tombol Outline Primary */
.btn-outline-primary {
    color: #0284c7 !important;
    border-color: #0284c7 !important;
    background-color: transparent !important;
}
.btn-outline-primary:hover {
    background-color: #0284c7 !important;
    border-color: #0284c7 !important;
    color: #ffffff !important;
}
.btn-outline-primary:focus,
.btn-outline-primary:focus-visible {
    color: #0284c7 !important;
    background-color: #e0f2fe !important;
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 0.25rem rgba(2, 132, 199, 0.35) !important;
    outline: none !important;
}
.btn-outline-primary:active,
.btn-outline-primary.active {
    background-color: #075985 !important;
    border-color: #075985 !important;
    color: #ffffff !important;
}

/* 6. Tombol Warning (Nilai Survei, Revisi Berkas) */
.btn-warning {
    background-color: #d97706 !important;
    border-color: #d97706 !important;
    color: #ffffff !important; /* Teks putih di atas amber tua kontras > 4.5:1 */
}
.btn-warning:hover {
    background-color: #b45309 !important;
    border-color: #92400e !important;
    color: #ffffff !important;
}
.btn-warning:focus,
.btn-warning:focus-visible {
    background-color: #b45309 !important;
    border-color: #92400e !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(217, 119, 6, 0.4) !important;
    outline: none !important;
}
.btn-warning:active,
.btn-warning.active {
    background-color: #92400e !important;
    border-color: #78350f !important;
    color: #ffffff !important;
}

/* 7. Tombol Danger & Outline Danger (Tolak, Batalkan, Hapus) */
.btn-danger {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}
.btn-danger:hover {
    background-color: #b91c1c !important;
    border-color: #991b1b !important;
    color: #ffffff !important;
}
.btn-danger:focus,
.btn-danger:focus-visible {
    background-color: #b91c1c !important;
    border-color: #991b1b !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 38, 38, 0.4) !important;
    outline: none !important;
}
.btn-outline-danger {
    color: #dc2626 !important;
    border-color: #dc2626 !important;
    background-color: transparent !important;
}
.btn-outline-danger:hover {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}
.btn-outline-danger:focus,
.btn-outline-danger:focus-visible {
    color: #dc2626 !important;
    background-color: #fee2e2 !important;
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 38, 38, 0.35) !important;
    outline: none !important;
}

/* 8. Tombol Secondary & Outline Secondary */
.btn-secondary {
    background-color: #475569 !important;
    border-color: #475569 !important;
    color: #ffffff !important;
}
.btn-secondary:hover {
    background-color: #334155 !important;
    border-color: #1e293b !important;
    color: #ffffff !important;
}
.btn-outline-secondary {
    color: #334155 !important;
    border-color: #cbd5e1 !important;
    background-color: transparent !important;
}
.btn-outline-secondary:hover {
    background-color: #f1f5f9 !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}
.btn-outline-secondary:focus,
.btn-outline-secondary:focus-visible {
    background-color: #f1f5f9 !important;
    border-color: #64748b !important;
    color: #0f172a !important;
    box-shadow: 0 0 0 0.25rem rgba(100, 116, 139, 0.3) !important;
    outline: none !important;
}

/* General button accessibility */
.btn:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

/* Mobile & Responsive Breakpoints */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-main {
        margin-left: 0;
    }
    .app-topbar {
        padding: 0 1rem;
    }
    .app-content {
        padding: 1rem;
    }
    .user-meta {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .app-topbar .topbar-breadcrumb {
        display: none;
    }
    .auth-card {
        border-radius: 12px;
    }
    .auth-body {
        padding: 1.5rem 1.25rem;
    }
}
