/* =========================================== */
/* Global Resets & Fonts          */
/* =========================================== */
/* MODIFIED: Allow vertical scrolling for the whole page */
html {
    height: 100%;
}
body, html {
    overflow-x: hidden;
}

body {
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #181a1b;
    color: #e6ecf5;
    display: flex;
    flex-direction: column;
}

* {
    box-sizing: border-box;
}

/* =========================================== */
/* Top Banner                     */
/* =========================================== */
#top-banner {
    background-color: #24282a;
    padding: 2rem;
    text-align: center;
    position: relative;
    flex-shrink: 0;
    z-index: 2000;
}

#top-banner h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    color: #e6ecf5;
    margin-top: 0;
    margin-bottom: 0.75rem;
}

#top-banner p {
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    color: #a0aab4;
    max-width: 650px;
    line-height: 1.6;
    margin: 0 auto 1.5rem auto;
}

.go-to-main-btn {
    display: inline-block;
    background-color: #dc5a50;
    color: #fff;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s;
}

.go-to-main-btn:hover {
    background-color: #be3c32;
}

/* =========================================== */
/* Map Layout Container           */
/* =========================================== */
.map-editor-container {
    display: flex;
    position: relative;
    height: 100vh;
}

.map-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

#map {
    flex-grow: 1;
    background-color: transparent !important;
    z-index: 100;
}

/* =========================================== */
/* Top Bar                      */
/* =========================================== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    height: 60px; /* --toolbar-size */
    background-color: #24282a;
    border-bottom: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
    z-index: 1050;
    flex-shrink: 0;
}

.site-name-link {
    display: flex;
    align-items: center;
    color: #e6ecf5;
    text-decoration: none;
    font-size: 1.2em;
    font-weight: 600;
}
.site-name-link img {
    height: 35px;
    width: auto;
    margin-right: 12px;
}

.top-bar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar-controls button {
    background-color: #32383b;
    color: #e6ecf5;
    border: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
    border-radius: 6px;
    padding: 8px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    white-space: nowrap;
    height: 38px;
}

.top-bar-controls #uploadImageBtn,
.top-bar-controls .remove-btn {
    width: 38px;
    padding: 0;
    font-size: 1.1em;
}

.top-bar-controls button:hover {
    background-color: rgba(60, 68, 72, 0.5);
}
.top-bar-controls .remove-btn {
    background-color: #dc5a50;
    border-color: #dc5a50;
    color: #fff; /* Ensure text is white for danger buttons */
}
.top-bar-controls .remove-btn:hover {
    background-color: #be3c32;
}

.select2-container { min-width: 150px; }
.select2-container--default .select2-selection--single {
    background-color: #32383b !important;
    border: 1px solid rgba(100, 110, 120, 0.3) !important; /* New border color */
    height: 38px !important;
    border-radius: 6px !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #e6ecf5 !important;
    line-height: 36px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #e6ecf5 transparent transparent transparent !important;
}
.select2-dropdown {
    background-color: #24282a !important;
    border-color: #46aaff !important;
}
.select2-search__field { background-color: #181a1b !important; color: #e6ecf5 !important; }
.select2-results__option--highlighted { background-color: #32383b !important; }
.select2-results__option { color: #e6ecf5; }


/* =========================================== */
/* Main Toolbar (Base)          */
/* =========================================== */
.main-toolbar {
    display: flex;
    flex-direction: column;
    background-color: #24282a;
    z-index: 1010;
    box-shadow: 0 0 15px rgba(0,0,0,0.5); /* Darker shadow for dark mode */
    height: 100%;
    border-top: 5px solid #46aaff;
    border-bottom: 5px solid #46aaff;
    border-left: 5px solid #46aaff;
    border-radius: 12px;
}

.main-toolbar button {
    background: none;
    border: none;
    color: #a0aab4;
    font-size: 1.3em;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.main-toolbar button:hover {
    background-color: rgba(60, 68, 72, 0.5);
    color: #46aaff;
}
.main-toolbar button.active-tool {
    background-color: #46aaff;
    color: #181a1b; /* Text color on accent background */
}
.main-toolbar button:disabled {
    color: rgb(120, 130, 140); /* New disabled color */
    cursor: not-allowed;
}
.main-toolbar button:disabled:hover {
    background: none;
}
.main-toolbar button img {
    width: 24px;
    height: 24px;
}

.toolbar-divider {
    border-left: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
    border-top: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
    margin: 10px 5px;
    flex-shrink: 0;
}

.scene-controls {
    display: flex;
    gap: 5px;
    align-items: center;
}

/* MODIFIED: يجعل أزرار الحفظ والأرقام أفقية في وضع الهاتف */
.scene-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    gap: 2px;
}
.scene-card button {
    height: auto;
    width: auto;
    padding: 2px 5px;
    border-radius: 4px;
    min-width: unset;
}
.scene-card .scene-restore-button {
    font-size: 1em;
    font-weight: bold;
    background-color: #32383b;
    color: #e6ecf5; /* Ensure text color is accessible */
}
.scene-card .scene-save-button {
    font-size: 0.8em;
    font-weight: bold;
    background-color: rgb(80, 90, 100); /* New save button color */
    color: #fff; /* White text for contrast */
}

/* =========================================== */
/* Analysis Sidebar (Right)       */
/* =========================================== */
#analysisSidebar{
    position: absolute;
    top: 60px;
    right: -350px;
    width: 300px;
    height: 80%;
    background-color: #24282a;
    box-shadow:-5px 0 15px rgba(0,0,0,0.5); /* Darker shadow */
    z-index: 1100;
    transition: right .4s ease-in-out;
    padding: 20px;
    overflow-y: auto;
    border-left: 6px solid #46aaff;
    border-top: 6px solid #46aaff;
    border-bottom: 6px solid #46aaff;
}
#analysisSidebar.open{ right: 0; }
#sidebarCloseBtn{
    position:absolute; top:10px; left:15px; color:#a0aab4; font-size:28px;
    font-weight:700; cursor:pointer; background: none; border: none; padding: 0;
    width: 48px; height: 48px;
}
#sidebarCloseBtn:hover{ color: #e6ecf5; }
#analysisSidebar h2{ color:#e6ecf5; text-align:center; margin-top:10px; margin-bottom:25px; padding-bottom:10px; border-bottom:1px solid #32383b; }
#sidebarIconsContainer{ display:grid; grid-template-columns:repeat(auto-fill,minmax(48px,1fr)); gap:15px; justify-items:center; }
#sidebarIconsContainer img{ width:48px; height:48px; cursor:pointer; transition:.2s; padding:3px; border-radius:4px; border:1px solid transparent; background-color: #32383b; object-fit:contain; }
#sidebarIconsContainer img:hover{ transform:scale(1.1); border-color:#46aaff; }
#sidebarIconsContainer img.active-tool{ border-color:#46aaff; box-shadow:0 0 8px rgba(70, 170, 255, 0.7); /* Accent color for shadow */ transform:scale(1.15); }

/* =========================================== */
/* Leaflet Overrides            */
/* =========================================== */
.leaflet-bar { border-radius: 6px !important; }
.leaflet-bar a, .leaflet-bar a:hover {
    background-color: #24282a !important;
    color: #e6ecf5 !important;
    border-bottom: 1px solid #32383b !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
}
.map-text-label {
    display: inline-block;
    background-color: rgba(36, 40, 42, 0.9); /* Secondary bg with transparency */
    color: rgb(230, 236, 245); /* Primary text for readability */
    border: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4); /* Darker shadow */
    white-space: nowrap;
}
.country-flag-icon{ border:1px solid rgba(100, 110, 120, 0.3); /* New border color */ box-shadow:0 1px 3px rgba(0,0,0,0.4); /* Darker shadow */ }


/* ================================================================== */
/* NEW: Fixed Image Container Styles                      */
/* ================================================================== */
#fixed-image-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgb(18, 20, 21); /* Almost Black */
    background-size: cover;
    background-position: center;
    z-index: 1;
}
#fixed-image-container img {
    display: none;
}


/* ================================================================== */
/* MOBILE & DESKTOP LAYOUTS                          */
/* ================================================================== */
.map-editor-container { flex-direction: column-reverse; }

.main-toolbar {
    flex-direction: row;
    align-items: center;
    width: 100%;
    height: 60px; /* --toolbar-size */
    border-top: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
    padding: 0 10px;
    gap: 10px;
    overflow-x: auto;
}

.main-toolbar button {
    height: 45px;
    width: 50px;
    min-width: 50px;
    border-radius: 4px;
}

.toolbar-divider { display: none; }
.scene-controls { flex-direction: row; }
.leaflet-control-zoom { position: 'topleft'; margin-left: 10px; margin-top: 10px; }
.site-name-link span { display: none; }
.scene-divider { display: none; }

.main-toolbar::-webkit-scrollbar {
    height: 6px;
    width: 8px;
}
.main-toolbar::-webkit-scrollbar-track {
    background: transparent;
}
.main-toolbar::-webkit-scrollbar-thumb {
    background: #32383b;
    border-radius: 4px;
}
.main-toolbar::-webkit-scrollbar-thumb:hover {
    background: #46aaff;
}
#analysisSidebar::-webkit-scrollbar {
    width: 8px;
}
#analysisSidebar::-webkit-scrollbar-track {
    background-color: #24282a;
}
#analysisSidebar::-webkit-scrollbar-thumb {
    background-color: #32383b;
    border-radius: 4px;
    border: 1px solid #24282a;
}
#analysisSidebar::-webkit-scrollbar-thumb:hover {
    background-color: #46aaff;
}

@media (min-width: 769px) {
    .map-editor-container {
        flex-direction: row;
        height: 100vh;
    }
    .main-toolbar {
        position: absolute;
        top: 60px; /* --toolbar-size */
        left: 0;
        height: 900px;
        flex-direction: column;
        justify-content: flex-start;
        width: 60px; /* --toolbar-size */
        padding: 9px 0;
        gap: 10px;
        border-top: none;
        border-right: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
        overflow-x: hidden;
        overflow-y: auto;
        border-top: 5px solid #46aaff;
        border-bottom: 5px solid #46aaff;
        border-left: 5px solid #46aaff;
        border-radius: 12px;
    }
    .main-toolbar button {
        width: 100%;
        height: auto;
        padding: 10px 0;
    }
    .toolbar-divider {
        display: block;
        border-top: none;
        border-left: none;
        width: 80%;
        height: 1px;
        background-color: rgba(100, 110, 120, 0.3); /* New border color */
        margin: 5px auto;
    }
    .scene-controls {
        flex-direction: column;
        width: 100%;
        padding: 0 5px;
        gap: 8px;
    }

    /* MODIFIED: تصحيح عرض الأزرار في وضع سطح المكتب */
    .scene-card {
        display: flex;
        flex-direction: column; /* تم تصحيح هذا السطر */
        flex-shrink: 0;
        width: 100%;
        gap: 0;
    }

    .scene-card button {
        height: auto;
        width: 100%;
        padding-top: 2px;
        padding-bottom: 2px;
        border-radius: 0;
        min-width: unset;
    }
    .scene-card .scene-restore-button {
        border-radius: 8px 8px 0 0;
        font-size: 2em;
        font-weight: bold;
        background-color: #32383b;
        color: #e6ecf5; /* Ensure text color is accessible */
        margin-bottom: 9px
    }
    .scene-card .scene-save-button {
        border-radius: 0 0 8px 8px;
        font-size: 2em;
        font-weight: bold;
        padding-top: 1px;
        padding-bottom: 1px;
        background-color: rgb(80, 90, 100); /* New save button color */
        color: #fff; /* White text for contrast */

    }

    .site-name-link span { display: inline; }
    .scene-divider { display: block; }
}

/* ================================================================== */
/* ACCESSIBILITY IMPROVEMENTS                        */
/* ================================================================== */
button:focus,
a:focus,
.select2-container--default .select2-selection--single:focus {
    outline: 3px solid #46aaff !important;
    outline-offset: 2px;
    box-shadow: 0 0 10px #46aaff;
    border-color: #46aaff !important;
}

/* ================================================================== */
/* NEW: FEATURES SECTION STYLES                      */
/* ================================================================== */
#features-section {
    background-color: #24282a;
    padding: 4rem 2rem;
}

#features-section h2 {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 600;
    color: #e6ecf5;
    margin-top: 0;
    margin-bottom: 3rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.feature-card {
    background-color: #32383b;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(100, 110, 120, 0.3); /* New border color */
}

.feature-card i {
    font-size: 2.5rem;
    color: #46aaff;
    margin-bottom: 1.5rem;
}

.feature-card h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #e6ecf5;
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.feature-card p {
    color: #a0aab4;
    line-height: 1.6;
    margin: 0;
}
/* =========================================== */
/* Footer Styles                  */
/* =========================================== */
.footer {
    margin-top: 50px;
    width: 100%;
    background-color: #181a1b;
    color: #e6ecf5;
    text-align: center;
    padding: 15px 20px;
    z-index: 2000;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.5); /* Darker shadow */
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 14px;
}

.footer-links {
    margin-bottom: 8px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: #46aaff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: rgb(120, 200, 255); /* Lighter shade of accent on hover for links */
    text-decoration: underline;
}

.copyright {
    margin: 0;
    font-size: 12px;
    color: #a0aab4;
}