/* ============================================================
   sidebar.css — SmartHospital Sidebar Clean White + Blue
   ============================================================ */

/* ---- Color Variables ---- */
:root {
    --sb-blue: #4f46e5;
    --sb-blue-light: #6366f1;
    --sb-blue-hover: #ede9fe;
    --sb-blue-active: #eef2ff;
    --sb-text: #3730a3;
    --sb-text-muted: #7c83d6;
    --sb-border: #e0e7ff;
    --sb-bg: #ffffff;
    --sb-shadow: rgba(79, 70, 229, 0.08);
}

/* ---- Dashboard Layout ---- */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar Utama ---- */
.sidebar {
    width: 265px;
    background: var(--sb-bg);
    border-right: 1.5px solid var(--sb-border);
    padding: 0;
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    box-shadow: 4px 0 20px rgba(79, 70, 229, 0.07);
    scrollbar-width: thin;
    scrollbar-color: var(--sb-border) transparent;
    transition: width 0.3s ease, transform 0.3s ease;
}

/* Custom Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--sb-border);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--sb-blue-light);
}

/* ---- Main Content Area ---- */
.main-content {
    margin-left: 265px;
    flex: 1;
    padding: 32px;
    transition: margin-left 0.3s ease;
}

/* ---- Brand Header ---- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 14px;
    border-bottom: 1.5px solid var(--sb-border);
}

/* ---- User Profile ---- */
.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px 16px;
    border-bottom: 1px solid var(--sb-border);
    margin-bottom: 4px;
    transition: all 0.3s ease;
}

/* ---- Avatar ---- */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sb-blue), var(--sb-blue-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
    border: 2px solid var(--sb-border);
}

/* ---- Sidebar Nav Wrapper ---- */
.sidebar-menu {
    padding: 4px 12px 24px;
    transition: padding 0.3s ease;
}

/* ---- Menu Item ---- */
.menu-item {
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    font-family: inherit;
    font-size: 13px;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--sb-text);
    margin-bottom: 1px;
    transition: all 0.18s ease;
    font-weight: 500;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    white-space: nowrap;
}

/* Hover */
.menu-item:hover {
    background: var(--sb-blue-hover);
    color: var(--sb-blue);
    transform: translateX(2px);
}

/* Active */
.menu-item.active {
    background: var(--sb-blue-active);
    color: var(--sb-blue);
    font-weight: 600;
    border: 1px solid rgba(79, 70, 229, 0.15);
    box-shadow: 0 1px 6px rgba(79, 70, 229, 0.08);
}

/* Active — indikator kiri */
.menu-item.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, var(--sb-blue), var(--sb-blue-light));
    border-radius: 0 3px 3px 0;
}

/* Icon kiri */
.menu-item i:first-child {
    width: 18px;
    text-align: center;
    font-size: 13px;
    color: var(--sb-text-muted);
    flex-shrink: 0;
    transition: color 0.18s;
}

.menu-item:hover i:first-child,
.menu-item.active i:first-child {
    color: var(--sb-blue);
}

/* Chevron kanan */
.menu-icon-right {
    margin-left: auto;
    font-size: 13px;
    color: var(--sb-text-muted);
    transition: transform 0.25s ease, color 0.18s;
    flex-shrink: 0;
}

.menu-item:hover .menu-icon-right,
.menu-item.active .menu-icon-right {
    color: var(--sb-blue);
}

/* Rotation class untuk chevron */
.rotate-90 {
    transform: rotate(90deg);
}

/* ---- Keluar (Logout) ---- */
a.menu-item[href*="logout"] {
    color: #ef4444;
}

a.menu-item[href*="logout"] i:first-child {
    color: #ef4444;
}

a.menu-item[href*="logout"]:hover {
    background: #fff1f2 !important;
    color: #dc2626 !important;
}

a.menu-item[href*="logout"]:hover i:first-child {
    color: #dc2626 !important;
}

/* ---- Submenu Container ---- */
.submenu-container {
    display: none;
    overflow: hidden;
    transition: all 0.3s ease;
    padding-left: 6px;
    border-left: 2px solid var(--sb-border);
    margin-left: 21px;
    margin-bottom: 2px;
}

.submenu-container.show {
    display: block;
}

/* ---- Submenu Item (level-2) ---- */
.submenu-item {
    padding-left: 22px !important;
    font-size: 13px;
    position: relative;
    white-space: normal !important;
    line-height: 1.4;
}

.submenu-item::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 16px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--sb-border);
    transition: background 0.2s;
}

.submenu-item:hover::before {
    background: var(--sb-blue-light);
}

.submenu-item.active::before {
    background: var(--sb-blue);
}

/* ---- Submenu Item Child ---- */
.submenu-item-child {
    padding-left: 24px !important;
    font-size: 13px;
    position: relative;
    white-space: normal !important;
    line-height: 1.4;
}

.submenu-item-child::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 15px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #c7d2fe;
    transition: all 0.2s;
}

.submenu-item-child:hover::before {
    background: var(--sb-blue-light);
}

.submenu-item-child.active {
    color: var(--sb-blue);
    font-weight: 600;
}

.submenu-item-child.active::before {
    background: var(--sb-blue);
}

/* ---- Toggle Button ---- */
#sidebar-toggle-btn {
    position: fixed;
    top: 22px;
    left: 251px;
    /* 265 - 14 (setengah tombol) */
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    border: 1.5px solid var(--sb-border);
    color: var(--sb-blue);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease,
        left 0.3s ease, transform 0.2s ease;
}

#sidebar-toggle-btn:hover {
    background: var(--sb-blue);
    color: white;
    border-color: var(--sb-blue);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    transform: scale(1.1);
}

#sidebar-toggle-btn i {
    transition: transform 0.3s ease;
}

/* =============================================
   MINI SIDEBAR — Icon Only Mode
   ============================================= */

/* Sidebar menyempit */
body.sidebar-mini .sidebar {
    width: 62px;
}

/* Tombol geser ikut sidebar */
body.sidebar-mini #sidebar-toggle-btn {
    left: 48px;
    /* 62 - 14 */
}

/* Putar chevron */
body.sidebar-mini #sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* Main content maju */
body.sidebar-mini .main-content {
    margin-left: 62px;
}

/* ===== Trik font-size:0 ===== */
/* Menyembunyikan TEXT NODE tanpa perlu ubah HTML.
   Ikon <i> di-reset ke ukuran normal dengan !important. */

body.sidebar-mini .sidebar .menu-item {
    font-size: 0;
    /* sembunyikan text node */
    justify-content: center;
    padding: 10px 0;
    overflow: visible;
    gap: 0;
    transform: none !important;
    /* nonaktifkan translateX hover */
}

body.sidebar-mini .sidebar .menu-item i {
    font-size: 13px !important;
    width: auto !important;
    margin: 0 !important;
}

/* Indikator aktif tetap muncul */
body.sidebar-mini .sidebar .menu-item.active::after {
    height: 50%;
}

/* Sembunyikan chevron kanan */
body.sidebar-mini .sidebar .menu-icon-right {
    display: none !important;
}

/* Sembunyikan semua submenu */
body.sidebar-mini .sidebar .submenu-container {
    display: none !important;
}

/* Sembunyikan section labels (div inline-style dalam nav) */
body.sidebar-mini .sidebar nav>div[style] {
    display: none;
}

/* Sembunyikan brand text (span setelah div ikon brand) */
body.sidebar-mini .sidebar>div:first-of-type>span {
    display: none;
}

body.sidebar-mini .sidebar>div:first-of-type {
    justify-content: center;
    padding: 16px 0 12px;
    border-bottom: 1.5px solid var(--sb-border);
}

/* Sembunyikan teks user profile */
body.sidebar-mini .sidebar .user-profile-mini>div:last-child {
    display: none;
}

body.sidebar-mini .sidebar .user-profile-mini {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
}

/* Kompakkan nav padding */
body.sidebar-mini .sidebar .sidebar-menu {
    padding: 4px 6px 24px;
}

/* Tooltip saat hover (butuh data-tooltip di HTML) */
body.sidebar-mini .sidebar .menu-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: fixed;
    left: 70px;
    background: #1e1b4b;
    color: white;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.sidebar-mini .sidebar .menu-item[data-tooltip]:hover::after {
    opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 265px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}