/* ===================================================
   SHENDESTAN WEBGIS – PRODUCTION STYLESHEET
   NATIVE POPUP MAP DESIGN SYSTEM
   =================================================== */

/* 1. GLOBAL PAGE SETTINGS */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* 2. FIXED TOP PROJECT HEADER (Updated for Responsiveness) */
#project-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    direction: ltr;
    box-sizing: border-box;
}

.header-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo img {
    max-height: 50px;
    width: auto;
    object-fit: contain;
}

.header-center-text {
    flex: 1;
    text-align: center;
    padding: 0 10px;
}

.header-center-text h1 {
    font-size: 18px;
    margin: 0;
    font-weight: 700;
    color: #1f4e79;
}

.header-center-text p {
    font-size: 12px;
    margin: 4px 0 0 0;
    color: #555;
    line-height: 1.4;
}

/* 3. MAP CONTAINER SETUP (Responsive Top Anchor) */
#map {
    position: absolute;
    top: 70px;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1;
}

/* 4. ADVANCED POPUP CUSTOMIZATION (Responsive Widths) */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    box-shadow: 0 3px 14px rgba(0,0,0,0.3);
}

.leaflet-popup-content {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 !important;
    width: 280px !important;
}

/* Popup Scrollbar Style */
.leaflet-popup-content::-webkit-scrollbar {
    width: 6px;
}
.leaflet-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.leaflet-popup-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.leaflet-popup-content::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Popup Table Layout */
.custom-popup {
    display: flex;
    flex-direction: column;
}

.popup-header {
    color: white;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 0.5px;
}

.popup-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: bold;
    color: white;
}

.popup-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.popup-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.popup-table td {
    padding: 8px 12px;
    font-size: 12px;
    border-bottom: 1px solid #eee;
}

.popup-table td.label {
    font-weight: bold;
    color: #222;
    width: 45%;
}

.popup-table td.value,
.custom-popup .popup-table td.value {
    font-weight: 600;
    color: #2c3e50;
    word-break: break-all;
}

/* 5. MAP UTILITIES & CONTROLS */
.coordinates-control {
    background: rgba(255, 255, 255, 0.85);
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 11px;
    font-family: monospace;
    font-weight: bold;
    color: #333;
    box-shadow: 0 1px 5px rgba(0,0,0,0.15);
}

/* Home Extent Button Style */
.leaflet-home-control a {
    background-color: #fff;
    width: 30px;
    height: 30px;
    line-height: 30px;
    display: block;
    text-align: center;
    text-decoration: none;
    color: #333;
    font-size: 16px;
    transition: background-color 0.2s, color 0.2s;
}

.leaflet-home-control a:hover {
    background-color: #f4f4f4;
    color: #1f4e79;
}

/* Leaflet Layer Infrastructure Base Control */
.leaflet-control-layers {
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
    padding: 10px !important;
    max-height: 85vh;
    overflow-y: auto;
}

.leaflet-control-layers-overlays label {
    font-size: 12px;
    cursor: pointer;
    margin-bottom: 4px;
    display: block;
}

/* Tree Structure Grouped Layer Control Customization */
.leaflet-control-layers-group-name {
    font-weight: bold;
    color: #1f4e79;
    border-bottom: 1px dashed #ddd;
    margin-top: 8px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    font-size: 13px;
}

.leaflet-control-layers-group {
    margin-bottom: 10px;
    padding-left: 5px;
}

/* 6. INTEGRATED NATIVE POPUP PDF HANDLER STYLES */
.popup-logplot-container {
    text-align: center;
    margin-top: 0;
    padding: 10px 12px;
    background: #fdfaf4;
    border-top: 1px dashed #eee;
}

.pdf-link {
    color: #e67e22;
    text-decoration: none;
    font-weight: bold;
    font-size: 12px;
    display: inline-block;
    transition: color 0.2s;
}

.pdf-link:hover {
    color: #d35400;
    text-decoration: underline;
}

/* ===================================================
   7. RESPONSIVE MEDIA QUERIES FOR MOBILE & TABLETS
   =================================================== */

/* Tablet and Mobile Screen Adaptations */
@media (max-width: 768px) {
    #project-header {
        height: 55px;
        padding: 0 10px;
    }

    .header-logo img {
        max-height: 35px;
    }

    .header-center-text h1 {
        font-size: 13px;
    }

    .header-center-text p {
        font-size: 9px;
        margin: 2px 0 0 0;
    }

    #map {
        top: 55px;
    }

    /* Adjust popup size for smaller screens */
    .leaflet-popup-content {
        width: 240px !important;
        max-height: 240px;
    }

    .popup-header {
        font-size: 12px;
        padding: 8px 10px;
    }

    .popup-table td {
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Hide MiniMap on small screens to save space */
    .leaflet-control-minimap {
        display: none !important;
    }
}

/* Ultra Small Screens (Vertical Mobile) */
@media (max-width: 480px) {
    .header-center-text p {
        display: none; /* Hide subtitles on very small screen */
    }
    
    .leaflet-control-layers {
        max-width: 180px; /* Constrain layer control width */
    }
}

/* ===================================================
   8. RESPONSIVE MEDIA QUERIES FOR LARGE SCREENS
   =================================================== */

/* Desktop & Large Monitor Adaptations */
@media (min-width: 1200px) {
    /* Limit the center text width to prevent ultra-wide stretching */
    .header-center-text {
        max-width: 600px;
        margin: 0 auto;
    }

    .header-center-text h1 {
        font-size: 20px; /* Slightly larger heading for big screens */
        letter-spacing: 0.5px;
    }

    /* Expand popups slightly for high-resolution data viewing */
    .leaflet-popup-content {
        width: 310px !important;
        max-height: 400px; /* Allow more visible rows without scrolling */
    }

    .popup-header {
        font-size: 15px;
        padding: 12px;
    }

    .popup-table td {
        padding: 10px 14px;
        font-size: 13px;
    }

    /* Make the tree layer control more prominent and structured */
    .leaflet-control-layers {
        min-width: 220px;
        max-height: 75vh;
        background: rgba(255, 255, 255, 0.95) !important;
    }
}

/* Ultra-Wide Monitor Safeguards */
@media (min-width: 1920px) {
    /* Add a subtle inner shadow to the map for better framing on huge screens */
    #map {
        box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    }

    /* Keep the control layers perfectly readable */
    .leaflet-control-layers {
        min-width: 250px;
    }
    
    .leaflet-control-layers-group-name {
        font-size: 14px;
        margin-top: 12px;
    }
}

/* ==========================================================================
   9. POPUP MEDIA RESOURCING (IMAGES, VIDEOS & LIGHTBOX DESIGN SYSTEM)
   ========================================================================== */

.popup-image {
    width: 100%;
    padding: 8px 0;
    text-align: center;
}

.popup-image img {
    max-width:100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.popup-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.popup-video {
    width: 100%;
    padding: 8px 0;
    text-align: center;
}

.popup-video video {
    width: 100%;
    max-height: 200px;
    border-radius: 6px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    outline: none;
}

/* --- LIGHTBOX MODAL CONTAINER (GOURI-STYLE COMPATIBLE) --- */
.lightbox {
    display: none; 
    position: fixed;
    z-index: 99999 !important; /* انتقال به بالاترین لایه فوقانی مرورگر فوق هدر و نقشه */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
    overflow: hidden;
    box-sizing: border-box;
}

/* تراز وسط کردن محتوای عکس درون گالری */
.lightbox-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    max-width: 85%;
    max-height: 85vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    user-select: none;
    animation: zoomInEffect 0.25s ease-out;
}

/* افکت انیمیشن باز شدن نرم عکس */
@keyframes zoomInEffect {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* دکمه بستن لایت باکس */
.close-lightbox {
    position: absolute;
    top: 20px;
    right: 25px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 100000;
    transition: color 0.2s, transform 0.2s;
    user-select: none;
}

.close-lightbox:hover {
    color: #ff4d4d;
    transform: scale(1.1);
}

/* دکمه‌های ناوبری چپ و راست گالری */
.prev-img, .next-img {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff;
    font-size: 36px;
    font-weight: bold;
    padding: 12px 20px;
    background-color: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    z-index: 100000;
    user-select: none;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.prev-img:hover, .next-img:hover {
    background-color: rgba(255, 255, 255, 0.9);
    color: #333333;
}

.prev-img {
    left: 20px;
}

.next-img {
    right: 20px;
}

.prev-img:active { 
    transform: translateY(-50%) scale(0.95); 
    left: 18px; 
}

.next-img:active { 
    transform: translateY(-50%) scale(0.95); 
    right: 18px; 
}