/* ============================================================
   Sakani Pro CRM — Unified Sidebar Styles
   Shared across all /public/crm/ pages.
   Supports both .nav-link and .nav-item class systems.
   ============================================================ */

/* ====== SIDEBAR CONTAINER ====== */
.sidebar {
    width: 260px;
    min-width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    background: linear-gradient(180deg, #0f1d33 0%, #0A1628 100%);
    border-right: 1px solid rgba(212, 175, 55, 0.1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, width;

    /* Firefox scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.2) transparent;
}

/* Webkit scrollbar */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(212, 175, 55, 0.2);
    border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(212, 175, 55, 0.4);
}

/* RTL */
html[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid rgba(212, 175, 55, 0.1);
}

/* ====== COLLAPSED STATE ====== */
.sidebar.collapsed {
    width: 72px;
    min-width: 72px;
}
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .nav-section-title {
    display: none;
}
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}
.sidebar.collapsed .nav-icon {
    margin-right: 0;
    margin-left: 0;
}
.sidebar.collapsed .user-profile-card {
    padding: 12px 8px;
    justify-content: center;
}
.sidebar.collapsed .user-avatar-sidebar {
    margin-right: 0;
}
html[dir="rtl"] .sidebar.collapsed ~ .main-content {
    margin-left: 0;
    margin-right: 72px;
}

/* ====== NAV-LINK SYSTEM (primary — 40+ pages) ====== */
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    font-size: 0.835rem;
    color: #94A3B8;
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
    position: relative;
}
.nav-link i,
.nav-link svg {
    width: 1.25rem;
    min-width: 1.25rem;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.nav-link:hover {
    color: #D4AF37;
    background: rgba(212, 175, 55, 0.05);
    border-left-color: rgba(212, 175, 55, 0.3);
}
.nav-link:hover i,
.nav-link:hover svg {
    transform: scale(1.1);
}
.nav-link.active {
    color: #D4AF37;
    background: rgba(212, 175, 55, 0.08);
    border-left-color: #D4AF37;
    font-weight: 600;
}
.nav-link:focus-visible {
    outline: 2px solid rgba(212, 175, 55, 0.5);
    outline-offset: -2px;
    border-radius: 4px;
}

/* RTL nav-link */
html[dir="rtl"] .nav-link {
    border-left: none;
    border-right: 3px solid transparent;
}
html[dir="rtl"] .nav-link:hover {
    border-right-color: rgba(212, 175, 55, 0.3);
    border-left-color: transparent;
}
html[dir="rtl"] .nav-link.active {
    border-right-color: #D4AF37;
    border-left-color: transparent;
}

/* ====== NAV-ITEM SYSTEM (alternative — portals, marketing) ====== */
.nav-item {
    display: flex;
    align-items: center;
    padding: 9px 16px;
    margin: 1px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    color: #94a3b8;
    text-decoration: none;
    white-space: nowrap;
    font-size: 13.5px;
}
.nav-item:hover {
    background: rgba(45, 62, 95, 0.5);
    color: #e2e8f0;
}
.nav-item.active {
    background: rgba(0, 212, 170, 0.12);
    color: #00D4AA;
    font-weight: 600;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    background: #00D4AA;
    border-radius: 0 3px 3px 0;
}
.nav-item:focus-visible {
    outline: 2px solid rgba(0, 212, 170, 0.5);
    outline-offset: -2px;
}

/* RTL nav-item */
html[dir="rtl"] .nav-item.active::before {
    left: auto;
    right: -10px;
    border-radius: 3px 0 0 3px;
}

/* ====== NAV ICON (for nav-item system) ====== */
.nav-icon {
    width: 18px;
    min-width: 18px;
    text-align: center;
    margin-right: 12px;
    font-size: 14px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
html[dir="rtl"] .nav-icon {
    margin-right: 0;
    margin-left: 12px;
}
.nav-item:hover .nav-icon {
    transform: scale(1.1);
}

/* ====== NAV BADGE ====== */
.nav-badge {
    margin-left: auto;
    background: linear-gradient(135deg, #D4AF37, #B8941F);
    color: #0A1628;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}
html[dir="rtl"] .nav-badge {
    margin-left: 0;
    margin-right: auto;
}

/* ====== SECTION TITLES ====== */

/* nav-section-title (nav-link system) */
.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(212, 175, 55, 0.6);
    padding: 16px 20px 6px;
    transition: opacity 0.2s ease;
}

/* sidebar-section-label (nav-item system) */
.sidebar-section-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(212, 175, 55, 0.5);
    padding: 14px 18px 4px;
    transition: opacity 0.2s ease;
}

/* ====== NOTIFICATION BADGE (topbar) ====== */
.notif-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: linear-gradient(135deg, #D4AF37, #B8941F);
    color: #0A1628;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    border: 2px solid #0A1628;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}
html[dir="rtl"] .notif-badge {
    right: auto;
    left: -8px;
}

/* ====== MAIN CONTENT ====== */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
html[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: 260px;
}
.sidebar.collapsed ~ .main-content {
    margin-left: 72px;
}

/* ====== SIDEBAR OVERLAY (mobile) ====== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 45;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.sidebar-overlay.show,
.sidebar-overlay.active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* ====== MOBILE RESPONSIVE ====== */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
    html[dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    /* Open states */
    .sidebar.mobile-open,
    .sidebar.open {
        transform: translateX(0) !important;
    }

    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Prevent body scroll when sidebar open */
    body.sidebar-open {
        overflow: hidden;
    }
}

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0) !important;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* Better touch targets on mobile */
@media (max-width: 1023px) {
    .nav-link {
        padding: 12px 20px;
    }
    .nav-item {
        padding: 12px 16px;
    }
    .nav-section-title {
        padding: 18px 20px 6px;
    }
    .sidebar-section-label {
        padding: 18px 18px 4px;
    }
}

/* Wider sidebar on tablets */
@media (min-width: 640px) and (max-width: 1023px) {
    .sidebar {
        width: 280px;
    }
}
