/* ========================================
   GreenStep Hub - Sidebar Styles
   Modern Dark Sidebar Navigation
   ======================================== */

/* Main Layout with Sidebar */
.app-layout {
    display: flex;
    min-height: 100vh;
    direction: rtl;
}

/* Sidebar Container */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 1000;
    transition: width var(--transition-normal);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

/* Sidebar Header / Logo */
.sidebar-header {
    padding: 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.sidebar-logo-icon {
    font-size: 1.5rem;
}

.sidebar-logo-img {
    width: 80px;
    height: auto;
}

.sidebar-logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--green);
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--text3);
    margin-top: 0.3rem;
}

/* Navigation Menu */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 0.5rem;
    padding: 0;
}

.nav-section-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--green);
    padding: 0.5rem 1rem 0.3rem;
    margin: 0;
    letter-spacing: 0.5px;
    line-height: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    margin: 0.1rem 0;
    color: var(--green);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-right: 3px solid transparent;
    font-size: 0.85rem;
    line-height: 1.3;
}

.nav-item:hover {
    background: rgba(0, 104, 56, 0.1);
    color: var(--green);
}

.nav-item.active {
    background: rgba(0, 104, 56, 0.15);
    color: var(--green);
    border-right-color: var(--green);
    font-weight: 600;
}

.nav-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    flex-shrink: 0;
}

.nav-item-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Collapsible sidebar groups (מחלקות / מודולים) */
.nav-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem 0.3rem;
    cursor: pointer;
    user-select: none;
}

.nav-group-head .nav-section-title {
    padding: 0;
}

.nav-group-head .nav-group-chev {
    color: var(--green);
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
}

.nav-group.collapsed .nav-group-chev {
    transform: rotate(-90deg);
}

.nav-group.collapsed .nav-list {
    display: none;
}

/* Department/module landing page */
.dept-landing-header {
    margin-bottom: 1.25rem;
}

.dept-landing-header h1 {
    font-size: 1.3rem;
    color: var(--text);
    margin: 0 0 0.25rem;
}

.dept-landing-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.dept-landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.dept-landing-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.dept-landing-card:hover {
    border-color: var(--green-lime);
    box-shadow: var(--shadow-md);
}

.dept-landing-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--green-light);
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dept-landing-card-label {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 600;
}

.dept-landing-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sidebar-logout svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-item-text {
    flex: 1;
}

.nav-item-badge {
    background: var(--orange);
    color: white;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-weight: 600;
}

/* Highlight style - now same as regular items */
.nav-item.highlight {
    background: transparent;
    color: var(--green);
    border-radius: 0;
    margin: 0.1rem 0;
    padding: 0.5rem 1rem;
    border-right: 3px solid transparent;
}

.nav-item.highlight:hover {
    background: rgba(0, 104, 56, 0.1);
    color: var(--green);
    transform: none;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: rgba(0, 104, 56, 0.1);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: var(--green);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.sidebar-user-info {
    flex: 1;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--green);
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--text2);
}

/* Logout button */
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    color: var(--text2);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

/* Main Content Area */
.main-content {
    flex: 1;
    min-width: 0; /* let it shrink below its content's natural width — otherwise a flex
                     item defaults to min-width:auto, so any wide nested content (a table
                     with nowrap headers, etc.) forces the whole layout wider than the
                     viewport instead of scrolling inside its own container. */
    margin-right: var(--sidebar-width);
    background: var(--bg);
    min-height: 100vh;
    transition: margin-right var(--transition-normal);
}

/* Mobile/Tablet Sidebar - push pattern from 1024px */
@media (max-width: 1024px) {
    /* Prevent horizontal scroll from off-screen sidebar */
    html, body {
        overflow-x: hidden;
    }

    .sidebar {
        transform: translateX(100%);
        width: var(--sidebar-width);
        visibility: hidden;
    }

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

    .main-content {
        margin-right: 0;
        transition: transform var(--transition-normal);
    }

    /* Push page content when sidebar opens */
    body.sidebar-open .main-content {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    /* Mobile Menu Toggle - prominent bar */
    .mobile-menu-toggle {
        display: flex;
        position: fixed;
        top: 0.75rem;
        right: 0.75rem;
        z-index: 1001;
        background: var(--bg-sidebar);
        color: white;
        height: 48px;
        padding: 0 16px;
        border-radius: 12px;
        align-items: center;
        justify-content: center;
        gap: 8px;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        font-size: 0.85rem;
        font-weight: 600;
    }

    .mobile-menu-toggle .menu-icon {
        font-size: 1.3rem;
        line-height: 1;
    }

    /* Also move the toggle button when sidebar is open */
    body.sidebar-open .mobile-menu-toggle {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .sidebar-logo-text,
    .sidebar-subtitle,
    .nav-section-title,
    .nav-item-text,
    .nav-item-badge,
    .sidebar-user-info {
        display: block;
    }

    .nav-item {
        justify-content: flex-start;
        padding: 0.5rem 1rem;
    }
}

/* Sidebar Overlay for Mobile - covers only the page content, not the sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: var(--sidebar-width);
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    pointer-events: none;
}

.sidebar-overlay.active {
    display: block;
    pointer-events: auto;
}

/* ========================================
   Coordinator mode — no side-nav (per Ortal, 2026-08-12: a coordinator has at most a
   handful of screens, all reachable as tiles on CoordinatorHome — a full side-nav just
   duplicates the same links and eats width on the phone screens this role mainly uses).
   The sidebar becomes a slim fixed top bar instead: logo doubles as the home button
   (see js/sidebar.js setupEventListeners), notification bell + logout stay in it.
   ======================================== */
body.coordinator-mode .sidebar {
    width: 100%;
    height: 56px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    transform: none;
    visibility: visible;
}

body.coordinator-mode .sidebar-header {
    padding: 0 1rem;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

/* Bell's own label text ("משימות חדשות") doesn't fit a 56px-tall bar next to the logo —
   icon + red count badge carries the same information. */
body.coordinator-mode .bell-label {
    display: none;
}

body.coordinator-mode .sidebar-logo-img {
    width: 36px;
}

body.coordinator-mode .sidebar-logo-text {
    display: none;
}

body.coordinator-mode .sidebar-nav {
    display: none;
}

body.coordinator-mode .sidebar-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
    border-top: none;
}

/* Name/role already shown in the CoordinatorHome greeting — avatar alone is enough
   here, saves space on a phone-width bar. */
body.coordinator-mode .sidebar-user-info {
    display: none;
}

body.coordinator-mode .sidebar-logout {
    margin-top: 0;
}

body.coordinator-mode .main-content {
    margin-right: 0;
    margin-top: 56px;
}

body.coordinator-mode .mobile-menu-toggle {
    display: none !important;
}
