/* אייקונים בתוך כפתורים יורשים את צבע הטקסט (במקום צבע type קבוע) — קונטרסט נכון על רקע מלא */
.btn svg,
.notif-action-btn svg {
    stroke: currentColor !important;
    flex-shrink: 0;
    vertical-align: middle;
}

.request-action-status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid transparent;
    line-height: 1.5;
}

.request-action-status-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.request-action-status-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #6ee7b7;
}

.request-action-status-error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.request-action-next {
    margin-top: 4px;
    font-weight: 600;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-warning {
    background: var(--color-warning);
    color: white;
}

.btn-refresh {
    background: linear-gradient(135deg, #4a6580 0%, #3a516f 55%, #2b415b 100%);
    color: white;
    border-radius: 50px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(43,65,91,.22);
    position: relative;
    overflow: hidden;
}

.btn-refresh::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.25s;
}

.btn-refresh:hover::after {
    opacity: 1;
}

.btn-refresh:hover {
    box-shadow: 0 4px 16px rgba(43,65,91,.35);
    transform: translateY(-1px);
}

.btn-refresh:active {
    transform: translateY(0);
    box-shadow: 0 1px 5px rgba(43,65,91,.2);
}

.btn-refresh .refresh-icon {
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-refresh:hover .refresh-icon {
    transform: rotate(200deg);
}

/* Settings tab bar — pill style */
/* הפריסה הישנה (שורת גלולות אופקית) הוסרה: הניווט הוא כעת סיידבר מקובץ,
   ו-#settingsSubNav כסלקטור מזהה היה גובר על .settings-nav ומחזיר אותו
   ל-display:flex. העיצוב חי כולו ב-.settings-nav. */

.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1.5px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.settings-tab:hover {
    border-color: #667eea;
    color: #5a67d8;
    background: #eef2ff;
}
.settings-tab.active {
    background: #5a67d8;
    border-color: #5a67d8;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102,126,234,0.35);
}

/* ─── הגדרות: פריסת סיידבר מקובץ ───
   מחליף את שורת הטאבים השטוחה. הניווט מקובץ לפי רמה (אישי / ארגון /
   מודול / מערכת) כדי שכל פריט יימצא לפי "של מי זה", לא לפי מבנה הנתונים.

   ההגדרות הן "מצב" ולא עוד מסך: בכניסה אליהן התפריט הראשי מתחלף בניווט
   ההגדרות (body.in-settings), כך שיש תמיד עמודת ניווט אחת ולא שתיים
   צמודות שמתחרות על תשומת הלב. היציאה דרך כפתור "חזרה למערכת". */
.settings-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

/* רק בדסקטופ: שם התפריט הראשי הוא עמודה אנכית שמתחרה בניווט ההגדרות.
   במובייל (≤768px) הוא ממילא שורת צ'יפים אופקית בראש המסך — אין תחרות,
   והסתרתו רק הייתה לוקחת את הניווט היחיד שיש. */
@media (min-width: 769px) {
    body.in-settings .sidebar {
        display: none;
    }
    /* הקיזוז שייך לסיידבר שהוסתר, ולכן חייב להתבטל באותה נקודת שבירה. כשהוא
       ישב יחד עם מעטפת הגובה (861px) נותר ברצועה 769–860 מרווח של 220px
       לסיידבר שאינו מוצג, והתוכן נדחק הצידה. */
    body.in-settings .main-content {
        margin-right: 0;
    }
}

/* ─── גלילה בעמודת התוכן בלבד ───
   העמוד עצמו לא נגלל בהגדרות: הכותרת והניווט קבועים, ורק עמודת התוכן
   גוללת. שרשרת של flex עם min-height:0 בכל חוליה — בלי זה פריט flex
   מסרב להתכווץ מתחת לגובה תוכנו והגלילה בורחת חזרה לעמוד.

   מ-861px ולא מ-769px: מתחת לכך .settings-layout נערם לעמודה אחת
   (‎@media max-width:860px‎), והניווט יושב מעל התוכן. מעטפת בגובה קבוע על
   פריסה ערומה חותכת את התוכן התחתון בלי שום גלילה להגיע אליו. */
@media (min-width: 861px) {
    body.in-settings {
        overflow: hidden;
    }
    body.in-settings .main-content {
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    body.in-settings #settingsSection.active {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    body.in-settings #settingsSection .top-bar {
        flex-shrink: 0;
    }
    body.in-settings .settings-layout {
        flex: 1;
        min-height: 0;
        /* דורס את align-items:start של הפריסה הרגילה. בלי stretch העמודות
           מקבלות את גובה תוכנן ולא את גובה השורה, ואז overflow לא נכנס
           לפעולה — הגלילה בורחת חזרה לעמוד. */
        align-items: stretch;
    }
    body.in-settings .settings-nav,
    body.in-settings .settings-content {
        min-height: 0;
        overflow-y: auto;
    }
    body.in-settings .settings-content {
        overscroll-behavior: contain;
        /* מרווח לפס הגלילה כדי שלא ידרוס את שולי הכרטיסים */
        padding-left: 4px;
    }
}

.settings-nav-back {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    margin-bottom: 8px;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    border-radius: 8px 8px 0 0;
    background: transparent;
    color: #5a67d8;
    font-size: 13px;
    font-weight: 650;
    font-family: inherit;
    text-align: start;
    cursor: pointer;
    transition: background 0.15s;
}
.settings-nav-back:hover {
    background: #eef2ff;
}
.settings-nav-back svg {
    flex-shrink: 0;
}

.settings-nav {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    /* שומר מקום לפס הגלילה גם כשאין בו צורך, אחרת הופעתו והיעלמותו
       מזיזה את פריטי הניווט הצידה בכל החלפת כרטיס. */
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
}

.settings-nav-group + .settings-nav-group {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}

.settings-nav-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 6px 10px 4px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #475569;
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    text-align: start;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.settings-nav-item:hover {
    background: #f1f5f9;
    color: #334155;
}
.settings-nav-item.active {
    background: #eef2ff;
    color: #4c51bf;
    font-weight: 650;
    box-shadow: inset 3px 0 0 #5a67d8;
}
.settings-nav-item:focus-visible {
    outline: 2px solid #5a67d8;
    outline-offset: -2px;
}

/* ─── מתג מודולים ברמת הארגון ───
   כיבוי מודול מסתיר כל אלמנט שנושא data-module תואם — פריטי תפריט,
   קבוצות בהגדרות וכרטיסים. משתמש במחלקה על <body> ולא ב-style ישיר
   כדי לא להתנגש בלוגיקת ההצגה לפי תפקיד, שכותבת style.display בעצמה. */
body.module-procurement-off [data-module="procurement"],
body.module-activities-off [data-module="activities"] {
    display: none !important;
}

/* סקירת הפעילויות בדאשבורד: כל שאר תוכן המסך שייך לרכש, ולכן היא מחליפה
   אותו כשהמודול כבוי. אינה נושאת data-module="activities" בכוונה — היא תלויה
   בכיבוי הרכש, לא בהדלקת הפעילויות, ובארגון ששני המודולים דלוקים בו הדאשבורד
   נשאר בדיוק כפי שהוא. */
#dashboardActivitiesOnly {
    display: none;
}
body.module-procurement-off #dashboardActivitiesOnly {
    display: block;
}

/* מובייל: הסיידבר נופל לרשימה ברוחב מלא מעל התוכן */
@media (max-width: 860px) {
    .settings-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .settings-nav {
        position: static;
        max-height: none;
    }
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

/* Main */
.main-app {
    display: none;
}

.main-app.active {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #3a4a63 0%, #2f3e56 100%);
    color: white;
    padding: 16px 0 0;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: -1px 0 2px rgba(2, 6, 23, 0.08);
}

.sidebar-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0 8px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 4px 16px 12px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-header:hover {
    opacity: 0.85;
}

.sidebar-header h2 {
    font-size: 11.5px;
    font-weight: 500;
    margin-bottom: 0;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    transition: opacity 0.2s, max-height 0.2s;
}

.sidebar-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 12px;
    margin-bottom: 8px;
    background: #ffffff;
    padding: 2px;
    border: 1px solid rgba(218, 228, 242, 0.85);
    box-shadow: 0 4px 12px rgba(10, 22, 39, 0.28);
    transition: width 0.25s, height 0.25s, border-radius 0.25s, margin 0.25s;
}

.sidebar-header {
    flex-shrink: 0;
}

/* Toggle button */
.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    padding: 8px 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s, background 0.2s;
    margin-top: 4px;
}
.sidebar-toggle-btn:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.08);
}
.sidebar-toggle-icon {
    width: 18px;
    height: 18px;
}
.sidebar-toggle-icon--closed { display: none; }

/* Collapsed state */
.sidebar.collapsed {
    width: 64px;
}
.sidebar.collapsed .sidebar-header h2 {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
}
.sidebar.collapsed .sidebar-header {
    display: none;
}
.sidebar.collapsed .sidebar-header-row {
    justify-content: center;
    padding: 0;
    margin-bottom: 4px;
}
.sidebar.collapsed .sidebar-toggle-btn {
    margin: 6px 0 10px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
}
.sidebar.collapsed .sidebar-toggle-icon--open { display: none; }
.sidebar.collapsed .sidebar-toggle-icon--closed { display: block; }
.sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 13px 0;
    gap: 0;
}
.sidebar.collapsed .sidebar-footer {
    display: none;
}
.sidebar.collapsed #sidebarEntitySwitcher {
    display: none !important;
}
.sidebar.collapsed .sidebar-divider {
    margin: 6px 12px;
}

/* Nav label transition */
.nav-label {
    transition: opacity 0.2s, width 0.2s;
    white-space: nowrap;
}

/* Sidebar divider */
.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.09);
    margin: 8px 0;
    list-style: none;
}

/* Notifications overlay */
.notifications-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 9997;
    backdrop-filter: blur(2px);
}

.notifications-overlay.active {
    display: block;
}

.notifications-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    background: white;
    box-shadow: 4px 0 32px rgba(15, 23, 42, 0.18);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    overflow-y: auto;
}

.notifications-panel.active {
    transform: translateX(0);
}

.notification-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
}

.notification-item:hover {
    background: #f8fafc;
}

.notification-item.unread {
    background: #f0f7ff;
    border-right: 3px solid #667eea;
}

/* ה-nav גדל למלא את הגובה כדי שאזור המשתמש/יציאה ייצמד לתחתית הסרגל
   ללא תלות בכמות הלשוניות; התפריט גולל בפנים כשיש יותר מדי פריטים. */
.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-menu {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
    padding: 4px 0;
}
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-item {
    padding: 9px 18px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 11px;
    color: rgba(203, 213, 225, 0.82);
    font-size: 13px;
    font-weight: 500;
    border-inline-start: 3px solid transparent;
    margin: 0;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.95);
}

.nav-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.9;
    fill: none;
    flex: 0 0 18px;
    /* חובה, לא קישוט: כמה מהאייקונים מציירים נקודה כקו באורך 0.01,
       ובלי קצה מעוגל הנקודה לא מרונדרת כלל. */
    stroke-linecap: round;
    stroke-linejoin: round;
}

.section-title-inline-icon {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.9;
    fill: none;
    vertical-align: -2px;
    margin-inline-start: 6px;
}

.sidebar-item.active {
    background: rgba(147, 197, 253, 0.14);
    color: #ffffff;
    font-weight: 600;
    border-inline-start-color: #93c5fd;
}

.sidebar-item:focus-visible,
.sidebar-toggle-btn:focus-visible,
.account-card:focus-visible,
.sidebar-signout:focus-visible,
.mobile-nav-toggle:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: -2px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    margin-top: 0;
    flex-shrink: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-primary, #2f4f7f);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    color: #5a6779;
}

/* Main Content */
.main-content {
    flex: 1;
    /* Flex items default to min-width:auto, so a wide table inside makes the
       whole page scroll sideways instead of the table scrolling on its own. */
    min-width: 0;
    margin-right: 240px;
    padding: 24px;
    position: relative;
    transition: margin-right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed ~ .main-content {
    margin-right: 64px;
}


.top-bar {
    background: white;
    padding: 16px 24px 16px 72px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
}

.notifications-bell {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9996;
    cursor: pointer;
    background: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.06);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

body.logged-in .notifications-bell {
    display: flex;
}

.bell-icon {
    width: 19px;
    height: 19px;
    stroke: #3d5a80;
    stroke-width: 2;
    fill: none;
}

.notifications-bell:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(15, 23, 42, 0.08);
    background: #f8fafc;
}

.notifications-bell.active-panel {
    background: #eff6ff;
    box-shadow: 0 2px 10px rgba(99, 131, 180, 0.25), 0 0 0 1px rgba(99, 131, 180, 0.3);
}
.notifications-bell.active-panel .bell-icon {
    stroke: #3b82f6;
}

/* 11b — מונה התראות רגוע: כחול במקום אדום-מבהיל, תקרת "9+" */
.bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #2563eb;
    color: white;
    font-size: 9.5px;
    font-weight: 700;
    padding: 0 4px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: content-box;
    border: 2px solid white;
    direction: ltr;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
}

.page-subtitle {
    font-size: 13px;
    color: #475569;
    margin-top: 4px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.content-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.request-submit-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 4px;
    padding: 18px 0 4px;
    background: transparent;
}

.request-submit-bar .btn {
    width: auto;
    min-width: 150px;
    min-height: 42px;
    padding: 11px 22px;
}

