/**
 * Sidebar Navigation Styles
 * RTL support for Hebrew text
 */

/* Sidebar Container */
.sidebar-container {
    position: relative;
    z-index: 1500;
}

/* Sidebar Navigation */
.sidebar-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    box-shadow: -2px 0 15px rgba(16, 185, 129, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1600;
    overflow-y: auto;
    direction: rtl;
}

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

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-header h3 {
    color: white;
    font-size: 1.3rem;
    margin: 0;
    font-weight: bold;
}

.sidebar-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.sidebar-close:hover {
    transform: scale(1.2);
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
    gap: 15px;
}

.sidebar-menu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    padding-left: 25px;
}

.sidebar-menu-item-active .sidebar-menu-link {
    background: rgba(255, 255, 255, 0.2);
    border-left: 4px solid white;
}

/* Mirror directional icons for RTL */
.sidebar-menu-icon {
    font-size: 1.5rem;
    min-width: 30px;
    text-align: center;
}

/* Ensure arrows and directional elements are mirrored */
.sidebar-menu-link[data-direction="ltr"] .sidebar-menu-icon {
    transform: scaleX(-1);
}

.sidebar-menu-label {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Sidebar Toggle Button (Hamburger Menu) */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(16, 185, 129, 0.95);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 1700;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    transition: all 0.3s ease-in-out;
    backdrop-filter: blur(10px);
}

.sidebar-toggle:hover {
    background: rgba(5, 150, 105, 1);
    transform: scale(1.05);
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.sidebar-toggle-active .hamburger-line:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.sidebar-toggle-active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.sidebar-toggle-active .hamburger-line:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1550;
}

.sidebar-overlay-active {
    opacity: 1;
    visibility: visible;
}

/* Desktop View (>= 768px) */
@media (min-width: 768px) {
    .sidebar-nav {
        transform: translateX(0);
    }
    
    /* When sidebar is closed on desktop */
    .sidebar-nav:not(.sidebar-open) {
        transform: translateX(100%);
    }

    .sidebar-toggle {
        display: flex; /* Show toggle button on desktop too */
        right: 20px;
        transition: right 0.3s ease-in-out;
    }
    
    /* Move toggle button when sidebar is open */
    body:not(.sidebar-closed) .sidebar-toggle {
        right: 300px;
    }

    .sidebar-overlay {
        display: none;
    }

    .sidebar-close {
        display: none;
    }

    /* Adjust main content to account for sidebar when open */
    body:not(.sidebar-closed) .video-container,
    body:not(.sidebar-closed) .content-section,
    body:not(.sidebar-closed) .announcements-section,
    body:not(.sidebar-closed) #contentDisplay,
    body:not(.sidebar-closed) .content-section-display {
        margin-right: 280px;
        transition: margin-right 0.3s ease-in-out;
    }
    
    /* When sidebar is closed on desktop */
    body.sidebar-closed .video-container,
    body.sidebar-closed .content-section,
    body.sidebar-closed .announcements-section,
    body.sidebar-closed #contentDisplay,
    body.sidebar-closed .content-section-display {
        margin-right: 0;
        transition: margin-right 0.3s ease-in-out;
    }
}

/* Mobile View (< 768px) */
@media (max-width: 767px) {
    .sidebar-nav {
        width: 280px;
        max-width: 85vw;
    }

    .sidebar-toggle {
        display: flex;
    }

    /* Ensure sidebar is above other fixed elements on mobile */
    .sidebar-nav.sidebar-open {
        z-index: 1600;
    }
}

/* Small Mobile View (< 480px) */
@media (max-width: 480px) {
    .sidebar-nav {
        width: 100%;
        max-width: 100vw;
    }

    .sidebar-header h3 {
        font-size: 1.1rem;
    }

    .sidebar-menu-link {
        padding: 15px 18px;
    }

    .sidebar-menu-icon {
        font-size: 1.3rem;
    }

    .sidebar-menu-label {
        font-size: 1rem;
    }

    .sidebar-toggle {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
    }

    .hamburger-line {
        width: 22px;
    }
}

/* Accessibility */
.sidebar-toggle:focus,
.sidebar-close:focus,
.sidebar-menu-link:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Smooth scrolling for sidebar */
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

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

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Animation for menu items */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar-nav.sidebar-open .sidebar-menu-item {
    animation: slideInFromRight 0.3s ease-out forwards;
}

.sidebar-nav.sidebar-open .sidebar-menu-item:nth-child(1) { animation-delay: 0.05s; }
.sidebar-nav.sidebar-open .sidebar-menu-item:nth-child(2) { animation-delay: 0.1s; }
.sidebar-nav.sidebar-open .sidebar-menu-item:nth-child(3) { animation-delay: 0.15s; }
.sidebar-nav.sidebar-open .sidebar-menu-item:nth-child(4) { animation-delay: 0.2s; }
.sidebar-nav.sidebar-open .sidebar-menu-item:nth-child(5) { animation-delay: 0.25s; }
.sidebar-nav.sidebar-open .sidebar-menu-item:nth-child(6) { animation-delay: 0.3s; }
.sidebar-nav.sidebar-open .sidebar-menu-item:nth-child(7) { animation-delay: 0.35s; }
