/* CSS Variables for a dark theme, similar to TimelineMap */
:root {
    --color-bg-primary: #1F1F1F;
    --color-bg-secondary: #2C2C2C;
    --color-text-primary: #E0E0E0;
    --color-text-secondary: #B0B0B0;
    --color-accent-gold: #D4AF37;
    --color-timeline-bg: #1A1A1A;
    --color-timeline-year: #888888;
    --color-timeline-marker: #D32F2F;
    --color-link-hover: #D4AF37;
    --color-text-primary: #E0E0E0;
    --color-accent-gold: #9c8846;
    --font-main: 'Vazirmatn', sans-serif;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: var(--font-main);
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    direction: rtl;
    text-align: justify;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* --- Header (Old Maps Online Style) --- */
.header {
            font-family: var(--font-main);
            display: flex;
            direction: rtl;
            text-align: right;
            justify-content: space-between;
            align-items: center;
            background-color: #473116;
            padding: 0 1rem;
            height: 80px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
            z-index: 1000;
        }
        
        #header-left {
            display: flex;
            align-items: center;
        }

        #header-logo {
            font-weight: 700;
            color: var(--color-accent-gold);
            text-decoration: none;
            white-space: nowrap;
            padding-top: 10px;
        }
        
        #search-box {
            display: flex;
            align-items: center;
            background-color: #837A6E80;
            border-radius: 20px;
            padding: 0.5rem 1rem;
            width: 300px;
            margin: 0 1.5rem;
        }
        
        #search-box input {
            background: none;
            border: none;
            color: var(--color-text-primary);
            font-family: var(--font-main);
            width: 100%;
            outline: none;
            padding: 0;
            margin-right: 0.5rem;
        }
        
        #search-box input::placeholder {
            color: var(--color-text-secondary);
        }
        
        #header-nav {
            display: flex;
            align-items: center;
        }

        #header-nav a {
            color: #ffffff;
            text-decoration: none;
            padding: 0.5rem 1rem;
            font-weight: 400;
            transition: color 0.2s ease;
            white-space: nowrap;
        }
        
        #header-nav a:hover {
            color: var(--color-accent-gold);
        }

        #header-right {
            display: flex;
            align-items: center;
            position: relative;
            gap: 1rem;
        }
        /* --- Share Button --- */
        #share-button {
            background: none;
            border: none;
            color: var(--color-text-secondary);
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            cursor: pointer;
            border-radius: 50%;
            transition: background-color 0.2s ease;
        }

        #share-button:hover {
            background-color: #383838;
        }

        /* --- User Avatar and Dropdown --- */
        #user-avatar-container {
            position: relative;
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--color-text-primary);
            font-size: 1.2rem;
            cursor: pointer;
        }

        #user-dropdown {
            position: absolute;
            top: 100%;
            right: -250px;
            width: 250px;
            background-color: #473116c0;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.5);
            padding: 1rem;
            margin-top: 0.5rem;
            z-index: 999;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: opacity 0.2s ease, transform 0.2s ease;
        }
        
        #user-dropdown.open {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        
        .dropdown-item {
            display: flex;
            align-items: center;
            gap: 1rem;
            padding: 0.7rem 1rem;
            text-decoration: none;
            color: var(--color-text-secondary);
            border-radius: 4px;
            transition: background-color 0.2s ease, color 0.2s ease;
        }
        
        .dropdown-item:hover {
            background-color: #383838;
            color: var(--color-text-primary);
        }
        
        .dropdown-item i {
            width: 20px;
            text-align: center;
            font-size: 1rem;
        }
        
        .dropdown-item span {
            font-size: 0.9rem;
        }



        /* استایل‌های مربوط به دکمه تغییر زبان */
        .language-switcher {
            position: relative;
            padding-right: 300px;
            /* این بخش را حذف کنید اگر قبلاً در `header-right` تعریف شده باشد. */
        }

        /* استایل دکمه تغییر زبان با متن */
        .language-button {
            background-color: rgba(255, 255, 255, 0.08); /* پس‌زمینه کمی شفاف */
            border: 1px solid rgba(255, 255, 255, 0.15); /* حاشیه */
            color: var(--color-text-primary);
            padding: 0.5rem 1rem;
            border-radius: 20px; /* گوشه‌های گرد */
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 1rem;
            cursor: pointer;
            transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
        }

        .language-button:hover {
            background-color: rgba(255, 255, 255, 0.15);
            border-color: var(--color-accent-gold); /* حاشیه طلایی پررنگ‌تر */
            transform: translateY(-2px);
        }

        /* آیکون داخل دکمه */
        .language-button .icon {
            font-size: 1.2rem;
            color: var(--color-accent-gold);
        }

        /* متن داخل دکمه */
        .language-button .text {
            font-family: var(--font-main);
            font-weight: 500;
        }

        /* استایل‌های مربوط به منوی کشویی زبان */
        .language-dropdown {
            position: absolute;
            top: 100%;
            width: 170px;
            background-color: #685f5480;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.5);
            padding: 1rem;
            margin-top: 0.5rem;
            z-index: 999;
            opacity: 0;
            visibility: hidden; /* منو را پنهان می‌کند */
            transform: translateY(-10px);
            transition: opacity 0.2s ease, transform 0.2s ease;
            direction: rtl; 
        }

        /* این کلاس با جاوا اسکریپت اضافه می‌شود تا منو نمایش داده شود */
        .language-dropdown.open {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

/* --- Share Modal --- */
#share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease;
}

#share-modal.open {
    visibility: visible;
    opacity: 1;
}

#share-popup {
    width: 500px;
    background-color: #473116;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    padding: 1.5rem;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#share-modal.open #share-popup {
    transform: scale(1);
}

#share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #383838;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

#share-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 500;
}

#share-header button {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.share-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #383838;
}

.share-tabs button {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.share-tabs button.active {
    color: var(--color-accent-gold);
    border-bottom: 2px solid var(--color-accent-gold);
}

.tab-content {
    padding-top: 1rem;
}

.link-share-section p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.link-input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.link-input-container input {
    flex-grow: 1;
    background-color: #837A6E80;
    border: 1px solid #444;
    color: var(--color-text-primary);
    font-family: var(--font-main);
    padding: 0.7rem;
    border-radius: 4px;
    outline: none;
}

.link-input-container button {
    background-color: var(--color-accent-gold);
    color: var(--color-bg-primary);
    border: none;
    padding: 0.7rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.link-input-container button:hover {
    opacity: 0.8;
}

.social-share-section {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.social-share-section p {
    margin: 0;
    white-space: nowrap;
}

.social-icons {
    display: flex;
    gap: 0.5rem;
}

.social-icon {
    width: 40px;
    height: 40px;
    background-color: #383838;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    font-size: 1.2rem;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.social-icon:hover {
    background-color: #444;
}

/* --- Main Content Area --- */
#main-content {
    flex-grow: 1;
    position: relative;
    display: flex;
}

/* --- Map Container --- */
#map-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

#map {
    width: 100%;
    height: 100%;
    background-color: #1F1F1F;
}

/* --- Left-side Map Controls --- */
#map-controls-left {
    position: absolute;
    top: 2rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 900;
}

#map-controls-left .control-group {
    display: flex;
    flex-direction: column;
    background-color: #473116;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    overflow: hidden;
    border: 1px solid #383838;
}

#map-controls-left button {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background-color 0.2s ease;
}

#map-controls-left button:hover {
    background-color: #383838;
}

#map-controls-left .control-group button:not(:last-child) {
    border-bottom: 1px solid #383838;
}

/* --- Right Sidebar (Maps) --- */
#sidebar-toggle-btn {
    position: absolute;
    top: 2rem;
    left: 2rem;
    background-color: #473116;
    color: var(--color-text-secondary);
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 900;
}


/* Container for the FAB and menu */
.layer-fab-container {
    position: fixed;
    /* این مقادیر را برای قرارگیری در مرکز صفحه تنظیم کنید */
    top: 27%;
    left: 4%;
    transform: translate(-50%, -50%);
    z-index: 900;
}
/* حالت موبایل (برای نمایشگرهای کوچکتر از 768 پیکسل) */
@media (max-width: 768px) {
  .layer-fab-container {
    /* ریست کردن مقادیر دسکتاپ */
    top: 27%;
    left: 14%;
    transform: translate(-50%, -50%);; /* حذف translate برای موقعیت‌دهی ساده‌تر */
    z-index: 900;
  }
}

/* Hide the main toggle checkbox */
.layers-toggle-checkbox {
    display: none;
}

/* Style for the "Layers" button */
.layers-toggle-label {
    padding: 12px 20px;
    background-color: #5d3f1d;
    color: #ffffff;
    border-radius: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    transition: background-color 0.3s ease;
}

.layers-toggle-label:hover {
    background-color: #5d3f1d;
}

/* Style for the dropdown menu */
.layers-dropdown-menu {
    position: absolute;
    top: 53px; /* این مقدار باید بزرگتر از ارتفاع دکمه باشد */
    left: 177%;
    transform: translateX(-50%) scale(0); /* تغییر مقادیر برای مرکز قرارگیری */
    transform-origin: top center; /* اینجا را اصلاح کنید */
    width: 160px;
    background: #2b1f13;
    border-radius: 12px;
    padding: 10px 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    pointer-events: none;
    opacity: 0;
}

/* Animate the menu when active */
.layers-toggle-checkbox:checked ~ .layers-dropdown-menu {
    transform: translateX(-50%) scale(1);
    pointer-events: auto;
    opacity: 1;
}

/* بقیه استایل‌ها (dropdown-option, icon-checkbox و ...) بدون تغییر می‌مانند */

/* Style for each option in the menu */
.dropdown-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.dropdown-option:last-child {
    border-bottom: none;
}

/* Hide the actual checkboxes */
.dropdown-option input[type="checkbox"] {
    display: none;
}

/* Style for the icon as a checkbox */
.icon-checkbox {
    font-size: 16px;
    color: #ffffff4d; /* Faded color for inactive state */
    transition: color 0.3s ease;
}

/* Change icon color when checkbox is checked */
.dropdown-option input[type="checkbox"]:checked ~ .icon-checkbox {
    color: #ffffff; /* Full color for active state */
}

.option-label {
    color: #ffffff;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
}

#sidebar-right {
    position: absolute;
    top: 0px; /* ارتفاع هدر */
    bottom: 150px; /* ارتفاع تایم‌لاین */
    left: 0;
    width: 0;
    min-width: 0;
    background-color: #473116;
    box-shadow: -2px 0 5px rgba(0,0,0,0.5);
    transition: width 0.3s ease;
    z-index: 999;
    overflow: hidden; /* پنهان کردن محتوا در حالت بسته */
}

#sidebar-right.open {
    width: 400px;
    min-width: 400px;
    overflow-y: auto; /* فعال کردن اسکرول در حالت باز */
}

#sidebar-content {
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#sidebar-right.open #sidebar-content {
    opacity: 1;
}

#sidebar-header {
    display: flex;
    width: 370px;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #383838;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    background-color: #837A6E80 ;
    z-index: 10;
}

#sidebar-header h2 {
    margin: 0;
    padding-right: 10px;
    font-size: 1.5rem;
    font-weight: 500;
}

#sidebar-header button {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #383838;
    position: sticky;
    top: 60px; /* ارتفاع هدر سایدبار */
    background-color: #837A6E80;
    z-index: 10;
}

.sidebar-tabs button {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.sidebar-tabs button.active {
    color: var(--color-accent-gold);
    border-bottom: 2px solid var(--color-accent-gold);
    padding-right: 10px;
}

.map-list {
    overflow-y: auto;
    height: 100%;
}

.map-item {
    display: flex;
    gap: 1rem;
    background-color: #383838;
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.map-item:hover {
    background-color: #444;
}

.map-item-image {
    width: 80px;
    height: 80px;
    background-color: #555;
    border-radius: 4px;
}

.map-item-details {
    flex-grow: 1;
}

.map-item-details h3 {
    margin: 0 0 0.2rem 0;
    font-size: 1rem;
    font-weight: 500;
}

.map-item-details p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

/*
 * PROFESSIONAL STYLING FOR LEAFLET REGION POLYGON AND POPUPS
 * Optimized for a Dark Theme with Gold Accent (--color-accent-gold)
 */



/* --- 2. Leaflet Popup Container --- */
.leaflet-popup-content-wrapper {
    background-color: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border-radius: 12px;           /* گوشه‌های گردتر و مدرن‌تر */
    border: 1px solid rgba(255, 255, 255, 0.1); /* خط دور ظریف برای تفکیک در تم تیره */
    padding: 15px 20px;            /* افزایش پدینگ برای فضای تنفس بهتر */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); /* سایه عمیق‌تر برای برجستگی */
    text-align: justify;
}

/* Remove Leaflet's default pointer tail box-shadow */
.leaflet-popup-tip {
    box-shadow: none; 
}

/* --- 3. Popup Content (Header/Title) --- */
.leaflet-popup-content h2 {
    font-size: 1.3rem;                 /* اندازه عنوان کمی بزرگتر */
    font-weight: 700;                  /* ضخامت بیشتر برای عنوان */
    color: var(--color-text-primary); 
    margin: 0 0 8px 0;                 /* افزایش مارجین پایین برای جداسازی بهتر */
    padding-bottom: 5px;               /* کمی فضای داخلی برای خط جداکننده */
    border-bottom: 1px solid rgba(255, 255, 255, 0.15); /* خط جداکننده ظریف */
}

/* --- 4. Popup Content (Paragraph Text) --- */
.leaflet-popup-content p {
    font-size: 0.95rem;                /* کمی بزرگتر از قبل برای خوانایی بهتر */
    color: var(--color-text-secondary);
    line-height: 1.5;                  /* ارتفاع خط مناسب برای پاراگراف */
    margin: 0;
}

#community-button {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    padding: 0.8rem 1.5rem;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    font-size: 0.9rem;
    z-index: 100;
    transition: background-color 0.2s ease;
    text-decoration: none;
}

#community-button:hover {
    background-color: #383838;
}

/* Adjust Leaflet default controls for the dark theme */
.leaflet-control-zoom, .leaflet-control-layers {
    display: none !important;
}

/* --- Timeline --- */
/* --- Timeline --- */
#timeline-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background-color: rgba(31, 31, 31, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
    padding: 0 5rem;
    transition: all 0.3s ease;
}

#timeline-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(212, 175, 55, 0.1) 0%, rgba(31, 31, 31, 0) 70%);
    z-index: -1;
    transition: background 0.5s ease;
}

#timeline-slider-wrapper {
    position: relative;
    width: 80%;
    max-width: 1200px;
    height: 20px;
    margin-top: 2.5rem; /* کمی فضا برای نمایشگر سال */
}

/* === استایل جدید برای اسلایدر === */
#timeline-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    /* پس‌زمینه پیش‌فرض خاکستری است */
    /* نوار پیشرفت طلایی توسط جاوااسکریپت کنترل می‌شود */
    background: #444; 
    height: 8px; /* کمی ضخیم‌تر */
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

/* === استایل جدید برای دکمه اسلایدر (Thumb) === */
#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 24px; /* بزرگتر و قابل کلیک‌تر */
    width: 24px;
    border-radius: 50%;
    background: var(--color-accent-gold);
    border: 3px solid #fff; /* حاشیه سفید برای برجستگی */
    cursor: grab;
    margin-top: -8px; /* تنظیم دقیق وسط‌چین */
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#timeline-slider::-moz-range-thumb {
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--color-accent-gold);
    border: 3px solid #fff;
    cursor: grab;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.5);
}

#timeline-slider::-webkit-slider-thumb:active,
#timeline-slider::-moz-range-thumb:active {
    cursor: grabbing;
    transform: scale(1.2);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.8);
}

#timeline-marks {
    /* این بخش دیگر استفاده نمی‌شود، می‌توان آن را حذف کرد */
}

/* === استایل جدید برای لیبل‌های سال === */
#timeline-years {
    display: flex;
    justify-content: space-between;
    overflow-x: auto; /* اجازه اسکرول افقی */
    width: 80%;
    max-width: 1200px;
    position: relative;
    -ms-overflow-style: none;  /* مخفی کردن اسکرول‌بار در IE */
    scrollbar-width: none;  /* مخفی کردن اسکرول‌بار در فایرفاکس */
    top: 10px; /* فاصله از اسلایدر */
    padding: 0 10px;
}

#timeline-years::-webkit-scrollbar {
    display: none; /* مخفی کردن اسکرول‌بار در کروم و سافاری */
}

.timeline-label {
    position: relative; /* برای ::before */
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, font-weight 0.2s ease;
    white-space: nowrap;
    text-align: center;
    min-width: 80px;
    padding-top: 15px; /* فضا برای "تیک" */
    opacity: 0.5; /* اسامی غیرفعال کمرنگ باشند */
}

/* === "تیک" (Tick) بالای هر لیبل === */
.timeline-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background-color: #555; /* رنگ تیک عادی */
    border-radius: 1px;
    transition: all 0.3s ease;
}

.timeline-label:hover {
    color: var(--color-accent-gold);
    font-weight: 500;
}

.timeline-label:hover::before {
    background-color: var(--color-accent-gold);
    height: 12px;
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
}

.timeline-label.active {
    opacity: 1;
    color: var(--color-accent-gold);
    transform: scale(1.2);
    font-weight: bold;
}

/* "تیک" فعال شده */
.timeline-label.active::before {
    background-color: var(--color-accent-gold);
    height: 12px;
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
}

/* تنظیم تراز برای لیبل اول و آخر */
.timeline-label:first-child {
    text-align: right;
    padding-right: 0;
}
.timeline-label:first-child::before {
    left: auto;
    right: 0;
    transform: none;
}
.timeline-label:last-child {
    text-align: left;
    padding-left: 0;
}
.timeline-label:last-child::before {
    left: 0;
    transform: none;
}

/* === استایل نمایشگر سال (بدون تغییر) === */
#current-year-display {
    position: absolute;
    top: 10px;
    right: 50%;
    transform: translateX(50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent-gold);
    text-shadow: 1px 1px 5px rgba(0,0,0,0.8);
    white-space: nowrap;
}

#current-year-value {
    font-size: 2.5rem;
    font-weight: 900;
}

#current-year-era {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
}

/* Preloader اصلی و تنظیمات کلی */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.7s ease-in-out, visibility 0s 0.7s;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
}

/* افکت ذرات */
.particles {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #2a2a2a 1px, transparent 1px);
    background-size: 20px 20px;
    animation: move-particles 30s linear infinite;
}

@keyframes move-particles {
    from { background-position: 0 0; }
    to { background-position: 100px 100px; }
}

/* کانتینر محتوا (لوگو و متن) */
.preloader-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    z-index: 2;
}

/* لوگوی سایت */
.preloader-site-logo {
    width: 150px;
    height: auto;
    border-radius: 30px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.6));
    animation: fadeIn 1s ease-in-out, pulse-shadow 2s ease-in-out infinite;
}

/* انیمیشن محو شدن لوگو */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* افکت درخشش نورانی */
.logo-glow {
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background-color: #fff;
    filter: blur(20px);
    opacity: 0.2;
    animation: glow-pulse 2s ease-in-out infinite;
    z-index: 1;
}

/* انیمیشن تپش نور */
@keyframes glow-pulse {
    0% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.2); opacity: 0.5; }
    100% { transform: scale(1); opacity: 0.2; }
}

/* متن بارگذاری */
.preloader p {
    font-family: 'Vazirmatn', sans-serif;
    color: #a3a3a3;
    font-size: 1.1rem;
    margin-top: 20px;
    animation: pulse 1.5s infinite;
}

/* انیمیشن تپش متن */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.sidebar-info {
    position: absolute;
    top: 0px; /* ارتفاع هدر */
    bottom: 150px; /* ارتفاع تایم‌لاین */
    left: 0;
    transform: translateX(-100%);
    width: 350px;
    transition: transform 0.3s ease;
    background-color: #473116;
    z-index: 999;

    padding: 0; /* <--- پدینگ را از اینجا حذف کنید */
    display: flex; /* <--- این را اضافه کنید */
    flex-direction: column; /* <--- این را اضافه کنید */
    overflow: hidden;
}

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

#period-timeline {
    font-size: 1rem;
    color: var(--color-accent-gold);
    margin-bottom: 15px;
}

#read-more-btn {
    display: none; /* به صورت پیش‌فرض مخفی است */
    margin-top: 20px;
}

/* Sidebar Header */
.sidebar-header {
    background: #837A6E80;
    color: #fff;
    padding: 30px;
    border-bottom: 3px solid #6c757d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.3);
}

#info-close-btn {
    color: #fff;
    background: transparent;
    border: none;
    font-size: 32px;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1.05), color 0.4s ease;
}

#info-close-btn:hover {
    transform: rotate(180deg) scale(1.1);
    color: #fca311;
}

/* Main Content Area */
.info-details {
    padding: 30px;
    flex-grow: 1;
    overflow-y: auto;
}

/* Site/Period Image */
#info-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    margin-bottom: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
}

/* Detail Cards */
.detail-item {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s ease-in-out;
}

.detail-item:hover {
    transform: translateY(-5px);
}

/* Detail Text */
.detail-label {
    color: #b0c4de;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.detail-value {
    color: #fff;
    font-weight: 500;
    font-size: 1rem;
}

p#info-description {
    line-height: 1.8;
    background: rgba(255, 255, 255, 0.03);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: pre-wrap;
    font-size: 1rem;
    text-align: justify;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

/* message */
/* Container for all message cards, centered on the screen */
.toast-container {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    z-index: 1050;
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
}

/* Base Toast Styles (unmodified from previous version) */
.toast {
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
    background-color: rgba(30, 40, 50, 0.85) !important;
    color: #f0f0f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Toast Body with Icon (unmodified) */
.toast-body {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-body:before {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 1.4rem;
}

/* Custom Colors and Icons for different message tags (unmodified) */
.toast.text-bg-success {
    background-color: rgba(40, 167, 69, 0.9) !important;
    border-color: #28a745;
}
.toast.text-bg-success .toast-body:before {
    content: '\f058';
    color: #fff;
}

.toast.text-bg-warning {
    background-color: rgba(255, 193, 7, 0.9) !important;
    border-color: #ffc107;
    color: #212529 !important;
}
.toast.text-bg-warning .toast-body:before {
    content: '\f071';
    color: #212529;
}

.toast.text-bg-danger {
    background-color: rgba(220, 53, 69, 0.9) !important;
    border-color: #dc3545;
}
.toast.text-bg-danger .toast-body:before {
    content: '\f057';
    color: #fff;
}

/* Close Button Styling (unmodified) */
.toast .btn-close {
    filter: brightness(0) invert(1);
    transition: transform 0.3s ease;
}

.toast .btn-close:hover {
    transform: rotate(90deg) scale(1.1);
}
.close-fixed-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-fixed-btn:hover {
    transform: scale(1.15) rotate(90deg);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.2));
    box-shadow:
        inset 0 0 40px rgba(255, 255, 255, 0.9),
        0 16px 30px rgba(0, 0, 0, 0.3);
}

.close-fixed-btn:active {
    transform: scale(0.98);
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.1);
}

/* فایل: style.css */

/* --- AI Chat Box - Modern & Professional Redesign --- */
#ai-chat-box {
    position: fixed;
    bottom: 180px;
    right: 20px;
    width: 380px;
    height: 520px;
    background-color: #35230f; /* پس‌زمینه تیره و یکپارچه */
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05); /* حاشیه بسیار ظریف و تیز */
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.6); /* سایه نرم‌تر برای عمق */
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateY(30px) scale(0.98);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); /* انیمیشن نرم و فنری */
}

#ai-chat-box.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-accent-gold);
}

#ai-chat-close-btn {
    background: none;
    border: none;
    color: #FF5A5A; /* رنگ قرمز برای حس خطر و تأکید */
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
}

#ai-chat-close-btn:hover {
    color: #FF2E2E;
    transform: rotate(90deg);
}

.chat-body {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar Styles - مینیمال و تیز */
.chat-body::-webkit-scrollbar {
    width: 5px;
}
.chat-body::-webkit-scrollbar-track {
    background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
    background: var(--color-accent-gold);
    border-radius: 2.5px;
}
.chat-body::-webkit-scrollbar-thumb:hover {
    background: #e6b800;
}

.chat-footer {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-input {
    flex-grow: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: #2e1616;
    color: var(--color-text-primary);
    padding: 12px 18px;
    border-radius: 8px; /* گوشه‌های تیز برای حس مدرن */
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#chat-input:focus {
    border-color: var(--color-accent-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}
#chat-input::placeholder {
    color: var(--color-text-secondary);
}

.chat-btn {
    background-color: transparent;
    border: none;
    color: var(--color-text-secondary);
    width: 45px;
    height: 45px;
    border-radius: 8px; /* گوشه‌های تیز برای دکمه‌ها */
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-accent-gold);
}

#send-btn {
    background-color: var(--color-accent-gold);
    color: #1F1F1F;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4);
}
#send-btn:hover {
    background-color: #e6b800;
    transform: translateY(-2px); /* حرکت به بالا در حالت هاور */
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.6);
}

.chat-messages {
    flex-grow: 1;
}

.message {
    padding: 12px 18px;
    border-radius: 12px;
    margin-bottom: 10px;
    max-width: 85%;
    line-height: 1.6;
    font-size: 0.95rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.message.sent {
    background-color: #333333;
    color: var(--color-text-primary);
    align-self: flex-end;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.message.received {
    background-color: #D4AF37;
    color: #1F1F1F;
    align-self: flex-start;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

/* Styling for new chat header buttons */
.chat-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-action-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.header-action-btn:hover {
    color: var(--color-text-primary);
    transform: scale(1.1);
}

.close-btn {
    /* اطمینان از اینکه دکمه بسته شدن استایل‌های خاص خود را حفظ می‌کند */
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-btn:hover {
    color: #FF5A5A;
    transform: rotate(90deg) scale(1.1);
}
@media (max-width: 768px) {
    /* تنظیمات عمومی برای بدنه و کانتینر اصلی */
    body, #app-container {
        overflow-x: hidden; /* جلوگیری از اسکرول افقی اضافی */
    }

    /* --- هدر (Header) بهینه شده برای موبایل --- */
    .header {
        height: 60px; /* ارتفاع کمتر برای هدر */
        padding: 0 1rem;
    }

    #header-logo {
        font-size: 1.2rem;
        padding-top: 0;
    }

    #header-nav {
        display: none; /* پنهان کردن منوی اصلی برای جلوگیری از شلوغی */
    }
    
    #search-box {
        display: none; /* پنهان کردن باکس جستجو در هدر موبایل */
    }
    
    #header-right {
        gap: 0.5rem;
    }

    .language-switcher {
        /* تنظیم موقعیت دکمه زبان */
        padding-right: 0;
    }
    
    /* نمایش دکمه‌های مهم در هدر */
    #header-right #share-button,
    #header-right .language-switcher {
        display: flex; /* مطمئن شوید که این دکمه‌ها نمایش داده می‌شوند */
    }

    /* --- تغییرات در سایدبارها و پنجره‌های شناور --- */
    
    /* سایدبار اطلاعات (اطلاعات دوره) به صورت تمام صفحه */
    .sidebar-info {
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 1px;
        z-index: 1000;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }
    
    .sidebar-header {
        padding: 15px;
        position: sticky;
        top: 0;
    }

    .info-details {
        padding: 15px;
    }
    
    /* سایدبار نقشه‌ها (سمت راست) به صورت تمام صفحه */
    #sidebar-right.open {
        top: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        min-width: 100%;
        transition: transform 0.3s ease;
        transform: translateX(0);
        overflow-y: auto;
    }

    /* --- مرکز کردن صحیح پنجره‌های شناور --- */
    #share-modal #share-popup {
        width: 90%;
    }
    
    /* --- چت‌باکس AI بهینه شده --- */
    #ai-chat-box {
        bottom: 150px; /* بالای تایم‌لاین */
        right: 1%;
        transform: translateX(50%);
        width: 98%;
        height: 70%;
        max-width: none;
    }

    .ai-orb-container {
        top: 91px; /* موقعیت بالاتر از تایم‌لاین */
        right: 15px; /* فاصله از لبه سمت راست */
        width: 45px;
        height: 45px;
        box-shadow: 0 4px 10px rgba(64, 26, 26, 0.3); /* سایه کوچک‌تر */
    }

    .ai-orb {
        width: 22px;
        height: 22px;
    }

    .ai-orb-container:hover {
        transform: scale(1.05); /* افکت هاور کوچک‌تر */
    }

    /* --- تایم‌لاین (Timeline) --- */
    #timeline-container {
        height: 100px;
        padding: 0 0.5rem;
    }
    
    #timeline-slider-wrapper {
        width: 95%;
    }
    
    #timeline-years {
        width: 95%;
        top: 10px;
        overflow-x: auto;
        white-space: nowrap;
        justify-content: flex-start;
        gap: 2rem;
    }

    .timeline-label {
        min-width: auto;
    }
    
    #current-year-display {
        font-size: 1.2rem;
        top: 5px;
    }
}

/* --- استایل‌های جدید برای منوی موبایل --- */
.mobile-menu-toggle {
    display: none; /* به صورت پیش‌فرض در دسکتاپ پنهان است */
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    position: absolute; /* موقعیت‌یابی در هدر */
    top: 31px;
    transform: translateY(-50%);
    left: 126px; /* فاصله از لبه چپ */
    z-index: 100;
}

/* استایل‌دهی منوی موبایل (به صورت پیش‌فرض پنهان است) */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 87%;
    height: 100%;
    background-color: var(--color-bg-primary);
    transform: translateX(100%); /* منو را به خارج از صفحه منتقل می‌کند */
    transition: transform 0.4s ease-in-out;
    z-index: 2000;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.mobile-menu.open {
    transform: translateX(0); /* منو را به داخل صفحه می‌آورد */
}

.mobile-menu a {
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: 1.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-bg-secondary);
}

.mobile-menu .menu-header {
    display: flex;
    justify-content: flex-end;
}

.menu-close-btn {
    background: none;
    border: none;
    color: var(--color-text-primary);
    font-size: 1.8rem;
    cursor: pointer;
}

/* --- Media Query برای حالت موبایل --- */
@media (max-width: 768px) {
    /* نمایش دکمه منوی موبایل */
    .mobile-menu-toggle {
        display: block;
    }

    /* پنهان کردن لینک‌های ناوبری دسکتاپ و تغییر زبان */
    #header-nav,
    .language-switcher {
        display: none;
    }
}

/* --- Tooltip Style for Boundaries (for onEachBoundaryFeature) --- */
.boundary-tooltip {
    /* اطمینان از دیده شدن روی لایه‌های تیره */
    background-color: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-accent-gold);
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
    padding: 5px 10px;
    font-size: 0.9rem;
    font-weight: 500;
    /* تنظیمات خاص Leaflet برای Tooltip */
    white-space: nowrap; /* از شکستن خط جلوگیری می‌کند */
}
/* =========================================
   === استایل دکمه "مطالعه بیشتر" در سایدبار ===
   ========================================= */

#read-more-btn {
    display: inline-block; /* اجازه می‌دهد padding و margin بگیرد */
    margin-top: 25px; /* فاصله از متن بالایی */
    padding: 10px 24px; /* اندازه دکمه */
    
    /* استفاده از متغیرهای رنگی خودتان */
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: bold;
    text-align: center;
    text-decoration: none; /* حذف کامل خط زیر لینک */
    
    /* طراحی به سبک "دکمه شبح" (Ghost Button) */
    background-color: transparent;
    color: var(--color-accent-gold); /* رنگ متن طلایی */
    border: 2px solid var(--color-accent-gold); /* حاشیه طلایی */
    
    border-radius: 8px; /* گوشه‌های گرد (هماهنگ با سایت شما) */
    cursor: pointer;
    
    /* انیمیشن نرم */
    transition: all 0.3s ease;
}

#read-more-btn:hover {
    /* افکت هاور: دکمه پر می‌شود */
    background-color: var(--color-accent-gold);
    color: #473116; /* رنگ متن تیره (همرنگ پس‌زمینه سایدبار) */
    
    /* افکت کوچک بالا آمدن */
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* =========================================
   === استایل لینک "مطالعه بیشتر" در پاپ‌آپ نقشه ===
   ========================================= */
/* این کد استایل لینکی است که در پاپ‌آپ‌های Leaflet اضافه کردیم */

.map-popup-link {
    display: block;
    margin-top: 10px;
    padding: 8px 12px;
    
    /* استایل دکمه تو پُر (Solid) */
    background-color: var(--color-accent-gold);
    color: #1F1F1F; /* رنگ پس‌زمینه اصلی برای کنتراست */
    
    text-decoration: none;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.map-popup-link:hover {
    background-color: var(--color-bg-secondary);
    color: var(--color-accent-gold);
}

/* =========================================
   === بخش محتوای قابل اسکرول سایدبار اطلاعات ===
   ========================================= */
.sidebar-info .sidebar-content {
    flex-grow: 1; /* تمام فضای باقیمانده را می‌گیرد */
    padding: 20px; /* پدینگی که از کانتینر اصلی حذف کردیم */

    /* 🚀 راه‌حل اصلی: اسکرول‌بار عمودی فقط در صورت نیاز */
    overflow-y: auto; 
}

/* (اختیاری) استایل زیباسازی اسکرول‌بار برای تم تیره */
.sidebar-info .sidebar-content::-webkit-scrollbar {
    width: 6px;
}
.sidebar-info .sidebar-content::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
}
.sidebar-info .sidebar-content::-webkit-scrollbar-thumb {
    background-color: var(--color-accent-gold); /* همرنگ تم شما */
    border-radius: 3px;
}
.sidebar-info .sidebar-content::-webkit-scrollbar-thumb:hover {
    background-color: #fff; /* هایلایت در هاور */
}

/* =========================================
   === استایل اصلاح شده تایم‌لاین ایران‌ویج ===
   ========================================= */

#timeline-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 150px;
    background-color: rgba(31, 31, 31, 0.9);
    backdrop-filter: blur(15px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 50px;
    border-top: 1px solid rgba(212, 175, 55, 0.3);
}

/* محفظه اسلایدر */
#timeline-slider-wrapper {
    position: relative;
    width: 90%;
    max-width: 1400px;
    margin-top: 50px; /* فضا برای نمایشگر سال */
}

/* کانتینر لیبل‌های سال */
#timeline-years {
    position: relative;
    width: 100%;
    height: 75px; /* افزایش ارتفاع برای جای‌گیری لیبل‌های دوطبقه */
    margin-top: 10px;
}

/* استایل پایه لیبل‌ها */
.timeline-label {
    position: absolute;
    white-space: nowrap;
    font-size: 0.72rem;
    color: #888;
    cursor: pointer;
    transition: all 0.25s ease;
    transform: translateX(50%); /* برای سنتر شدن دقیق روی تیک سال */
    font-family: var(--font-main, sans-serif);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* خط تیک بالای هر سال */
.timeline-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 8px;
    background-color: rgba(212, 175, 55, 0.4);
}

/* چیدمان زیگزاگی (یکی در میان بالا و پایین) برای جلوگیری از هم‌پوشانی */
.timeline-label:nth-child(odd) {
    top: 0px;
    padding-top: 12px;
    padding-right: 17px;
}

.timeline-label:nth-child(even) {
    top: 28px; /* آیتم‌های زوج پایین‌تر قرار می‌گیرند */
    padding-top: 12px;
    padding-right: 15px;
}
.timeline-label:nth-child(even)::before {
    top: -28px;
    height: 36px; /* خط تیک بلندتر تا اسلایدر بالا */
    background-color: rgba(255, 255, 255, 0.2);
}

/* هاور و وضعیت فعال */
.timeline-label:hover,
.timeline-label.active {
    color: #e5c158;
    font-weight: bold;
    z-index: 10;
    font-size: 0.82rem;
}

.timeline-label.active::before {
    background-color: #e5c158;
    width: 2px;
}


/* جلوگیری از برخورد لیبل‌ها در رزولوشن‌های پایین */
@media (max-width: 1000px) {
    .timeline-label {
        font-size: 0.65rem;
    }
    /* نمایش یکی در میان پایین‌تر برای جلوگیری از هم‌پوشانی */
    .timeline-label:nth-child(even) {
        padding-top: 25px;
    }
    .timeline-label:nth-child(even)::before {
        height: 20px;
    }
}

/* استایل بدنه خود اسلایدر برای هماهنگی با تیک‌ها */
#timeline-slider {
    width: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 5;
}
#search-box {
    position: relative; /* برای تراز شدن دراپ‌داون */
}

.search-results-dropdown {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: #473116;
    border: 1px solid var(--color-accent-gold);
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 2000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    transition: background 0.2s;
}

.search-result-item:hover {
    background: rgba(212, 175, 55, 0.2);
    color: var(--color-accent-gold);
}

.search-result-item small {
    opacity: 0.8;
    margin-top: 2px;
    letter-spacing: 0.5px;
}
/* اصلاح کانتینر تایم‌لاین */
#timeline-years {
    position: relative;
    width: 100%;
    min-height: 60px;
}

@media (min-width: 769px) {
    #timeline-years {
        display: block !important;
        overflow: visible !important;
    }
    .timeline-label {
        position: absolute;
        white-space: nowrap;
        transform: translateX(50%);
    }
}

@media (max-width: 768px) {
    #timeline-years {
        display: flex !important;
        overflow-x: auto;
        padding: 0 50vw; /* پدینگ برای مرکز شدن آیتم‌ها در موبایل */
        scroll-behavior: smooth;
    }
    .timeline-label {
        position: relative !important;
        right: auto !important;
        transform: none !important;
        min-width: 120px;
    }
}

/* استایل نتایج جستجو */
.search-results-dropdown {
    position: absolute;
    top: 110%; left: 0; right: 0;
    background: #473116;
    border: 1px solid var(--color-accent-gold);
    border-radius: 8px;
    z-index: 2000;
    max-height: 250px;
    overflow-y: auto;
}


/* اطمینان از کلیک‌پذیری و اولویت پن مکان‌های تاریخی */
.leaflet-pane.leaflet-sitesPane-pane {
z-index: 650 !important;
}

.leaflet-sitesPane-pane path,
.leaflet-sitesPane-pane .leaflet-marker-icon {
pointer-events: auto !important;
cursor: pointer !important;
}

/* پن مرزها */
.leaflet-pane.leaflet-boundariesPane-pane {
z-index: 400 !important;
}

/* استایل مختصات در پاپ‌آپ نقشه */
.map-popup-coords {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 6px 0 10px 0;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--color-gold, #d4af37);
    border: 1px solid rgba(212, 175, 55, 0.2);
    direction: rtl;
}

/* استایل مختصات در سایدبار اطلاعات */
.sidebar-coords-box {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 3px solid var(--color-gold, #d4af37);
    border-radius: 0 6px 6px 0;
    font-size: 0.88rem;
    color: var(--color-text-secondary, #ccc);
    direction: rtl;
}

.sidebar-coords-box .coord-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sidebar-coords-box .coord-label {
    font-style: normal;
    color: var(--color-gold, #d4af37);
    font-weight: 500;
}


/* ============================================================
   MAP UI PROFESSIONAL V2 — CONSERVATIVE VISUAL POLISH
   IMPORTANT:
   - Preserves existing layout dimensions and positioning.
   - Preserves existing component sizes and behavior.
   - Visual refinement only.
   ============================================================ */

:root {
    --ui-gold: #d4af37;
    --ui-gold-soft: rgba(212, 175, 55, 0.18);
    --ui-panel: rgba(39, 31, 23, 0.94);
    --ui-panel-soft: rgba(55, 44, 33, 0.88);
    --ui-border: rgba(255, 255, 255, 0.10);
    --ui-border-gold: rgba(212, 175, 55, 0.30);
    --ui-text: #f3f0e9;
    --ui-muted: #b8b2a8;
}

/* ---------- Global typography: preserve sizes, improve rhythm ---------- */
body {
    font-family: var(--font-main), "Vazirmatn", Tahoma, sans-serif;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

/* ---------- Header: same 80px geometry, cleaner visual hierarchy ---------- */
.header {
    height: 80px;
    min-height: 80px;
    box-sizing: border-box;
    background:
        linear-gradient(180deg, rgba(71,49,22,0.98), rgba(60,42,21,0.98));
    border-bottom: 1px solid rgba(212,175,55,0.16);
    box-shadow: 0 2px 12px rgba(0,0,0,0.28);
}

#header-nav {
    gap: 2px;
}

#header-nav a {
    border-radius: 9px;
    transition: color .2s ease, background-color .2s ease;
}

#header-nav a:hover {
    background: rgba(212,175,55,0.08);
}

#search-box {
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}

#search-box:focus-within {
    border-color: rgba(212,175,55,0.42);
    background-color: rgba(131,122,110,0.58);
    box-shadow: 0 0 0 3px rgba(212,175,55,0.07);
}

#share-button:hover,
.user-avatar:hover {
    background-color: rgba(212,175,55,0.10);
    color: #fff;
}

.language-button:hover {
    border-color: rgba(212,175,55,0.35);
}

/* ---------- Map controls: retain 40px controls ---------- */
#map-controls-left {
    top: 2rem;
    right: 1rem;
}

#map-controls-left .control-group,
#sidebar-toggle-btn {
    border: 1px solid rgba(255,255,255,0.11);
    box-shadow: 0 5px 16px rgba(0,0,0,0.30);
}

#map-controls-left button {
    color: rgba(255,255,255,0.82);
}

#map-controls-left button:hover,
#sidebar-toggle-btn:hover {
    background-color: rgba(212,175,55,0.14);
    color: #fff;
}

/* ---------- Layers launcher: keep original position and dimensions ---------- */
.layer-fab-container {
    top: 27%;
    left: 4%;
    transform: translate(-50%, -50%);
}

.layers-toggle-label {
    box-sizing: border-box;
    min-height: 40px;
    border: 1px solid rgba(255,255,255,0.11);
    background: linear-gradient(180deg, #64451f, #55391b);
    box-shadow: 0 5px 16px rgba(0,0,0,0.28);
}

.layers-toggle-label:hover {
    background: linear-gradient(180deg, #705027, #5d3f1d);
    border-color: rgba(212,175,55,0.35);
}

.layers-dropdown-menu {
    width: 190px;
    background: rgba(43,31,19,0.97);
    border: 1px solid rgba(212,175,55,0.18);
    box-shadow: 0 14px 34px rgba(0,0,0,0.38);
}

.dropdown-option {
    min-height: 36px;
    box-sizing: border-box;
    border-bottom-color: rgba(255,255,255,0.08);
    transition: background-color .18s ease, padding-right .18s ease;
}

.dropdown-option:hover {
    background: rgba(212,175,55,0.08);
}

.dropdown-option input[type="checkbox"]:checked ~ .icon-checkbox {
    color: var(--ui-gold);
    text-shadow: 0 0 9px rgba(212,175,55,0.25);
}

.option-label {
    line-height: 1.8;
}

/* ---------- Historical data sidebar: preserve 400px geometry ---------- */
#sidebar-right {
    background:
        linear-gradient(180deg, rgba(71,49,22,0.97), rgba(43,31,19,0.98));
    border-left: 1px solid rgba(255,255,255,0.08);
    box-shadow: -10px 0 30px rgba(0,0,0,0.28);
}

#sidebar-right.open {
    width: 400px;
    min-width: 400px;
}

#sidebar-content {
    box-sizing: border-box;
}

#sidebar-header {
    background: rgba(131,122,110,0.20);
    border-bottom-color: rgba(212,175,55,0.20);
}

#sidebar-header h2 {
    color: #f5f1e8;
    line-height: 1.5;
}

.sidebar-tabs {
    border-bottom-color: rgba(255,255,255,0.10);
}

.sidebar-tabs button {
    line-height: 1.8;
    border-radius: 6px;
}

.sidebar-tabs button:hover {
    color: #fff;
    background: rgba(212,175,55,0.07);
}

.sidebar-tabs button.active {
    color: var(--ui-gold);
    background: rgba(212,175,55,0.06);
    border-bottom-color: var(--ui-gold);
}

/* ---------- Sidebar content: Persian typography + justified paragraphs ---------- */
.map-list,
.map-item,
.map-item-details,
.map-item-details p,
.map-item-details h3 {
    direction: rtl;
}

.map-item {
    border: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.035);
    box-shadow: 0 3px 12px rgba(0,0,0,0.12);
}

.map-item:hover {
    background: rgba(212,175,55,0.08);
    border-color: rgba(212,175,55,0.20);
}

.map-item-details h3 {
    line-height: 1.7;
}

.map-item-details p {
    line-height: 2;
    text-align: justify;
    text-justify: inter-word;
}

/* ---------- Period information drawer: preserve original 350px ---------- */
.sidebar-info {
    background:
        linear-gradient(180deg, rgba(71,49,22,0.98), rgba(39,30,22,0.99));
    border-right: 1px solid rgba(255,255,255,0.08);
    box-shadow: 10px 0 30px rgba(0,0,0,0.28);
}

.sidebar-header {
    background: linear-gradient(
        180deg,
        rgba(131,122,110,0.30),
        rgba(131,122,110,0.16)
    );
    border-bottom: 1px solid rgba(212,175,55,0.22);
    padding: 24px 30px;
}

.sidebar-header h2 {
    font-family: var(--font-main);
    line-height: 1.7;
    text-align: right;
}

.info-details {
    direction: rtl;
    text-align: right;
}

.info-details p,
.info-details .description,
.info-details .detail-description {
    text-align: justify;
    text-justify: inter-word;
    line-height: 2;
}

.detail-item {
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 5px 16px rgba(0,0,0,0.18);
}

#period-timeline {
    line-height: 1.8;
}

/* ---------- Timeline: preserve exact 150px height ---------- */
#timeline-container {
    height: 150px;
    box-sizing: border-box;
    border-top: 1px solid rgba(212,175,55,0.20);
    background:
        linear-gradient(
            180deg,
            rgba(31,31,31,0.88),
            rgba(24,24,24,0.96)
        );
    box-shadow: 0 -5px 22px rgba(0,0,0,0.30);
}

#timeline-bg {
    background:
        radial-gradient(
            circle at 50% 0%,
            rgba(212,175,55,0.12) 0%,
            rgba(31,31,31,0) 68%
        );
}

#current-year-display {
    line-height: 1.3;
    text-align: center;
}

#current-year-value,
#current-year-era {
    line-height: 1.3;
}

#timeline-slider {
    box-shadow:
        inset 0 1px 2px rgba(0,0,0,0.35),
        0 0 0 1px rgba(255,255,255,0.03);
}

#timeline-slider::-webkit-slider-thumb {
    box-shadow:
        0 2px 8px rgba(212,175,55,0.40),
        0 0 0 3px rgba(212,175,55,0.10);
}

#timeline-slider::-moz-range-thumb {
    box-shadow:
        0 2px 8px rgba(212,175,55,0.40),
        0 0 0 3px rgba(212,175,55,0.10);
}

#timeline-years {
    text-align: center;
}

.timeline-label {
    line-height: 1.8;
    text-align: center;
    font-family: var(--font-main);
}

.timeline-label.active {
    text-shadow: 0 0 10px rgba(212,175,55,0.22);
}

/* ---------- Search result / popup typography ---------- */
.search-results-dropdown {
    background: rgba(43,31,19,0.98);
    border-color: rgba(212,175,55,0.25);
    box-shadow: 0 12px 30px rgba(0,0,0,0.38);
}

.search-result-item {
    line-height: 1.7;
}

.search-result-item:hover {
    background: rgba(212,175,55,0.09);
}

.leaflet-popup-content {
    direction: rtl;
    text-align: right;
    font-family: var(--font-main);
    line-height: 1.8;
}

.leaflet-popup-content p {
    text-align: justify;
    line-height: 1.9;
}

/* ---------- Keep mobile geometry stable ---------- */
@media (max-width: 768px) {
    .header {
        height: 60px;
        min-height: 60px;
    }

    .layer-fab-container {
        top: 27%;
        left: 14%;
        transform: translate(-50%, -50%);
    }

    #sidebar-right.open {
        width: min(400px, 92vw);
        min-width: min(400px, 92vw);
    }

    #timeline-container {
        height: 150px;
    }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
