/* ==========================================================================
   Indian Map Project - Master Studio Stylesheet
   ========================================================================== */

/* Base & Typography */
html, body {
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #F8FAFC;
    color: #0F172A;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Map Container Layout */
.map-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    background-color: #F1F5F9;
}

/* Custom Styled Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #94A3B8;
}

/* Sidebar Dock Layout & Collapsed State (Side-by-side Flex Layout on Desktop) */
@media (min-width: 640px) {
    #settingsPanel {
        transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    }
    #settingsPanel.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
        border-right-width: 0 !important;
        pointer-events: none !important;
    }
}

@media (max-width: 639px) {
    #settingsPanel {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 85vh !important;
        z-index: 1001 !important;
        border-top-left-radius: 1rem !important;
        border-top-right-radius: 1rem !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    #settingsPanel.collapsed {
        transform: translateY(120%) !important;
    }
}

/* Visual Card Picker Radio Input */
.layer-card-input:checked + .layer-card-body {
    border-color: #0D9488 !important;
    background-color: #F0FDF4 !important;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.15) !important;
}
.layer-card-input:checked + .layer-card-body .layer-card-icon {
    color: #0D9488 !important;
}
.layer-card-input:checked + .layer-card-body .layer-card-check {
    opacity: 1 !important;
    transform: scale(1) !important;
}

/* Custom Toggle Switch Control */
.toggle-checkbox:checked {
    right: 2px;
    border-color: #0D9488;
}
.toggle-checkbox:checked + .toggle-label {
    background-color: #0D9488;
}
.toggle-checkbox {
    right: calc(100% - 22px);
}

/* Point Addition Crosshair Mode */
.cursor-crosshair {
    cursor: crosshair !important;
}

/* Dedicated Map-Click Custom Leaflet Popup */
.custom-map-click-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid #E2E8F0;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    background: #FFFFFF;
}
.custom-map-click-popup .leaflet-popup-content {
    margin: 0;
    width: 260px !important;
    max-width: 85vw !important;
    line-height: 1.4;
    font-family: 'Inter', sans-serif;
}
.custom-map-click-popup .leaflet-popup-close-button {
    display: none;
}
.custom-map-click-popup .leaflet-popup-tip-container {
    margin-top: -1px;
}

/* Leaflet DivIcon Overrides */
.leaflet-div-icon {
    background: transparent;
    border: none;
}

:root {
    --label-font-family: 'Inter', sans-serif;
    --label-font-size: 11px;
    --label-font-color: #0F172A;
    --label-font-weight: 700;
}

/* Custom Indian State Map Tooltip Labels */
.leaflet-tooltip.state-label-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--label-font-color, #0F172A) !important;
    font-family: var(--label-font-family, 'Inter', sans-serif) !important;
    font-weight: var(--label-font-weight, 400) !important;
    font-size: var(--dynamic-state-font-size, var(--label-font-size, 8px)) !important;
    text-transform: var(--label-text-transform, capitalize) !important;
    letter-spacing: 0.05em !important;
    text-shadow: var(--label-text-shadow, 0px 0px 4px rgba(255, 255, 255, 0.95), 0px 0px 6px rgba(255, 255, 255, 0.9)) !important;
    padding: 0 !important;
    transition: font-size 0.1s ease-out;
}
.leaflet-tooltip.state-label-tooltip::before {
    display: none !important;
}

/* City Label Marker Styling */
.city-label-icon {
    color: var(--label-font-color, #334155);
    font-family: var(--label-font-family, 'Inter', sans-serif);
    font-weight: var(--label-font-weight, 400) !important;
    font-size: var(--dynamic-city-font-size, var(--label-font-size, 8px));
    text-transform: var(--label-text-transform, capitalize) !important;
    text-shadow: var(--label-text-shadow, 0px 0px 4px rgba(255, 255, 255, 0.95), 0px 0px 6px rgba(255, 255, 255, 0.9));
    white-space: nowrap;
    text-align: center;
    transition: font-size 0.1s ease-out;
}
.city-dot {
    width: 5px;
    height: 5px;
    background: #0D9488;
    border: 1.5px solid #FFFFFF;
    border-radius: 50%;
    margin: 0 auto 2px auto;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Rich Text Editor & Leaflet Popup Bullet List Formatting */
#editPinTitleRichEditor ul,
.leaflet-popup-content ul {
    list-style-type: disc !important;
    padding-left: 1.25rem !important;
    margin-top: 0.25rem !important;
    margin-bottom: 0.25rem !important;
}
#editPinTitleRichEditor ol,
.leaflet-popup-content ol {
    list-style-type: decimal !important;
    padding-left: 1.25rem !important;
    margin-top: 0.25rem !important;
    margin-bottom: 0.25rem !important;
}
#editPinTitleRichEditor li,
.leaflet-popup-content li {
    display: list-item !important;
    margin-bottom: 0.125rem !important;
}

/* Hide State & City Map Labels Utilities */
.hide-state-labels .state-label-tooltip,
.leaflet-tooltip.state-label-tooltip.hide-label {
    display: none !important;
}

.hide-city-labels .city-label-icon {
    display: none !important;
}

/* Auto-Hide State & City Labels When Zoomed Out (Zoom < 6) */
.zoom-hide-state-labels .state-label-tooltip,
.zoom-hide-state-labels .leaflet-tooltip.state-label-tooltip,
.zoom-hide-city-labels .city-label-icon,
#map.zoom-hide-state-labels .leaflet-tooltip-pane .leaflet-tooltip {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Country Center Label (Shown When Zoomed Out - India / Bharat / Hindustan) */
.country-label-icon {
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}
.country-label-title {
    font-family: var(--label-font-family, 'Inter', sans-serif);
    font-size: var(--country-title-size, 16px);
    font-weight: 900;
    color: #0F172A;
    letter-spacing: var(--country-letter-spacing, 0.18em);
    text-transform: uppercase;
    transition: font-size 0.12s ease-out, letter-spacing 0.12s ease-out;
    text-shadow: 0px 0px 8px rgba(255, 255, 255, 0.98), 0px 0px 14px rgba(255, 255, 255, 0.95);
}
.country-label-sub {
    font-family: var(--label-font-family, 'Inter', sans-serif);
    font-size: var(--country-sub-size, 10px);
    font-weight: 800;
    color: #0D9488;
    letter-spacing: calc(var(--country-letter-spacing, 0.18em) + 0.05em);
    text-transform: uppercase;
    margin-top: 1px;
    transition: font-size 0.12s ease-out;
    text-shadow: 0px 0px 6px rgba(255, 255, 255, 0.95);
}

/* Floating Search Auto-Complete Dropdown */
.search-results-dropdown {
    max-height: 240px;
    overflow-y: auto;
}

/* Live Zoom Count Badge Above Plus/Minus Controls */
.leaflet-zoom-badge {
    background: #0F172A;
    color: #FFFFFF;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 800;
    text-align: center;
    padding: 5px 4px;
    border-bottom: 1px solid #E2E8F0;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    letter-spacing: 0.05em;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1);
    line-height: 1;
    select: none;
}

/* Pulse animation for active Add Point mode */
@keyframes pulse-ring {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}
.animate-pulse-ring {
    animation: pulse-ring 2s infinite ease-in-out;
}

/* Glassmorphism Classes */
.glass-panel {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Modal Open Backstage Lock */
body.modal-open {
    overflow: hidden;
}

/* Custom Brand Loading Splash Overlay */
.brand-splash-overlay {
    position: absolute;
    inset: 0;
    z-index: 2500;
    background: transparent;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand-splash-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.brand-splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    transform: scale(0.9);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand-splash-overlay.active .brand-splash-content {
    transform: scale(1);
}

.brand-splash-img {
    max-width: 260px;
    max-height: 140px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.15));
    animation: logoPulse 2.2s infinite ease-in-out;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.brand-splash-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(13, 148, 136, 0.2);
    border-top-color: #0D9488;
    border-radius: 50%;
    animation: splashSpin 0.8s linear infinite;
}

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

.brand-splash-text {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: #0F172A;
    letter-spacing: 0.02em;
}

/* Custom Standalone Logo Badge Positioned Above Existing "Created With" Tag (Left Side, Matching Width) */
.brand-watermark-badge {
    position: absolute;
    bottom: 38px;
    left: 12px;
    z-index: 1000;
    width: 165px;
    max-width: calc(100% - 24px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid #CBD5E1;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.brand-watermark-badge.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.brand-watermark-img {
    max-width: 140px;
    max-height: 36px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.brand-splash-overlay.morphing {
    opacity: 0;
    transform: scale(0.2) translate(-150%, 150%);
    pointer-events: none;
}

/* Geocoding Result Marker & Pulse Animation */
@keyframes geocodePing {
    0% {
        transform: scale(0.8);
        opacity: 0.9;
    }
    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

.geocode-result-icon {
    background: transparent;
    border: none;
}

/* Printable Map & Print Styles */
@media print {
    @page {
        size: auto;
        margin: 0;
    }
    body {
        background: white !important;
    }
    body * {
        visibility: hidden !important;
    }
    #printPreviewCompositionStage, #printPreviewCompositionStage *, #printPreviewComposition, #printPreviewComposition * {
        visibility: visible !important;
    }
    #printPreviewCompositionStage, #printPreviewComposition {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        box-shadow: none !important;
        border: none !important;
        background: white !important;
        margin: 0 !important;
    }
}

/* Custom "Use My Location" Leaflet Map Control Button */
.leaflet-control-location-box {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border: 1px solid #E2E8F0;
    overflow: hidden;
    margin-top: 8px !important;
}
.leaflet-control-location-btn {
    background: #ffffff;
    border: none;
    padding: 6px 9px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: #0F172A;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    height: 32px;
    min-width: 32px;
}
.leaflet-control-location-btn:hover {
    background: #F8FAFC;
    color: #0D9488;
}
.leaflet-control-location-btn.locating {
    color: #0D9488;
    background: #F0FDF4;
}
.leaflet-control-location-btn.active {
    color: #0D9488;
    background: #CCFBF1;
    font-weight: 800;
}
.location-icon {
    font-size: 13px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.location-btn-label {
    max-width: 120px;
    opacity: 1;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin 0.3s ease;
    display: inline-block;
    vertical-align: middle;
}

/* Collapsed Icon-Only State (Triggered after 4s initial load timer) */
.leaflet-control-location-btn.collapsed .location-btn-label,
#btnUseMyLocationHeader.collapsed .location-btn-label {
    max-width: 0px !important;
    opacity: 0 !important;
    margin: 0 !important;
}

/* Expand label smoothly on hover */
.leaflet-control-location-btn.collapsed:hover .location-btn-label,
#btnUseMyLocationHeader.collapsed:hover .location-btn-label {
    max-width: 120px !important;
    opacity: 1 !important;
    margin-left: 2px !important;
}

/* User Location GPS Marker Pulse Animation */
.user-location-div-icon {
    background: transparent;
    border: none;
}
.user-location-marker {
    position: relative;
    width: 24px;
    height: 24px;
}
.user-location-dot {
    width: 14px;
    height: 14px;
    background: #0D9488;
    border: 2.5px solid #FFFFFF;
    border-radius: 50%;
    position: absolute;
    top: 5px;
    left: 5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    z-index: 2;
}
.user-location-pulse {
    width: 24px;
    height: 24px;
    background: rgba(13, 148, 136, 0.38);
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    animation: userLocationPulse 2s infinite ease-out;
    z-index: 1;
}
@keyframes userLocationPulse {
    0% { transform: scale(0.5); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* Custom Leaflet Zoom Control Styling (Thin Border, Perfectly Aligned Width) */
.leaflet-control-zoom {
    border: 1px solid #CBD5E1 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
    overflow: hidden !important;
    background: #ffffff !important;
    width: 38px !important;
    box-sizing: border-box !important;
}

.leaflet-control-zoom a,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    width: 100% !important;
    height: 30px !important;
    line-height: 28px !important;
    display: block !important;
    text-align: center !important;
    background: #ffffff !important;
    color: #0F172A !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 700 !important;
    font-size: 16px !important;
    border: none !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    text-decoration: none !important;
    transition: background 0.15s ease, color 0.15s ease !important;
}

.leaflet-control-zoom a:hover,
.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    background: #F8FAFC !important;
    color: #0D9488 !important;
}

.leaflet-control-zoom-out {
    border-top: 1px solid #E2E8F0 !important;
}

.leaflet-zoom-badge,
#leafletZoomBadge {
    width: 100% !important;
    background: #002B36 !important;
    color: #ffffff !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    text-align: center !important;
    padding: 3px 0 !important;
    box-sizing: border-box !important;
    letter-spacing: -0.02em !important;
    border-bottom: 1px solid #002B36 !important;
    line-height: 1.2 !important;
}

/* ==========================================================================
   Mobile & Responsive Enhancements (Strictly Scoped - No Desktop Impact)
   ========================================================================== */

/* 1. Dynamic Viewport Height & Safe Area Insets */
html, body {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    overflow-x: hidden !important;
}

@media (max-width: 639px) {
    /* Header layout optimization on mobile screens (320px - 639px) */
    header {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        gap: 0.5rem !important;
    }

    #brandHeaderLogoImg {
        height: 1.35rem !important;
    }

    /* Mobile Search Bar - Zero Horizontal Overflow */
    #citySearchInput {
        font-size: 11px !important;
        padding-left: 2.25rem !important;
        padding-right: 2rem !important;
        height: 38px !important;
    }

    #searchResultsDropdown {
        width: calc(100vw - 1.5rem) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        max-height: 50vh !important;
    }

    #appModeDropdownMenu {
        max-width: calc(100vw - 1.5rem) !important;
        left: 0 !important;
    }

    /* Header Tools Touch Target Alignment */
    #headerStandardTools {
        gap: 0.35rem !important;
    }

    #headerStandardTools button {
        padding: 0.4rem 0.6rem !important;
        font-size: 11px !important;
        min-height: 38px !important;
    }

    /* Touch-Friendly Map Controls (~42-44px touch targets on mobile) */
    .leaflet-control-zoom {
        width: 42px !important;
    }
    .leaflet-control-zoom a,
    .leaflet-control-zoom-in,
    .leaflet-control-zoom-out {
        width: 100% !important;
        height: 42px !important;
        line-height: 40px !important;
        font-size: 18px !important;
    }
    .leaflet-control-location-box {
        margin-top: 6px !important;
    }
    .leaflet-control-location-btn {
        min-height: 42px !important;
        min-width: 42px !important;
        padding: 8px 10px !important;
    }

    /* Floating Theme Changer Button Touch Target */
    #floatingThemeBtn {
        min-height: 42px !important;
        padding: 8px 12px !important;
    }

    /* Mobile Slide-Up Bottom Sheet for Customizer Sidebar */
    #settingsPanel {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 82vh !important;
        z-index: 1001 !important;
        border-top-left-radius: 1.25rem !important;
        border-top-right-radius: 1.25rem !important;
        border-right: none !important;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25) !important;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease !important;
    }
    #settingsPanel.collapsed {
        transform: translateY(120%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Mobile Print Studio Layout: Stacked Preview + Bottom Control Panel */
    #printModuleContainer {
        flex-direction: column !important;
    }
    #printStageView {
        height: 60vh !important;
        padding: 0.5rem !important;
    }
    #printSidebar {
        width: 100% !important;
        height: 40vh !important;
        border-right: none !important;
        border-top: 1px solid #E2E8F0 !important;
    }
    #printStageSheetWrapper {
        padding: 0.25rem !important;
    }

    /* Mobile Dialogs & Modals Max Width */
    #exportModal > div,
    #creditsModal > div,
    #previewModal > div {
        max-height: 92vh !important;
        width: 95vw !important;
        margin: 0 auto !important;
        border-radius: 1rem !important;
    }
}

