/* ============================================================
   sidebar.css — SIPDAM Sidebar Toggle
   ============================================================ */

:root {
    --sb-green:    #1a7a4a;
    --sb-green-m:  #2d9e63;
    --sb-green-l:  #e8f7ee;
    --sb-green-l2: #d0eedd;
    --sb-rose:     #dc2626;
    --sb-rose-l:   #fff1f2;
    --sb-border:   #d1e8da;
    --sb-t1:       #0f172a;
    --sb-t2:       #334155;
    --sb-t3:       #64748b;
    --sb-t4:       #94a3b8;
    --sb-font:     'Figtree', 'Segoe UI', sans-serif;
    --sb-width:    190px;
    --sb-collapsed-width: 68px;
}

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

/* ── Main Wrapper ── */
.main-wrapper {
    flex: 1;
    margin-left: var(--sb-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    background: #f0f7f3;
}

.main-wrapper.sb-collapsed {
    margin-left: var(--sb-collapsed-width);
}

/* ── Base Sidebar ── */
.sb {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sb-width);
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 1px solid var(--sb-border);
    box-shadow: 4px 0 24px rgba(26, 122, 74, 0.08);
    transition: width 0.3s ease;
    overflow: hidden;
    font-family: var(--sb-font);
}

.sb.sb-collapsed {
    width: var(--sb-collapsed-width);
}

/* ── Logo Header ── */
.sb-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 12px;
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--sb-green) 0%, var(--sb-green-m) 100%);
    min-height: 76px;
    overflow: hidden;
    white-space: nowrap;
}

.sb-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
}

.sb-wordmark {
    overflow: hidden;
    transition: opacity 0.2s ease, width 0.3s ease;
    white-space: nowrap;
}

.sb.sb-collapsed .sb-wordmark {
    opacity: 0;
    width: 0;
}

.sb-wordmark-main {
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.02em;
    line-height: 1;
}

.sb-wordmark-sub {
    font-size: 10px;
    color: rgba(255,255,255,0.65);
    margin-top: 3px;
}

/* ── Navigation ── */
.sb-nav {
    padding: 14px 8px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    list-style: none;
    margin: 0;
}

.sb-nav::-webkit-scrollbar { display: none; }

/* Section label */
.menu-section {
    font-size: 10px;
    font-weight: 700;
    color: var(--sb-t4);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 12px 8px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.sb.sb-collapsed .menu-section {
    opacity: 0;
    height: 0;
    padding: 0;
}

/* Nav links */
.sb-nav > li > a,
.sb-nav > li > .menu-parent {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sb-t2);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--sb-font);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    text-align: left;
    box-sizing: border-box;
    white-space: nowrap;
    margin-bottom: 2px;
}

.sb-nav > li > a:hover,
.sb-nav > li > .menu-parent:hover {
    background: var(--sb-green-l);
    color: var(--sb-green);
}

.sb-nav > li > a.active,
.sb-nav > li.active > .menu-parent {
    background: var(--sb-green-l);
    color: var(--sb-green);
    font-weight: 700;
}

/* Icon */
.sb-nav > li > a > i:first-child,
.sb-nav > li > .menu-parent > i:first-child {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    transition: background 0.15s;
}

.sb-nav > li > a.active > i:first-child,
.sb-nav > li > a:hover > i:first-child,
.sb-nav > li.active > .menu-parent > i:first-child,
.sb-nav > li > .menu-parent:hover > i:first-child {
    background: var(--sb-green-l2);
    color: var(--sb-green);
}

/* Label span */
.sb-nav > li > a > span,
.sb-nav > li > .menu-parent > span {
    flex: 1;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.sb.sb-collapsed .sb-nav > li > a > span,
.sb.sb-collapsed .sb-nav > li > .menu-parent > span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Toggle chevron */
.toggle-icon {
    font-size: 10px;
    color: var(--sb-t4);
    margin-left: auto;
    transition: transform 0.25s, opacity 0.2s;
    flex-shrink: 0;
}

.menu-toggle.active > .menu-parent > .toggle-icon {
    transform: rotate(180deg);
}

.sb.sb-collapsed .toggle-icon {
    opacity: 0;
    width: 0;
}

/* ── Submenu ── */
.menu-toggle { margin-bottom: 2px; }

.submenu {
    list-style: none;
    padding-left: 10px;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.menu-toggle.active > .submenu {
    max-height: 400px;
}

.sb.sb-collapsed .submenu {
    max-height: 0 !important;
}

.submenu > li > a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--sb-t2);
    font-family: var(--sb-font);
    text-decoration: none;
    margin-bottom: 2px;
    transition: background 0.15s, color 0.15s;
    border-left: 2px solid transparent;
    white-space: nowrap;
}

.submenu > li > a:hover {
    background: var(--sb-green-l);
    color: var(--sb-green);
    border-left-color: var(--sb-green-l2);
}

.submenu > li > a.active {
    background: var(--sb-green-l);
    color: var(--sb-green);
    font-weight: 700;
    border-left-color: var(--sb-green);
}

.submenu > li > a > i {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Toggle Button ── */
.sb-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--sb-green-l);
    border: none;
    color: var(--sb-green);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.sb-toggle-btn:hover {
    background: var(--sb-green-l2);
}

/* ── Topbar ── */
.main-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid var(--sb-border);
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--sb-green-l);
    color: var(--sb-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.topbar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--sb-t1);
}

.topbar-sub {
    font-size: 12px;
    color: var(--sb-t3);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.clock-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--sb-green-l);
    border: 1px solid var(--sb-border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--sb-green);
}

.dot-live {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Main Content ── */
.main-content {
    padding: 24px;
}

/* ── User Profile Bottom ── */
.sb-bottom {
    flex-shrink: 0;
    border-top: 1px solid var(--sb-border);
    background: #f0f7f3;
    padding: 12px;
    overflow: hidden;
}

.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.sb-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--sb-green), var(--sb-green-m));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    font-family: var(--sb-font);
}

.sb-user-info {
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.sb.sb-collapsed .sb-user-info {
    opacity: 0;
    width: 0;
}

.sb-user-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--sb-t1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-user-email {
    font-size: 10px;
    color: var(--sb-t3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.sb-logout-btn {
    width: 100%;
    margin-top: 10px;
    padding: 9px;
    border-radius: 10px;
    background: var(--sb-rose-l);
    border: 1px solid #fca5a5;
    color: var(--sb-rose);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--sb-font);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.sb.sb-collapsed .sb-logout-btn span {
    display: none;
}

.sb-logout-btn:hover {
    background: #fecaca;
    border-color: var(--sb-rose);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sb {
        transform: translateX(-100%);
        width: var(--sb-width) !important;
    }
    .sb.sb-mobile-open {
        transform: translateX(0);
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
}