/* ==========================================================================
   SSO Admin theme (di atas Bootstrap 5.3)
   ========================================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 76px;
    --topbar-height: 64px;
    --sidebar-bg: #111827;
    --sidebar-bg-2: #1f2937;
    --sidebar-text: #9ca3af;
    --sidebar-text-hover: #f9fafb;
    --sidebar-active-bg: rgba(99, 102, 241, .16);
    --sidebar-active: #a5b4fc;
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --page-bg: #f3f4f8;
    --card-border: #e8eaf0;
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: #4f46e5;
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: #4338ca;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-size: .925rem;
}

body { background: var(--page-bg); color: #1f2937; }

/* Bootstrap primary override ------------------------------------------------ */
.btn-primary {
    --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca;
    --bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3;
    --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand); --bs-btn-active-border-color: var(--brand);
}
.text-primary { color: var(--brand) !important; }
.bg-primary, .text-bg-primary { background-color: var(--brand) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.page-link { color: var(--brand); }
.active > .page-link, .page-link.active { background-color: var(--brand); border-color: var(--brand); }
.btn { border-radius: .5rem; font-weight: 500; }
.form-control, .form-select, .input-group-text { border-radius: .5rem; }

/* Sidebar -------------------------------------------------------------------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    display: flex; flex-direction: column;
    transition: width .2s ease, transform .2s ease;
}
.sidebar-brand {
    height: var(--topbar-height); flex-shrink: 0;
    display: flex; align-items: center; gap: .75rem;
    padding: 0 1.25rem; color: #fff; text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-brand:hover { color: #fff; }
.sidebar-logo {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); font-size: 1.1rem;
}
.sidebar-brand-text { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.sidebar-brand-text small { display: block; font-weight: 400; font-size: .7rem; color: var(--sidebar-text); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem; }
.sidebar-heading {
    font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: #6b7280; padding: 1rem .75rem .5rem; white-space: nowrap;
}
.sidebar-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem .75rem; margin-bottom: 2px; border-radius: .5rem;
    color: var(--sidebar-text); text-decoration: none; white-space: nowrap;
    transition: background-color .15s ease, color .15s ease;
}
.sidebar-link .bi { font-size: 1.1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { color: var(--sidebar-text-hover); background: rgba(255, 255, 255, .05); }
.sidebar-link.active { color: var(--sidebar-active); background: var(--sidebar-active-bg); font-weight: 600; }
.sidebar-link .badge { margin-left: auto; }

.sidebar-footer {
    padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-user {
    display: flex; align-items: center; gap: .75rem; padding: .5rem; border-radius: .5rem;
    color: #e5e7eb; overflow: hidden;
}
.sidebar-user-info { min-width: 0; line-height: 1.2; }
.sidebar-user-info small { color: var(--sidebar-text); }

/* Collapsed (desktop) */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }
    body.sidebar-collapsed .main { margin-left: var(--sidebar-collapsed); }
    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .sidebar-link span,
    body.sidebar-collapsed .sidebar-link .badge,
    body.sidebar-collapsed .sidebar-user-info { display: none; }
    body.sidebar-collapsed .sidebar-heading { visibility: hidden; height: .75rem; padding: 0; }
    body.sidebar-collapsed .sidebar-brand,
    body.sidebar-collapsed .sidebar-link,
    body.sidebar-collapsed .sidebar-user { justify-content: center; }
}

/* Mobile */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(17, 24, 39, .5);
    }
}

/* Main & topbar ----------------------------------------------------------------- */
.main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }
@media (max-width: 991.98px) { .main { margin-left: 0; } }

.topbar {
    position: sticky; top: 0; z-index: 1030;
    height: var(--topbar-height);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, .9); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--card-border);
}
.topbar-toggle {
    border: 0; background: transparent; font-size: 1.35rem; color: #4b5563;
    width: 40px; height: 40px; border-radius: .5rem;
}
.topbar-toggle:hover { background: #f3f4f6; }
.topbar .breadcrumb { font-size: .8rem; }
.topbar-title { font-weight: 600; font-size: 1rem; margin: 0; line-height: 1.2; }
.topbar .dropdown-toggle::after { display: none; }
.topbar-user { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; padding: .25rem .5rem; border-radius: .5rem; }
.topbar-user:hover { background: #f3f4f6; }

.avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: .85rem; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.avatar-sm { width: 30px; height: 30px; font-size: .75rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }

.content { padding: 1.5rem; flex: 1; }
@media (min-width: 1200px) { .content { padding: 2rem; } }
.footer { padding: 1rem 1.5rem; font-size: .8rem; color: #6b7280; border-top: 1px solid var(--card-border); background: #fff; }

/* Page header ----------------------------------------------------------------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header p { color: #6b7280; margin: .25rem 0 0; }

/* Cards ------------------------------------------------------------------------- */
.card { border: 1px solid var(--card-border); border-radius: .85rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header {
    background: #fff; border-bottom: 1px solid var(--card-border);
    padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    border-top-left-radius: .85rem !important; border-top-right-radius: .85rem !important;
}
.card-title { font-size: .95rem; font-weight: 600; margin: 0; }
.card-body { padding: 1.25rem; }

/* Stat cards */
.stat-card .card-body { display: flex; align-items: flex-start; gap: 1rem; }
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.stat-label { font-size: .8rem; color: #6b7280; font-weight: 500; }
.stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.2; color: #111827; }
.stat-meta { font-size: .78rem; color: #6b7280; }
.soft-primary { background: #eef2ff; color: #4f46e5; }
.soft-success { background: #ecfdf5; color: #059669; }
.soft-warning { background: #fffbeb; color: #d97706; }
.soft-info { background: #ecfeff; color: #0891b2; }
.soft-danger { background: #fef2f2; color: #dc2626; }
.soft-secondary { background: #f3f4f6; color: #4b5563; }

/* Welcome banner */
.welcome-card {
    border: 0; color: #fff; overflow: hidden; position: relative;
    background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 100%);
}
.welcome-card::after {
    content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px;
    border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.welcome-card .text-muted-light { color: rgba(255, 255, 255, .8); }

/* Tables ------------------------------------------------------------------------ */
.table { --bs-table-hover-bg: #f9fafb; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .8rem 1.25rem; border-color: #f0f1f5; }
.table thead th {
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: #6b7280; background: #f9fafb; border-bottom: 1px solid var(--card-border);
}
.card > .table-responsive:last-child .table tr:last-child td { border-bottom: 0; }

.badge { font-weight: 600; padding: .4em .65em; border-radius: .4rem; }
.badge-soft-success { background: #ecfdf5; color: #047857; }
.badge-soft-danger { background: #fef2f2; color: #b91c1c; }
.badge-soft-primary { background: #eef2ff; color: #4338ca; }
.badge-soft-info { background: #ecfeff; color: #0e7490; }
.badge-soft-secondary { background: #f3f4f6; color: #374151; }
.badge-soft-warning { background: #fffbeb; color: #b45309; }

.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* App tiles --------------------------------------------------------------------- */
.app-tile { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; height: 100%; }
.app-tile:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(16, 24, 40, .08); border-color: #c7d2fe; }
.app-avatar {
    width: 46px; height: 46px; border-radius: 12px; font-weight: 700; font-size: 1.2rem;
    display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Lists ------------------------------------------------------------------------ */
.list-activity { list-style: none; padding: 0; margin: 0; }
.list-activity li { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-bottom: 1px solid #f0f1f5; }
.list-activity li:last-child { border-bottom: 0; }
.progress-thin { height: 6px; border-radius: 3px; background: #eef2ff; }
.progress-thin .progress-bar { background: var(--brand); border-radius: 3px; }

.empty-state { text-align: center; padding: 3rem 1rem; color: #6b7280; }
.empty-state > .bi { font-size: 2.5rem; color: #c7d2fe; }

/* Auth pages -------------------------------------------------------------------- */
.auth-page { min-height: 100vh; display: flex; background: #fff; }
.auth-aside {
    flex: 1 1 50%; position: relative; overflow: hidden; color: #fff;
    background: linear-gradient(135deg, #312e81 0%, #4f46e5 50%, #7c3aed 100%);
    padding: 3rem; display: none; flex-direction: column; justify-content: space-between;
}
@media (min-width: 992px) { .auth-aside { display: flex; } }
.auth-aside::before, .auth-aside::after {
    content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .07);
}
.auth-aside::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.auth-aside::after { width: 300px; height: 300px; left: -100px; bottom: -100px; }
.auth-aside > * { position: relative; z-index: 1; }
.auth-feature { display: flex; gap: .9rem; margin-bottom: 1.25rem; }
.auth-feature .bi {
    width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .14);
}
.auth-main { flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--page-bg); }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .card { border-radius: 1rem; box-shadow: 0 10px 30px rgba(16, 24, 40, .06); }
.auth-box .form-control { padding: .65rem .85rem; }
.auth-box .input-group-text { background: #fff; color: #9ca3af; }

code { color: #6d28d9; }
pre code { color: inherit; }
.min-w-0 { min-width: 0; }
.card > .table-responsive:last-child,
.card > .list-activity:last-child { border-bottom-left-radius: .85rem; border-bottom-right-radius: .85rem; overflow: hidden; }
