/* ===================================================
 * TRENJ SPA - Shared Styles for SPA Navigation
 * هيدر ثابت + نافيجيشن سفلي ثابت + أنيميشن التنقل
 * =================================================== */

/* ===== 1. شريط التحميل العلوي ===== */
#spa-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #FF385C, #E31C5F, #D70466);
    z-index: 99999;
    transition: none;
    opacity: 0;
    pointer-events: none;
    border-radius: 0 2px 2px 0;
}

#spa-loading-bar.spa-loading-active {
    opacity: 1;
    animation: spaLoadingProgress 1.5s ease-out forwards;
}

#spa-loading-bar.spa-loading-done {
    width: 100% !important;
    opacity: 0;
    transition: opacity 0.3s ease 0.1s;
}

@keyframes spaLoadingProgress {
    0%   { width: 0; }
    20%  { width: 30%; }
    50%  { width: 60%; }
    80%  { width: 85%; }
    100% { width: 92%; }
}

/* ===== 2. أنيميشن تبديل المحتوى ===== */
#spa-content {
    transition: opacity 0.25s ease, transform 0.25s ease;
    will-change: opacity, transform;
    min-height: calc(100vh - 80px - 64px);
}

#spa-content.spa-leaving {
    opacity: 0;
    transform: translateY(8px);
}

#spa-content.spa-entering {
    animation: spaFadeIn 0.3s ease forwards;
}

@keyframes spaFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 3. النافيجيشن السفلي (Bottom Navigation) ===== */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #ffffff;
    border-top: 1px solid #ebebeb;
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1500;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    /* smooth shadow */
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.06);
    /* تنعيم أداء الرسم */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* عنصر مفرد في النافيجيشن */
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: #717171;
    font-size: 10px;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: 10px;
    transition: color 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    min-width: 56px;
    position: relative;
}

.bottom-nav-item i,
.bottom-nav-item .nav-icon {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.bottom-nav-item .nav-label {
    font-size: 10px;
    line-height: 1.2;
    white-space: nowrap;
}

/* الحالة النشطة */
.bottom-nav-item.active {
    color: #FF385C;
}

.bottom-nav-item.active i,
.bottom-nav-item.active .nav-icon {
    transform: scale(1.1);
}

/* Active dot indicator */
.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #FF385C;
}

/* حالة الضغط */
.bottom-nav-item:active {
    color: #FF385C;
    background: rgba(255, 56, 92, 0.06);
}

/* ===== 3.5 زر الخريطة المميز ===== */
.nav-map-btn {
    color: #fff !important;
    background: linear-gradient(135deg, #7CB342, #558B2F) !important;
    border-radius: 50% !important;
    width: 52px !important;
    height: 52px !important;
    margin-top: -18px; /* يبرز للأعلى */
    padding: 0 !important;
    box-shadow: 0 4px 14px rgba(85, 139, 47, 0.45);
    position: relative;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.nav-map-btn i {
    font-size: 20px !important;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-map-btn .nav-label {
    font-size: 9px;
    color: #fff;
    margin-top: 1px;
}

.nav-map-btn:active {
    transform: scale(0.92);
    background: linear-gradient(135deg, #558B2F, #33691E) !important;
    color: #fff !important;
}

/* active = الخريطة مفتوحة → يتحول لأيقونة قائمة */
.nav-map-btn.map-open {
    background: linear-gradient(135deg, #222, #444) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.nav-map-btn.map-open .nav-label {
    color: #ccc;
}

/* لا نريد النقطة تحت زر الخريطة */
.nav-map-btn::after {
    display: none !important;
}

/* ===== 3.6 طبقة الخريطة العالمية (fullscreen) ===== */
#global-map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 64px; /* فوق النافيجيشن */
    z-index: 1400;
    background: #fff;
    display: none;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#global-map-overlay.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

#global-map-overlay .map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #7CB342, #558B2F);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}

#global-map-overlay .map-header button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

#global-map-overlay .map-header button:hover {
    background: rgba(255,255,255,0.35);
}

#global-map-container {
    flex: 1;
    min-height: 0;
}

/* Price markers for global map */
.leaflet-price-marker {
    background: transparent;
    border: none;
}

.price-marker-content {
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 24px;
    padding: 4px 10px;
    font-weight: 700;
    font-size: 13px;
    color: #222;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.price-marker-content:hover {
    background: #222;
    color: white;
    transform: scale(1.08);
}

/* ===== 4. إخفاء أزرار قديمة على الموبايل ===== */
/* النافيجيشن القديم الخاص بـ chalets.php */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: none !important; /* يستبدل بـ #bottom-nav الجديد */
    }
}

/* ===== 5. تعديل padding للمحتوى ===== */
body {
    padding-bottom: 64px; /* مساحة للنافيجيشن السفلي */
}

/* الجوال: مساحة إضافية */
@media (max-width: 768px) {
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* تعديل زر الواتساب العائم */
    .whatsapp-float {
        bottom: 80px !important;
    }
}

/* ===== 6. إخفاء النافيجيشن على الديسكتوب (اختياري) ===== */
@media (min-width: 769px) {
    #bottom-nav {
        display: flex; /* موجود على الكل */
    }
    
    /* يمكن تغييره لـ display:none إذا أردت إخفاءه على الديسكتوب */
    /*
    #bottom-nav {
        display: none;
    }
    body {
        padding-bottom: 0;
    }
    */
}

/* ===== 7. الهيدر الثابت ===== */
#main-header,
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* ===== 7.1 Mobile Header - Fixed & Auto-hide ===== */
@media (max-width: 768px) {
    .header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        will-change: transform;
    }
    
    .header.header-hidden {
        transform: translateY(-100%);
        box-shadow: none !important;
        /* pointer-events: none; -- removed: was blocking taps on user-menu button */
    }
    
    .header.header-visible {
        transform: translateY(0);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Push main content below fixed header */
    .main-content {
        padding-top: 52px;
    }

    /* Correct min-height for mobile (52px header + 56px bottom-nav) */
    #spa-content {
        min-height: calc(100vh - 52px - 56px);
    }
    
    /* Compact header on mobile */
    .header .header-content {
        flex-direction: row !important;
        gap: 0 !important;
        padding: 0.5rem 1rem !important;
    }
    
    /* Hide main nav on mobile - replaced by bottom nav */
    .header .main-nav {
        display: none !important;
    }
    
    .header .logo-text {
        font-size: 1.1rem !important;
    }
    
    .header .logo-img {
        height: 28px !important;
    }
}

/* ===== 8. تنعيم التنقل العام ===== */
/* scroll-behavior: smooth handled in style.css — disabled on mobile to prevent jank */
@media (min-width: 769px) {
    html {
        scroll-behavior: smooth;
    }
}

/* تجنّب مشاكل الأنيميشن */
#spa-content * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== 9. أنيميشن متقدمة للنافيجيشن السفلي ===== */

/* --- 9.1 Ripple Effect (Material You) --- */
.bottom-nav-item {
    overflow: hidden;
    position: relative;
    isolation: isolate;
}

.nav-ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 56, 92, 0.35) 0%, rgba(255, 56, 92, 0) 70%);
    transform: scale(0);
    animation: navRippleExpand 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    pointer-events: none;
    z-index: 0;
}

.nav-map-btn .nav-ripple {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 70%);
}

@keyframes navRippleExpand {
    0%   { transform: scale(0); opacity: 1; }
    70%  { opacity: 0.5; }
    100% { transform: scale(4); opacity: 0; }
}

/* --- 9.2 Icon Bounce (إنبثاق مطاطي) --- */
.bottom-nav-item.nav-bounce i,
.bottom-nav-item.nav-bounce .nav-icon {
    animation: navIconBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes navIconBounce {
    0%   { transform: scale(1); }
    20%  { transform: scale(0.75); }
    50%  { transform: scale(1.35); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1.1); }
}

/* Non-active items return to normal scale after bounce */
.bottom-nav-item.nav-bounce:not(.active) i,
.bottom-nav-item.nav-bounce:not(.active) .nav-icon {
    animation: navIconBounceReturn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes navIconBounceReturn {
    0%   { transform: scale(1); }
    20%  { transform: scale(0.75); }
    50%  { transform: scale(1.3); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* --- 9.3 Label Pop (ظهور النص) --- */
.bottom-nav-item.nav-bounce .nav-label {
    animation: navLabelPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s both;
}

@keyframes navLabelPop {
    0%   { transform: scale(0.8) translateY(2px); opacity: 0.6; }
    60%  { transform: scale(1.1) translateY(-1px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* --- 9.4 Particle Burst (انفجار جزيئات) --- */
.nav-particle-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 10;
}

.nav-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: navParticleBurst var(--particle-duration, 0.65s) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    --px: 0px;
    --py: 0px;
}

@keyframes navParticleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    60% {
        opacity: 0.8;
    }
    100% {
        transform: translate(var(--px), var(--py)) scale(0);
        opacity: 0;
    }
}

/* --- 9.5 Active Glow (توهج عند التنشيط) --- */
.bottom-nav-item.nav-glow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 56, 92, 0.12);
    transform: translate(-50%, -50%) scale(0);
    animation: navGlowPulse 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    z-index: -1;
}

.nav-map-btn.nav-glow::before {
    background: rgba(124, 179, 66, 0.2);
}

@keyframes navGlowPulse {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    50%  { transform: translate(-50%, -50%) scale(1.2); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* --- 9.6 Map Button Special Pulse --- */
.nav-map-btn.nav-bounce {
    animation: mapBtnPulse 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes mapBtnPulse {
    0%   { box-shadow: 0 4px 14px rgba(85, 139, 47, 0.45); transform: scale(1); }
    25%  { box-shadow: 0 6px 24px rgba(85, 139, 47, 0.7); transform: scale(0.9); }
    50%  { box-shadow: 0 8px 30px rgba(85, 139, 47, 0.55); transform: scale(1.12); }
    75%  { box-shadow: 0 5px 18px rgba(85, 139, 47, 0.5); transform: scale(0.98); }
    100% { box-shadow: 0 4px 14px rgba(85, 139, 47, 0.45); transform: scale(1); }
}

/* --- 9.7 Active indicator slide --- */
.bottom-nav-item.active::after {
    animation: navDotAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes navDotAppear {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.6); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- 9.8 Haptic Color Flash (وميض لون عند الضغط) --- */
.bottom-nav-item.nav-flash {
    animation: navColorFlash 0.3s ease;
}

@keyframes navColorFlash {
    0%   { color: #717171; }
    30%  { color: #FF385C; }
    100% { color: #FF385C; }
}

.bottom-nav-item.nav-flash:not(.active) {
    animation: navColorFlashReturn 0.5s ease;
}

@keyframes navColorFlashReturn {
    0%   { color: #717171; }
    30%  { color: #FF385C; }
    100% { color: #717171; }
}

/* ===== 10. سكيلتون لوادينج (اختياري) ===== */
.spa-skeleton {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    min-height: 60vh;
    align-items: center;
    justify-content: center;
}

.spa-skeleton-text {
    height: 14px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    width: 60%;
}

.spa-skeleton-card {
    height: 180px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 14px;
    width: 100%;
    max-width: 400px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
