/* core_app/static/css/maps/dashboard_perf.css */

/* [PERF] Critical CSS for faster initial render */
#map {
    background: #f8f9fa url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMjAiIGN5PSIyMCIgcj0iMiIgZmlsbD0iI2RlZTJlNiIvPgo8L3N2Zz4=');
    background-size: 20px 20px;
    height: 100%;
    min-height: 0;
    contain: layout paint; /* Optimize rendering */
}

/* [PERF] Loader styling */
#map-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    text-align: center;
    color: #6c757d;
}

#map-loader .spinner-border {
    width: 2rem;
    height: 2rem;
    border-width: 0.2em;
}

/* [PERF] Marker'lara will-change: transform VERME: MapLibre bu sınıfı
   yüzlerce/binlerce düğüme basar; her biri için kalıcı GPU compositor
   katmanı = GPU-bellek şişmesi + daha yavaş compositing. translateZ(0)
   zaten MapLibre'ın inline transform'una specificity'de kaybediyordu
   (ölü kod). MapLibre marker'ları kendi verimli yönetir. */

/* [PERF] Layer/popup: avoid will-change (reduces memory); GPU layer only for markers */
.maplibregl-popup {
    contain: layout paint;
}

/* [PERF] Content visibility for off-screen sections */
.map-page-shell .layer-grid {
    content-visibility: auto;
    contain-intrinsic-size: 0 200px;
}

.map-page-shell .tab-content .tab-pane {
    content-visibility: auto;
    contain-intrinsic-size: 0 300px;
}

/* Pan/zoom sırasında harita üstündeki blur/shadow yüzeylerini her frame yeniden
   rasterize etme. Hareket bitince görsel kalite geri gelir. */
.map-wrapper.is-map-moving .map-sidebar,
.map-wrapper.is-map-moving .custom-map-controls,
.map-wrapper.is-map-moving .map-legend,
.map-wrapper.is-map-moving #map-loader,
.map-wrapper.is-map-moving .map-lifecycle-bar,
.map-wrapper.is-map-moving .parcel-loading-overlay {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

/* Bootstrap görünmeyen modal sekmelerini zaten display:none yapar. Tab-pane'e
   paint containment vermek, görünür bina şeması etiketlerini ve odak halkasını
   kırpıyordu. Yalnız gerçekten taşma sınırı olan ağır alt yüzeyleri izole et. */
#parcelCardModal .table-responsive,
#parcelCardModal .parcel-yearlapse {
    contain: layout paint;
}

@media screen {
    #parcelCardModal .schema-floor-ref:not(.floor-ref-ground) {
        content-visibility: auto;
        contain-intrinsic-size: auto 56px;
    }
}

@media (max-width: 1024px), (pointer: coarse) {
    /* Mobil/dokunmatikte blur (backdrop-filter) her frame yeniden rasterize
       edilir → düşük-uçlu cihazda pan/scroll jank. Listeye eksik kalan
       yüzeyler eklendi (sidebar sekmeleri, imar araç çubuğu/etiket/zoom
       overlay'i, doğrulama toast'ı, yearlapse meta, harita toast'ı). */
    .map-legend,
    #map-loader,
    .map-lifecycle-bar,
    .parcel-loading-overlay,
    .map-sidebar-tabs,
    .imar-drawing-toolbar,
    .imar-visual-label,
    .imar-zoom-overlay,
    .parcel-map-verification-toast,
    .yearlapse-meta,
    .map-toast-item {
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    /* [A11Y / Apple HIG] Dokunmatik hedefler ≥44px. Bunlar 26-40px kalmıştı:
       yaşam-döngüsü filtre pill'leri, sheet/sidebar kapatma ✕, modal sekmeleri,
       popup butonları, FAB'lar, imar zoom butonları. */
    .lifecycle-pill,
    .dp-sheet-close,
    .map-sidebar-mobile-close,
    #parcelCardModal .nav-tabs .nav-link,
    .map-popup-card button,
    .map-mobile-controls-fab,
    .map-mobile-search-fab,
    .map-sidebar-refresh-btn,
    .parcel-history-refresh,
    .parcel-history-item__remove,
    .parcel-map-verification-toast__close,
    .imar-drawing-zoom-btn,
    .yearlapse-controls .btn,
    .yearlapse-divider-grip,
    .yearlapse-band-cell,
    .yearlapse-ticks button,
    .yearlapse-story-item,
    [data-satellite-history-retry],
    [data-yl-image-retry] {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    .parcel-map-verification-toast {
        grid-template-columns: 32px minmax(0, 1fr) 44px;
    }
}

/* [PERF] Optimize loading states */
.map-page-shell .skeleton,
#parcelCardModal .skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


@media (prefers-reduced-motion: reduce) {
    /* Maps tercihlerini platformun diğer uygulamalarına taşırma. */
    .map-page-shell *,
    .map-page-shell *::before,
    .map-page-shell *::after,
    #parcelCardModal *,
    #parcelCardModal *::before,
    #parcelCardModal *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (min-width: 768px) {
    #parcelCardModal .dp-sheet-close {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 38px;
        height: 38px;
        padding: 0;
        border: none;
        border-radius: 12px;
        background: rgba(35, 49, 59, 0.08);
        color: #23313b;
        font-size: 1rem;
        line-height: 1;
        cursor: pointer;
        transition: background 0.15s ease;
    }
    #parcelCardModal .dp-sheet-close:hover {
        background: rgba(35, 49, 59, 0.16);
    }
    #parcelCardModal .dp-sheet-close:focus-visible {
        outline: 2px solid #2f6f6a;
        outline-offset: 2px;
    }

    #parcelCardModal .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
    }
    #parcelCardModal .nav-tabs .nav-link {
        white-space: nowrap;
    }
    #parcelCardModal .nav-tabs::-webkit-scrollbar {
        height: 4px;
    }
    #parcelCardModal .nav-tabs::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.5);
        border-radius: 2px;
    }
}

.section-history-reveal {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid #e6e9ef;
}
.section-history-reveal[open] {
    padding-bottom: 4px;
}
.section-history-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #4a5b6b;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
    user-select: none;
}
.section-history-summary::-webkit-details-marker {
    display: none;
}
.section-history-summary:hover {
    background: rgba(35, 49, 59, 0.06);
    color: #23313b;
}
.section-history-summary:focus-visible {
    outline: 2px solid #2f6f6a;
    outline-offset: 2px;
}
.section-history-summary .section-history-count {
    font-weight: 700;
}
.section-history-host {
    padding: 10px 2px 2px;
}
/* Pane modu: bölüm kendi sekmesini doldurur (Uydu Zaman Tüneli). */
.section-history-reveal--pane {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
.section-history-reveal--pane > .section-history-summary {
    display: none;
}
.section-history-reveal--pane > .section-history-host {
    padding: 0 2px 2px;
}
.section-history-host .section-history-card {
    background: #fbfcfe;
    border-color: #e6e9ef !important;
}
.section-history-periods .section-history-period-btn {
    white-space: normal;
    line-height: 1.35;
}
@media (max-width: 1024px), (pointer: coarse) {
    .section-history-summary {
        min-height: 44px;
        padding: 10px 8px;
    }
    .section-history-periods .section-history-period-btn {
        min-height: 44px;
    }
}

.map-sidebar-hint {
    color: #5b6b7b;
}
.imar-hero-card-label-v2,
.imar-empty-state-desc,
.pms-lbl {
    color: #5b6b7b !important;
}
.plan-card-label {
    color: #475569 !important;
}
.lifecycle-pill:not(.active) {
    /* Full opacity so the muted label clears WCAG AA; the "off" cue is the pale
       fill + dimmed icon, not label transparency. */
    opacity: 1;
}

body:not(.map-sidebar-ready) .map-sidebar-backdrop {
    opacity: 0 !important;
    pointer-events: none !important;
}

@media (min-width: 768px) {
    .sidebar-toggle {
        left: 370px;
    }
}

@media (min-width: 768px) and (max-width: 1419.98px) {
    .map-lifecycle-bar {
        max-width: min(700px, calc(100vw - 172px));
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }
    .map-lifecycle-bar::-webkit-scrollbar {
        display: none;
    }
    .map-lifecycle-bar .lifecycle-pill {
        flex-shrink: 0;
    }
    body:not(.map-sidebar-collapsed) .map-lifecycle-bar {
        left: 424px;
        right: 80px;
        width: fit-content;
        max-width: none;
        margin-left: auto;
        margin-right: auto;
        transform: none;
    }
    body:not(.map-sidebar-collapsed) .map-lifecycle-bar.lifecycle-bar-hidden {
        transform: translateY(-6px);
    }
}
