/* ==========================================
   Base.html Styles - עיצובים עבור התבנית הראשית
   ========================================== */

/* ==========================================
   Body & Layout Settings
   ========================================== */
body {
    font-family: Arial, sans-serif;
    background-color: #eef2f6;
    margin: 0;
    padding: 0;
}

body.rtl {
    direction: rtl;
    text-align: right;
}

body.ltr {
    direction: ltr;
    text-align: left;
}

/* Container הבסיסי */
.container {
    width: 91%;
    max-width: none;
    margin: 20px auto;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 20px;
    box-sizing: border-box;
}

/* ==========================================
   Navbar Styles
   ========================================== */
.navbar {
    padding: 0rem 1rem;
}


/* Keep horizontal menu only on wider screens */
@media (min-width: 1158px) {
    .navbar-nav {
        flex-direction: row;
    }
}

.nav-link {
    padding: 10px 15px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background-color: #f8f9fa;
    color: #000;
    border-radius: 5px;
}

.nav-link:focus {
    background-color: #ffd700;
    color: #333;
}

.navbar-toggler {
    border: none;
}

/* Offcanvas navbar custom styling */
.navbar .offcanvas {
    background-color: #343a40;
    color: #fff;
    width: 250px;
    top: 45px; /* open below the navbar */
}

.navbar .offcanvas .nav-link {
    color: #fff;
}

.navbar .offcanvas .nav-link:hover {
    background-color: #198754;
    color: #fff;
}

.nav-link.active {
    background-color: #0d4abb;
    color: #fff;
}

/* Navbar Fixed positioning */
@media (min-width: 992px) {
    .navbar {
        position: fixed !important;
        top: 0;
        width: 100%;
        z-index: 999;
    }
}

@media (max-width: 991px) {
    .navbar {
        position: static !important;
    }
}

/* רווח בין אייקון לטקסט בניווט */
.nav-link i {
    margin-left: 0.25rem;
}

body.rtl .nav-link i {
    margin-right: 0.25rem;
    margin-left: 0;
}

/* התאמות למובייל */
@media (max-width: 768px) {
    .navbar-nav {
        flex-direction: column;
    }

    .container {
        margin-top: 15px !important;
    }
}

/* ==========================================
   Language Dropdown
   ========================================== */
.dropdown-toggle {
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
}

.dropdown-menu {
    min-width: 8rem;
    font-size: 0.9rem;
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-item:hover {
    background-color: #e9ecef;
}

.dropdown-item.active {
    background-color: #28a745;
    color: white;
}

/* התאמה למובייל */
@media (max-width: 991px) {
    .navbar-brand .dropdown-toggle {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }

    .navbar-brand .dropdown-menu {
        min-width: 6rem;
    }
}

/* ==========================================
   Flash Messages & Alerts
   ========================================== */
.swal-toast {
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 350px;
    top: 50px !important;
}

/* ==========================================
   Scroll to Top Button
   ========================================== */
.scroll-to-top {
    position: fixed !important;
    bottom: 30px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 38px !important;
    height: 38px !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    cursor: pointer !important;
    z-index: 1000 !important;
    color: white !important;
    text-decoration: none !important;

    /* מצב התחלתי - מוסתר */
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;

    /* אנימציות */
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;

    /* אפקטים מתקדמים */
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(10px) !important;

    /* אנימציית דופק עדינה */
    animation: subtlePulse 3s ease-in-out infinite !important;

    /* דריסת כללים גלובליים */
    margin: 0 !important;
    padding: 0 !important;
    font-size: inherit !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
}

/* מצב גלוי */
.scroll-to-top.visible {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
    transform: translateX(-50%) !important;
}

/* מצב hover */
.scroll-to-top:hover {
    transform: translateX(-50%) scale(1.1) translateY(-5px) !important;
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4), 0 8px 20px rgba(0, 0, 0, 0.2) !important;
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4c93 100%) !important;
    color: white !important;
    text-decoration: none !important;
}

/* מצב לחיצה */
.scroll-to-top:active {
    transform: translateX(-50%) scale(0.95) !important;
    transition: transform 0.1s ease !important;
}

/* אייקון החץ */
.scroll-to-top i {
    font-size: 16px !important;
    color: white !important;
    transition: all 0.3s ease !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    display: inline-block !important;
}

.scroll-to-top:hover i {
    transform: translateY(-3px) !important;
    font-size: 18px !important;
}

/* אנימציית דופק עדינה */
@keyframes subtlePulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4), 0 6px 18px rgba(0, 0, 0, 0.2);
    }
}

/* אנימציה למצב הופעה */
.scroll-to-top.show-animation {
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.3) translateY(100px);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.05);
    }
    70% {
        transform: translateX(-50%) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%);
    }
}

/* אנימציה למצב היעלמות */
.scroll-to-top.hide-animation {
    animation: bounceOut 0.4s ease-in-out !important;
}

@keyframes bounceOut {
    0% {
        opacity: 1;
        transform: translateX(-50%);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) scale(0.3) translateY(100px);
    }
}

:root {
    --progress: 0;
}

/* אינדיקטור התקדמות */
.scroll-progress {
    position: absolute !important;
    top: -3px !important;
    left: -3px !important;
    right: -3px !important;
    bottom: -3px !important;
    border-radius: 50% !important;
    background: conic-gradient(
        from 0deg,
        #667eea 0deg,
        #764ba2 calc(var(--progress, 0) * 1deg),
        rgba(255, 255, 255, 0.1) calc(var(--progress, 0) * 1deg)
    ) !important;
    z-index: -1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* התאמה למובייל */
@media (max-width: 768px) {
    .scroll-to-top {
        width: 36px !important;
        height: 36px !important;
        bottom: 20px !important;
    }

    .scroll-to-top i {
        font-size: 14px !important;
    }

    .scroll-to-top:hover i {
        font-size: 16px !important;
    }
}

/* הסתרה בעת גלילה למטה */
.scroll-to-top.scrolling-down {
    transform: translateX(-50%) translateY(100px) scale(0.5) !important;
    opacity: 0.3 !important;
}

/* דריסת כללים שיכולים להפריע */
.scroll-to-top:focus,
.scroll-to-top:visited,
.scroll-to-top:link {
    color: white !important;
    text-decoration: none !important;
    outline: none !important;
}

/* ==========================================
   Loading Overlay
   ========================================== */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 22px;
}

#loading-overlay .spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #3498db;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-message {
    font-size: 1.25rem;
    color: #1a237e;
    font-weight: 600;
    text-align: center;
    max-width: 90vw;
    line-height: 1.6;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.7s, transform 0.7s;
    direction: rtl;
}

.loading-message.fade-in {
    opacity: 1;
    transform: translateY(0);
}


/* ==========================================
   Utility Classes
   ========================================== */
html {
    scroll-behavior: smooth;
}

/* ==========================================
   General Helper Classes
   ========================================== */
.center-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 70px;
}

/* ==========================================
   Responsive Helpers
   ========================================== */
@media (max-width: 576px) {
    .container {
        margin-top: 15px !important;
    }
}

/* ==========================================
   RTL/LTR Select Fixes
   ========================================== */
body.rtl .select_fix select {
    direction: ltr;
    text-align-last: right;
}

body.rtl .select_fix select option {
    direction: rtl;
    text-align: right;
}

body.ltr select {
    direction: rtl;
    text-align-last: left;
}

body.ltr select option {
    direction: ltr;
    text-align: left;
}