/* ==========================================================
   ROOT VARIABLES - Design Tokens
   Tema: Warm Neutral - santai namun tetap profesional
   ========================================================== */
:root {
    --color-primary: #c17b4a;
    --color-primary-dark: #a5643a;
    --color-sidebar: #3a2f27;
    --color-bg: #f7f2ea;
    --color-card: #fffdfa;
    --color-border: #ece2d4;
    --color-text: #4a3f35;
    --color-text-secondary: #8a7c6c;

    --color-success: #7f9d5c;
    --color-warning: #d9a441;
    --color-danger: #c1614b;
    --color-info: #6f9c92;

    --radius: 14px;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 80px;
    --navbar-height: 70px;
    --layout-gap: 1.1rem;
    --transition-speed: 0.3s;

    --font-heading: "Poppins", "Nunito", sans-serif;
    --font-body: "Nunito", "Poppins", sans-serif;
}

/* ==========================================================
   BASE / GLOBAL
   ========================================================== */

/* PENTING: cegah dokumen jadi lebih lebar dari viewport.
   Hanya ditaruh di <html>. TIDAK di body/app-wrapper/main-content,
   karena overflow-x non-visible pada body memaksa overflow-y jadi "auto"
   (aturan CSS bawaan), yang membuat body jadi scroll container sendiri
   dan merusak position:sticky di dalamnya. */
html {
    overflow-x: hidden;
    width: 100%;
}

body {
    background-color: var(--color-bg);
    font-family: var(--font-body);
    color: var(--color-text);
}

h1,
h2,
h3,
h4,
h5,
h6,
.fw-bold,
.fw-semibold {
    font-family: var(--font-heading);
}

a {
    text-decoration: none;
}

.app-wrapper {
    min-height: 100vh;
    padding: var(--layout-gap);
    gap: var(--layout-gap);
}

.btn-primary,
.bg-primary {
    background-color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
}

.text-primary {
    color: var(--color-primary) !important;
}

.text-secondary {
    color: var(--color-text-secondary) !important;
}

/* ==========================================================
   SIDEBAR
   ========================================================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--color-sidebar);
    height: calc(100vh - (var(--layout-gap) * 2));
    position: sticky;
    top: var(--layout-gap);
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    box-shadow: 0 14px 34px rgba(58, 47, 39, 0.16);
    transition:
        width var(--transition-speed) ease,
        min-width var(--transition-speed) ease,
        transform var(--transition-speed) ease;
    z-index: 1030;
}

.sidebar-brand {
    padding: 1.5rem 1.5rem 1.25rem;
    color: #fff;
    font-family: var(--font-heading);
}

.sidebar-brand .brand-logo {
    width: 42px;
    height: 42px;
    min-width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-primary);
    border-radius: 14px;
    font-size: 1.15rem;
}

.sidebar-brand .brand-text {
    font-size: 1.1rem;
    white-space: nowrap;
}

.sidebar-menu {
    padding: 0.5rem 1rem 1rem;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
    padding: 0.9rem 0.85rem 0.4rem;
}

.sidebar.collapsed .sidebar-section-label {
    text-align: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-item {
    margin-bottom: 0.3rem;
}

.sidebar-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.08);
    margin: 0.75rem 0.5rem 1rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.62);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
    cursor: pointer;
}

.sidebar-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}

.sidebar-icon i {
    font-size: 1rem;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.sidebar-item.active > .sidebar-link {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-primary);
}

.sidebar-item.active > .sidebar-link .sidebar-icon {
    color: var(--color-primary);
}

.sidebar-logout {
    color: #e8a08e;
}

.sidebar-logout:hover {
    background-color: rgba(232, 160, 142, 0.12);
    color: #e8a08e;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    min-width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .menu-text {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(58, 47, 39, 0.45);
    z-index: 1020;
}
.sidebar-item.has-submenu .submenu-caret {
    transition: transform 0.2s ease;
    font-size: 0.7rem;
}
.sidebar-item.has-submenu.open .submenu-caret,
.submenu-toggle[aria-expanded="true"] .submenu-caret {
    transform: rotate(180deg);
}

.sidebar-submenu {
    padding-left: 0.5rem;
    margin-top: 0.25rem;
}
.sidebar-submenu .sidebar-link {
    border-radius: 0.6rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    font-size: 0.9rem;
}
.sidebar-submenu .sidebar-item.active .sidebar-link {
    background: rgba(255, 255, 255, 0.12);
}
/* ==========================================================
   RESPONSIVE SIDEBAR (Mobile)
   ========================================================== */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: var(--layout-gap);
        top: var(--layout-gap);
        height: calc(100vh - (var(--layout-gap) * 2));
        transform: translateX(calc(-100% - var(--layout-gap) - 20px));
        visibility: hidden; /* benar-benar keluarkan dari render saat tersembunyi */
    }

    .sidebar.show {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* ==========================================================
   NAVBAR
   ========================================================== */
.navbar-top {
    height: var(--navbar-height);
    background-color: var(--color-card);
    border-radius: 20px;
    box-shadow: 0 10px 28px rgba(58, 47, 39, 0.1);
    position: sticky;
    top: var(--layout-gap);
    z-index: 1010;
}

.btn-icon {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.btn-icon:hover {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* Search: icon button + input yang muncul saat diklik */
.search-wrapper {
    position: relative;
}

.search-input {
    width: 0;
    padding: 0;
    opacity: 0;
    background-color: var(--color-bg);
    border-radius: 30px;
    margin-left: 0;
    transition:
        width 0.3s ease,
        opacity 0.3s ease,
        margin-left 0.3s ease,
        padding 0.3s ease;
}

.search-input.show {
    width: 240px;
    opacity: 1;
    margin-left: 0.6rem;
    padding: 0.5rem 1rem;
}

.notif-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 8px;
    height: 8px;
    background-color: var(--color-danger);
    border: 2px solid var(--color-card);
    border-radius: 50%;
}

.notif-dropdown {
    width: 320px;
}

.avatar-wrapper {
    position: relative;
    display: inline-flex;
}

.avatar-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background-color: var(--color-success);
    border: 2px solid var(--color-card);
    border-radius: 50%;
}

.btn-icon-lg {
    border-radius: 30px;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    transition: border-color 0.2s ease;
}

.btn-icon-lg:hover {
    border-color: var(--color-primary);
}

.user-dropdown-btn {
    border-radius: 30px;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
}

/* Site Switcher (navbar) */
.site-switcher {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 30px;
    padding: 0.4rem 0.9rem 0.4rem 0.7rem;
    margin-left: 0.25rem;
    gap: 0.55rem;
}

.site-switcher-icon {
    color: var(--color-primary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.site-switcher-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

.site-switcher-select {
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    max-width: 160px;
    text-overflow: ellipsis;
}

/* ==========================================================
   MAIN CONTENT
   ========================================================== */
.main-content {
    display: flex;
    flex-direction: column;
    gap: var(--layout-gap);
    min-width: 0;
}

.page-content {
    flex-grow: 1;
}

/* ==========================================================
   CARDS (Warm & Friendly Style)
   ========================================================== */
.card {
    background-color: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(90, 70, 50, 0.05);
    transition:
        box-shadow 0.25s ease,
        transform 0.25s ease;
}

.card:hover {
    box-shadow: 0 10px 24px rgba(90, 70, 50, 0.09);
    transform: translateY(-2px);
}

/* Statistic Card */
.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.badge-trend {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
}

.badge-trend-success {
    background-color: rgba(127, 157, 92, 0.15);
    color: var(--color-success);
}

.badge-trend-danger {
    background-color: rgba(193, 97, 75, 0.14);
    color: var(--color-danger);
}

/* Soft Background Colors untuk Icon (tint hangat) */
.bg-primary-soft {
    background-color: rgba(193, 123, 74, 0.14);
    color: var(--color-primary);
}
.bg-success-soft {
    background-color: rgba(127, 157, 92, 0.15);
    color: var(--color-success);
}
.bg-warning-soft {
    background-color: rgba(217, 164, 65, 0.16);
    color: var(--color-warning);
}
.bg-info-soft {
    background-color: rgba(111, 156, 146, 0.15);
    color: var(--color-info);
}

.activity-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================
   BREADCRUMB
   ========================================================== */
.page-header .breadcrumb {
    font-size: 0.875rem;
}

.page-header .breadcrumb-item.active {
    color: var(--color-text-secondary);
}

/* ==========================================================
   FOOTER
   ========================================================== */
.app-footer {
    background-color: var(--color-card);
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(58, 47, 39, 0.08);
}

/* ==========================================================
   SCROLLBAR (Sidebar)
   ========================================================== */
.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

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

/* ==========================================================
   RESPONSIVE LAYOUT (Mobile)
   ========================================================== */
@media (max-width: 991.98px) {
    .app-wrapper {
        gap: 0;
        max-width: 100vw; /* cegah wrapper ikut melebar akibat elemen anak */
    }

    .main-content {
        width: 100%;
        max-width: 100vw;
        margin: 0;
    }

    /* Gap yang jelas terlihat antara navbar dan tepi atas layar saat discroll */
    .navbar-top {
        top: 1.5rem;
    }
}

/* ==========================================================
   DATATABLES - active pagination link color
   ========================================================== */
.dataTables_wrapper .page-item.active .page-link {
    background-color: #3A2F27;
    border-color: #3A2F27;
    color: #fff;
}

.dataTables_wrapper .page-item.active .page-link:hover {
    background-color: #3A2F27;
    border-color: #3A2F27;
}

.dataTables_wrapper .page-item .page-link {
    color: #C17B4A;
}
