/* ???????????????????????????????????????????????????????????????????????????
   CARD IN CLOUD - Modern Soft Sidebar with Logo on Collapse
   ??????????????????????????????????????????????????????????????????????????? */

/* ???????????????????????????????????????????????????????????????????????????
   1. SIDEBAR CONTAINER
   ??????????????????????????????????????????????????????????????????????????? */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, #1E1B4B 0%, #111827 100%);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    backface-visibility: hidden;
}

    .sidebar.collapsed {
        width: 64px;
    }

/* ???????????????????????????????????????????????????????????????????????????
   2. SIDEBAR HEADER - Modern Soft Design
   ??????????????????????????????????????????????????????????????????????????? */
.sidebar-header {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    flex-shrink: 0;
    position: relative;
    transition: justify-content 0.3s ease;
    background: rgba(255, 255, 255, 0.03);
}

.sidebar:not(.collapsed) .sidebar-header {
    justify-content: space-between;
}

/* Brand Container */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-brand {
    gap: 0;
}

.sidebar-brand:hover {
    color: var(--text-light);
}

/* Brand Icon - Always visible with soft glow */
.sidebar-brand-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.2);
}

.sidebar.collapsed .sidebar-brand-icon {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.3);
}

.sidebar-brand-icon:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.sidebar-brand-icon img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Brand Text - Hidden when collapsed */
.sidebar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    background: linear-gradient(135deg, #fff 0%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: opacity 0.3s ease, width 0.3s ease;
    letter-spacing: 0.5px;
}

.sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
}

/* Collapse Toggle Button - Soft modern style */
.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-collapse-btn {
    opacity: 0;
    width: 0;
    overflow: hidden;
    padding: 0;
    border: none;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.2);
}

.sidebar-collapse-btn i {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* Expand hint on collapsed logo */
.sidebar.collapsed .sidebar-brand-icon::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 8px;
    color: var(--text-light);
    content: '\f054';
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-brand:hover .sidebar-brand-icon::after {
    opacity: 1;
}

/* ???????????????????????????????????????????????????????????????????????????
   3. NAVIGATION - Modern Soft
   ??????????????????????????????????????????????????????????????????????????? */
.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

    .sidebar-nav::-webkit-scrollbar {
        width: 4px;
    }

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

    .sidebar-nav::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    .sidebar-nav ul {
        list-style: none;
        margin: 0;
        padding: 0 0.75rem;
    }

    .sidebar-nav li {
        margin-bottom: 4px;
    }

/* ???????????????????????????????????????????????????????????????????????????
   4. NAVIGATION LINKS - Modern Soft Design
   ??????????????????????????????????????????????????????????????????????????? */
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    white-space: nowrap;
    letter-spacing: 0.1px;
}

    .nav-link i:first-child {
        width: 18px;
        text-align: center;
        font-size: 0.9rem;
        flex-shrink: 0;
        opacity: 0.85;
        transition: all 0.2s ease;
    }

    .nav-link span {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        transition: opacity 0.3s ease;
    }

.sidebar.collapsed .nav-link span {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.625rem;
}

.nav-link:hover {
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

    .nav-link:hover i:first-child {
        opacity: 1;
        transform: scale(1.1);
    }

.nav-link.active {
    color: var(--text-light);
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.8) 0%, rgba(var(--accent-rgb), 0.8) 100%);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

    .nav-link.active i:first-child {
        opacity: 1;
    }

    .nav-link.active::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 4px;
        height: 60%;
        background: var(--accent-light);
        border-radius: 0 4px 4px 0;
    }

.sidebar.collapsed .nav-link {
    transform: none;
}

.sidebar.collapsed .nav-link:hover {
    transform: scale(1.05);
}

.sidebar.collapsed .nav-link.active::before {
    display: none;
}

/* Locked state */
.nav-link.nav-locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-link.nav-locked:hover {
    transform: none;
    background: transparent;
}

/* Tooltip for collapsed state */
.sidebar.collapsed .nav-link {
    position: relative;
}

    .sidebar.collapsed .nav-link::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 16px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--background-dark);
        color: var(--text-light);
        padding: 0.625rem 0.875rem;
        border-radius: 10px;
        font-size: 0.8125rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 1001;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    }

    .sidebar.collapsed .nav-link:hover::after {
        opacity: 1;
    }

/* ???????????????????????????????????????????????????????????????????????????
   5. SIDEBAR FOOTER - Modern Soft Design
   ??????????????????????????????????????????????????????????????????????????? */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.sidebar-footer-content {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    transition: justify-content 0.3s ease;
}

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

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-light);
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(var(--primary-rgb), 0.3);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.1px;
}

.sidebar-user-role {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ???????????????????????????????????????????????????????????????????????????
6. MOBILE OVERLAY
??????????????????????????????????????????????????????????????????????????? */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
    -webkit-tap-highlight-color: transparent;
}

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

/* ???????????????????????????????????????????????????????????????????????????
7. MOBILE TOGGLE BUTTON
??????????????????????????????????????????????????????????????????????????? */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s ease;
}

    .sidebar-toggle:hover {
        background: var(--background-light);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-toggle:active {
        transform: scale(0.95);
    }

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

    .hamburger span {
        display: block;
        width: 18px;
        height: 2px;
        background: currentColor;
        border-radius: 2px;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

.sidebar-toggle.active .hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.sidebar-toggle.active .hamburger span:nth-child(2) {
    opacity: 0;
}

.sidebar-toggle.active .hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* ???????????????????????????????????????????????????????????????????????????
   8. RESPONSIVE - DESKTOP
   ??????????????????????????????????????????????????????????????????????????? */
@media (min-width: 769px) {
    .app-wrapper .main-content-wrapper {
        margin-left: 220px;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .app-wrapper .sidebar.collapsed ~ .main-content-wrapper {
        margin-left: 64px;
    }
}

/* ???????????????????????????????????????????????????????????????????????????
9. RESPONSIVE - MOBILE
??????????????????????????????????????????????????????????????????????????? */
@media (max-width: 768px) {
.sidebar {
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    will-change: transform;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
}

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: 220px;
    }

    .sidebar-collapse-btn {
        display: none;
    }

    .sidebar-toggle {
        display: flex;
    }

        .sidebar-toggle.active {
            opacity: 0;
            pointer-events: none;
        }

    .sidebar-overlay {
        display: block;
        will-change: opacity;
    }

    .main-content-wrapper {
        margin-left: 0 !important;
    }
}

/* ???????????????????????????????????????????????????????????????????????????
10. REDUCE MOTION
??????????????????????????????????????????????????????????????????????????? */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-overlay,
    .nav-link,
    .hamburger span {
        transition: none !important;
    }
}
