/* =================================================
   SiBaron — Global CSS
   Design system: tokens, components, animations
   ================================================= */

/* ---------- 1. Google Fonts Import ---------- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* ---------- 2. CSS Custom Properties (Design Tokens) ---------- */
:root {
    /* Brand Colors */
    --color-brand-50:  #ecfdf5;
    --color-brand-100: #d1fae5;
    --color-brand-200: #a7f3d0;
    --color-brand-400: #34d399;
    --color-brand-500: #10b981;
    --color-brand-600: #059669;
    --color-brand-700: #047857;
    --color-brand-800: #065f46;
    --color-brand-900: #064e3b;

    /* Dark Sidebar Colors */
    --sidebar-bg:      #0f1f1a;
    --sidebar-border:  #1e3a30;
    --sidebar-item-hover: rgba(16, 185, 129, 0.1);
    --sidebar-item-active-from: #059669;
    --sidebar-item-active-to:   #047857;

    /* Semantic Colors */
    --color-danger:  #ef4444;
    --color-warning: #f59e0b;
    --color-info:    #3b82f6;
    --color-success: #10b981;

    /* Neutral */
    --color-bg:      #f0fdf8;
    --color-surface: #ffffff;
    --color-border:  #e2e8f0;
    --color-text:    #1e293b;
    --color-muted:   #64748b;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:  0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);
    --shadow-card: 0 2px 8px rgba(5,150,105,.08);

    /* Radius */
    --radius-sm: .5rem;
    --radius-md: .75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    /* Transitions */
    --transition: all .2s cubic-bezier(.4,0,.2,1);
    --transition-slow: all .35s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---------- 4. Scrollbar Custom ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------- 5. Sidebar Styles ---------- */
.sidebar-dark {
    background: linear-gradient(180deg, #0f1f1a 0%, #0a1a14 100%);
}

/* ---------- 5b. Layout: Topbar + Main + Footer ---------- */
.main-content {
    min-height: 0;          /* allow flex-child to scroll */
    min-width: 0;
}

.topbar-app {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3.75rem;
    padding: 0 1.25rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    flex-shrink: 0;
}

.app-footer {
    background: white;
    border-top: 1px solid var(--color-border);
    padding: .75rem 1.5rem;
    flex-shrink: 0;
}



.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: .65rem 1rem;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 500;
    color: #94a3b8;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.sidebar-nav-item:hover {
    background: rgba(16, 185, 129, .12);
    color: #34d399;
}

.sidebar-nav-item.active {
    background: linear-gradient(135deg, var(--sidebar-item-active-from), var(--sidebar-item-active-to));
    color: #fff;
    box-shadow: 0 4px 12px rgba(5, 150, 105, .35);
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: #6ee7b7;
    border-radius: 0 2px 2px 0;
}

.sidebar-section-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #475569;
    padding: 0 .75rem;
    margin-top: 1.25rem;
    margin-bottom: .35rem;
}

/* ---------- 6. Card Component ---------- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: var(--transition);
}

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

.card-stat {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    border: 1px solid #f0fdf8;
    position: relative;
    overflow: hidden;
    transition: var(--transition-slow);
}

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

.card-stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .75rem;
}

/* ---------- 7. Badge Component ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .65rem;
    border-radius: 9999px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-gray    { background: #f1f5f9; color: #475569; }

/* SP Status Badges */
.sp-aman         { background: #d1fae5; color: #065f46; }
.sp-pra          { background: #fef3c7; color: #92400e; }
.sp-sp1          { background: #fed7aa; color: #9a3412; }
.sp-sp2          { background: #fee2e2; color: #991b1b; }
.sp-sp3          { background: #fce7f3; color: #9d174d; }

/* ---------- 8. Button Component ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    box-shadow: 0 2px 8px rgba(5,150,105,.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(5,150,105,.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 8px rgba(239,68,68,.25);
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(239,68,68,.35); }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--color-border);
    color: var(--color-muted);
}
.btn-outline:hover { border-color: var(--color-brand-500); color: var(--color-brand-600); background: var(--color-brand-50); }

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }

/* ---------- 9. Form Elements ---------- */
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: .6rem .9rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-family: inherit;
    background: white;
    color: var(--color-text);
    transition: var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--color-brand-500);
    box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}

.form-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .35rem;
}

/* ---------- 10. Table Styles ---------- */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    background: #f8fafc;
    padding: .75rem 1rem;
    text-align: left;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    border-bottom: 1px solid var(--color-border);
}

.data-table tbody td {
    padding: .85rem 1rem;
    font-size: .875rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

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

.data-table tbody tr {
    transition: var(--transition);
}

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

/* ---------- 11. Modal Styles ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0,0,0,.2);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px) scale(.97);
    transition: var(--transition-slow);
}

.modal-overlay.open .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body { padding: 1.25rem 1.5rem; }

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
}

/* ---------- 12. Page Header ---------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.page-subtitle {
    font-size: .875rem;
    color: var(--color-muted);
    margin-top: .2rem;
}

/* ---------- 13. Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(.8); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
    50%       { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
}

.animate-fade-in { animation: fadeIn .4s ease both; }
.animate-slide-left { animation: slideInLeft .4s ease both; }

/* Staggered children */
.stagger-children > *:nth-child(1) { animation-delay: .05s; }
.stagger-children > *:nth-child(2) { animation-delay: .10s; }
.stagger-children > *:nth-child(3) { animation-delay: .15s; }
.stagger-children > *:nth-child(4) { animation-delay: .20s; }

/* ---------- 14. Mobile Topbar ---------- */
.mobile-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: white;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}

/* ---------- 15. Responsive Utilities ---------- */
@media (max-width: 1023px) {

}

@media (max-width: 640px) {
    .page-title { font-size: 1.15rem; }
    .card-stat { padding: 1rem; }
    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        margin-bottom: .75rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }
    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: .6rem .85rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: .8rem;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: .7rem;
        text-transform: uppercase;
        color: var(--color-muted);
        flex-shrink: 0;
        margin-right: .5rem;
    }
    .data-table tbody tr:last-child td:last-child { border-bottom: none; }
}

/* ---------- 16. Utility Classes ---------- */
.text-gradient {
    background: linear-gradient(135deg, var(--color-brand-500), var(--color-brand-700));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass {
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.5);
}

.divider {
    height: 1px;
    background: var(--color-border);
    margin: 1rem 0;
}

/* ---------- 17. Toast Notification ---------- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

/* ---------- 18. Extra Badge & Button Variants ---------- */
.badge-purple {
    background: #f3e8ff;
    color: #7c3aed;
    border: 1px solid #ddd6fe;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    border-radius: .625rem;
    font-size: .875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(239,68,68,.25);
    text-decoration: none;
}
.btn-danger:hover { opacity: .88; transform: translateY(-1px); }
.btn-danger:active { transform: translateY(0); }

/* ---------- 19. Permission checkbox scrollable area ---------- */
#permGroupsContainer::-webkit-scrollbar { width: 4px; }
#permGroupsContainer::-webkit-scrollbar-track { background: transparent; }
#permGroupsContainer::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* Mobile topbar */
.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    padding: .75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

