/* (Existing CSS is mostly appended, so I will rewrite the whole file via write_to_file with Overwrite true) */
:root {
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-light: #6366f1;
    /* Indigo 500 */
    --primary-dark: #4338ca;
    /* Indigo 700 */
    --bg: #0f172a;
    /* Slate 900 */
    --bg-panel: rgba(15, 23, 42, 0.7);
    /* Glassy panel background */
    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #94a3b8;
    /* Slate 400 */

    /* Stages colors */
    --color-proje: #eab308;
    --color-proje-rgb: 234, 179, 8;
    --color-ruhsat: #3b82f6;
    --color-ruhsat-rgb: 59, 130, 246;
    --color-insaat: #f97316;
    --color-insaat-rgb: 249, 115, 22;
    --color-tamamlandi: #10b981;
    --color-tamamlandi-rgb: 16, 185, 129;
    --color-yazi: #ffff00;
    --color-yazi-rgb: 255, 255, 0;

    --border: rgba(255, 255, 255, 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    overflow: hidden;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

h2 {
    font-size: 1.25rem;
    font-weight: 500;
}

h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

h4 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

h5 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

p {
    line-height: 1.5;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at top left, rgba(79, 70, 229, 0.2), transparent 40%),
        radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.2), transparent 40%);
}

.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.sidebar {
    width: 360px;
    min-width: 360px;
    height: 100%;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-light);
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.search-box {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search-box svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: inherit;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-light);
}

/* User Panel */
.user-panel {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-outline {
    background: transparent;
    color: var(--primary-light);
    border: 1px solid var(--primary-light);
}

.btn-outline:hover {
    background: var(--primary-light);
    color: white;
}

.w-100 {
    width: 100%;
}

/* Map Area */
.map-area {
    flex-grow: 1;
    height: 100%;
    position: relative;
    z-index: 1;
}

/* Detail Panel */
.detail-panel {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 380px;
    height: calc(100vh - 40px);
    border-radius: var(--radius-lg);
    z-index: 1000;
    transform: translateX(110%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent edge leakage */
}

.detail-panel.open {
    transform: translateX(0);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
    /* Ensure it stays above content */
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.1);
}

#detailContent {
    padding: 2.5rem 1.5rem 1.5rem;
    /* Increased top padding for close btn */
    overflow-y: auto;
    overflow-x: hidden;
    /* No horizontal scroll */
    flex-grow: 1;
}

/* Detail Content Scrollbar */
#detailContent::-webkit-scrollbar {
    width: 4px;
}

#detailContent::-webkit-scrollbar-track {
    background: transparent;
}

#detailContent::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

#detailContent::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Admin panel in Detail View */
.admin-actions {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.hidden {
    display: none !important;
}

.input-modern {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
    transition: var(--transition);
}

.input-modern:focus {
    outline: none;
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.1);
}

select.input-modern {
    background-color: rgba(15, 23, 42, 0.9);
    /* Opaque dark for dropdown rendering */
}

select.input-modern option {
    background-color: var(--bg);
    color: var(--text-primary);
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.action-buttons .input-modern {
    margin-bottom: 0;
}

/* Stages */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.proje {
    background-color: var(--color-proje);
    box-shadow: 0 0 8px var(--color-proje);
}

.ruhsat {
    background-color: var(--color-ruhsat);
    box-shadow: 0 0 8px var(--color-ruhsat);
}

.insaat {
    background-color: var(--color-insaat);
    box-shadow: 0 0 8px var(--color-insaat);
}

.tamamlandi {
    background-color: var(--color-tamamlandi);
    box-shadow: 0 0 8px var(--color-tamamlandi);
}

.building-header {
    margin-bottom: 2rem;
}

.building-header .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.badge.proje {
    background: rgba(234, 179, 8, 0.2);
    color: var(--color-proje);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge.ruhsat {
    background: rgba(59, 130, 246, 0.2);
    color: var(--color-ruhsat);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge.insaat {
    background: rgba(249, 115, 22, 0.2);
    color: var(--color-insaat);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge.tamamlandi {
    background: rgba(16, 185, 129, 0.2);
    color: var(--color-tamamlandi);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 20px;
    margin-top: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--primary);
    transform: translateX(-50%);
    z-index: 2;
}

.timeline-item.completed .timeline-dot {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.timeline-item.pending .timeline-dot {
    border-color: var(--text-secondary);
}

.timeline-item.pending .timeline-content {
    opacity: 0.5;
}

.timeline-content {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    transition: var(--transition);
}

.timeline-content:hover {
    background: rgba(255, 255, 255, 0.08);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.timeline-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.timeline-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Documents */
.document-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.document-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-light);
}

.document-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.document-info h4 {
    font-size: 0.85rem;
    font-weight: 500;
}

.document-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Marker */
.custom-leaflet-marker {
    background: transparent;
    border: none;
}

.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    background: var(--primary);
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -15px 0 0 -15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 2px solid white;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.marker-pin::after {
    content: '';
    width: 14px;
    height: 14px;
    margin: 6px 0 0 6px;
    background: white;
    position: absolute;
    border-radius: 50%;
}

.custom-leaflet-marker:hover .marker-pin,
.custom-leaflet-marker.selected .marker-pin {
    transform: rotate(-45deg) scale(1.2);
    z-index: 1000;
}

.marker-proje .marker-pin {
    background: var(--color-proje);
    box-shadow: 0 0 15px var(--color-proje);
}

.marker-ruhsat .marker-pin {
    background: var(--color-ruhsat);
    box-shadow: 0 0 15px var(--color-ruhsat);
}

.marker-insaat .marker-pin {
    background: var(--color-insaat);
    box-shadow: 0 0 15px var(--color-insaat);
}

.marker-tamamlandi .marker-pin {
    background: var(--color-tamamlandi);
    box-shadow: 0 0 15px var(--color-tamamlandi);
}

/* Popup */
.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 2px;
}

.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-secondary);
}

.leaflet-popup-content h3 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.leaflet-popup-content p {
    margin: 0;
    color: var(--text-secondary);
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--primary);
    transform: translateX(-50%);
    z-index: 2;
}

.timeline-item.completed .timeline-dot {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.timeline-item.pending .timeline-dot {
    border-color: var(--text-secondary);
}

.timeline-item.pending .timeline-content {
    opacity: 0.5;
}

.timeline-content {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    transition: var(--transition);
}

.timeline-content:hover {
    background: rgba(255, 255, 255, 0.08);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.timeline-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.timeline-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Documents */
.document-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.document-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-light);
}

.document-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.document-info h4 {
    font-size: 0.85rem;
    font-weight: 500;
}

.document-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Marker */
.custom-leaflet-marker {
    background: transparent;
    border: none;
}

.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    background: var(--primary);
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -15px 0 0 -15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 2px solid white;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.marker-pin::after {
    content: '';
    width: 14px;
    height: 14px;
    margin: 6px 0 0 6px;
    background: white;
    position: absolute;
    border-radius: 50%;
}

.custom-leaflet-marker:hover .marker-pin,
.custom-leaflet-marker.selected .marker-pin {
    transform: rotate(-45deg) scale(1.2);
    z-index: 1000;
}

.marker-proje .marker-pin {
    background: var(--color-proje);
    box-shadow: 0 0 15px var(--color-proje);
}

.marker-ruhsat .marker-pin {
    background: var(--color-ruhsat);
    box-shadow: 0 0 15px var(--color-ruhsat);
}

.marker-insaat .marker-pin {
    background: var(--color-insaat);
    box-shadow: 0 0 15px var(--color-insaat);
}

.marker-tamamlandi .marker-pin {
    background: var(--color-tamamlandi);
    box-shadow: 0 0 15px var(--color-tamamlandi);
}

/* Popup */
.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 2px;
}

.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-secondary);
}

.leaflet-popup-content h3 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.leaflet-popup-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* (Removed the global invert filter so Google Satellite isn't inverted) */

/* --- 3D Model Katman Kontrolü (Leaflet Stili) --- */
#cesiumLayerPanel {
    position: absolute !important;
    bottom: 30px !important;
    left: 20px !important;
    z-index: 1000 !important;
    font-family: 'Outfit', sans-serif !important;
    transition: all 0.2s ease-in-out !important;
}

.layer-panel-content.leaflet-style {
    background: var(--bg-panel) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5) !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
}

/* Mouse ile üzerine gelindiğinde açılma */
#cesiumLayerPanel:hover .layer-panel-content.leaflet-style {
    width: 320px !important;
    height: auto !important;
    max-height: 500px !important;
    cursor: default !important;
}

/* Kapalıyken ortalı ikon */
.cesium-layer-icon {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--text-primary) !important;
}

/* Liste içeriği kapalıyken gizli */
.cesium-layer-list-wrapper,
.panel-header {
    display: none !important;
}

/* Açıldığında içeriği göster (hover = masaüstü, .open = mobil dokunma) */
#cesiumLayerPanel:hover .cesium-layer-list-wrapper,
#cesiumLayerPanel:hover .panel-header,
#cesiumLayerPanel.open .cesium-layer-list-wrapper,
#cesiumLayerPanel.open .panel-header {
    display: block !important;
}

#cesiumLayerPanel:hover .panel-header,
#cesiumLayerPanel.open .panel-header {
    display: flex !important;
}

.panel-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    align-items: center;
    justify-content: space-between;
}

.panel-header h4 {
    margin: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
}

.cesium-layer-list-wrapper {
    padding: 0 12px 12px 12px;
    overflow-y: auto;
    max-height: 400px;
}

/* Model öğesi stili */
.layer-item {
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.layer-name {
    font-size: 13px !important;
    color: var(--text-primary) !important;
    font-weight: 500 !important;
}

.offset-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 22px;
}

.offset-control input[type='range'] {
    flex-grow: 1;
    height: 4px;
    cursor: pointer;
}

/* Leaflet Side-by-Side: divider çizgisi JS ile sürüklenebilir yapıldı,
   range input kütüphane varsayılanında (pointer-events:none) kalıyor */

/* Restoring Missing Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 500px;
    max-width: 90%;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transform: scale(1);
    transition: transform 0.3s;
    position: relative;
    margin: auto;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.modal-overlay.hidden .modal {
    transform: scale(0.9) !important;
}

.modal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 1.5rem !important;
    border-bottom: 1px solid var(--border) !important;
    padding-bottom: 10px !important;
}

.modal-body {
    max-height: 80vh !important;
    overflow-y: auto !important;
}

.modal-body {
    overflow-x: hidden !important;
}

/* Management Section Collapsible */
.management-section {
    margin: 5px 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
}

.management-toggle {
    width: 100%;
    padding: 10px 15px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.management-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.management-content {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.management-toggle .chevron-icon {
    transition: transform 0.3s ease;
}

.management-toggle.active .chevron-icon {
    transform: rotate(180deg);
}

/* Bina Listesi Optimization */
.building-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 60px;
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--primary-light);
    transform: translateX(4px);
}

.list-item.selected {
    background: rgba(79, 70, 229, 0.1);
    border-color: var(--primary);
    box-shadow: inset 4px 0 0 var(--primary);
}

.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.list-item-title {
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    color: #fff !important;
    margin: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 0.72rem !important;
    color: var(--text-secondary) !important;
    margin-top: 2px !important;
}

.status-badge {
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    padding: 2px 8px !important;
    border-radius: 6px !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Scrollbar styling for sidebar/list */
.building-list::-webkit-scrollbar {
    width: 4px;
}

.building-list::-webkit-scrollbar-track {
    background: transparent;
}

.building-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Sidebar structure refinement */
.sidebar-header {
    padding: 1.25rem 1.5rem;
}

.user-panel {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.01);
}

.stats-overview {
    padding: 10px 1.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================
   Pusula (Compass)
   ========================================== */
.map-compass {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 44px;
    height: 44px;
    z-index: 1001;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s linear, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.map-compass:hover {
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.5);
}

.compass-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-arrow-north {
    position: absolute;
    top: 6px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 16px solid #ef4444;
    /* North - Red */
}

.compass-arrow-south {
    position: absolute;
    bottom: 6px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 16px solid #f8fafc;
    /* South - White */
}

.compass-center {
    width: 4px;
    height: 4px;
    background: #475569;
    border-radius: 50%;
    z-index: 2;
}

.compass-n {
    position: absolute;
    top: -2px;
    font-size: 8px;
    font-weight: 800;
    color: white;
    text-shadow: 0 0 4px black;
    z-index: 3;
    pointer-events: none;
}

/* Detail panel açıkken pusulayı sola kaydır (Opsiyonel ama daha iyi kullanıcı deneyimi) */
.detail-panel.open~.map-area .map-compass {
    right: 410px;
}

/* Not: CSS selectorden dolayı bu çalışmayabilir çünkü .map-area .detail-panel'in kardeşi veya çocuğu olabilir. 
   Bakalım index.html'e. 
   .sidebar, .map-area ve .detail-panel kardeş. 
   Sıralama: .sidebar, .map-area, .detail-panel
*/
.map-area:has(~ .detail-panel.open) .map-compass {
    right: 410px;
}

/* older browsers support fallback */
@supports not selector(:has(*)) {
    .map-compass-shift {
        right: 410px !important;
    }
}
/* 2D Bina isim etiketi */
.building-label-2d {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #facc15;
    font-size: 11px;
    font-weight: bold;
    text-shadow: 1px 1px 3px black, -1px -1px 3px black, 0 0 4px black;
    white-space: nowrap;
    pointer-events: none;
    padding: 0 !important;
}
.building-label-2d::before {
    display: none !important;
}

/* Vektör katman yazı etiketi (toggle ile açılır) */
.vector-label-2d {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #facc15;
    font-size: 11px;
    font-weight: bold;
    text-shadow: 1px 1px 3px black, -1px -1px 3px black, 0 0 4px black;
    white-space: nowrap;
    pointer-events: none;
    padding: 0 !important;
}
.vector-label-2d::before {
    display: none !important;
}

/* ==========================================
   BOTTOM SHEET HANDLE (her zaman tanımlı, mobilde görünür)
   ========================================== */
.sheet-handle-bar {
    display: none; /* masaüstünde gizli */
    justify-content: center;
    align-items: center;
    padding: 10px 0 6px;
    flex-shrink: 0;
    cursor: grab;
    touch-action: none;
}
.sheet-handle-bar:active { cursor: grabbing; }
.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
}


/* ==========================================
   MOBİL UYUMLULUK (max-width: 768px)
   ========================================== */
@media (max-width: 768px) {

    /* ── Genel layout: harita tam ekran ── */
    .app-container {
        flex-direction: row;
        position: relative;
    }

    /* Harita tam ekranı kaplar */
    .map-area {
        position: fixed !important;
        inset: 0;
        width: 100% !important;
        height: 100% !important;
        z-index: 1;
    }

    #map, #cesiumContainer {
        width: 100% !important;
        height: 100% !important;
    }

    /* ── Bottom Sheet (sidebar) ── */
    .sidebar {
        position: fixed !important;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        min-width: unset !important;
        border-right: none;
        border-top: 1px solid var(--border);
        border-radius: 20px 20px 0 0;
        z-index: 200;
        /* Başlangıç: mini snap (sadece handle+arama görünür ~90px) */
        transform: translateY(calc(100% - 90px));
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
        /* İçerik kaydırma */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 100svh;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
    }

    /* Sürüklenirken animasyonu kapat */
    .sidebar.dragging {
        transition: none !important;
    }

    /* Snap pozisyonları (JS tarafından class ile atanır) */
    .sidebar.snap-mini {
        transform: translateY(calc(100% - 90px));
    }
    .sidebar.snap-half {
        transform: translateY(40%);
    }
    .sidebar.snap-full {
        transform: translateY(0);
    }

    /* Handle bar mobilde görünür */
    .sheet-handle-bar {
        display: flex;
    }

    /* Sidebar scroll'u: snap-full'da içerik kaydırılabilir,
       diğerlerinde handle drag'i öncelikli olsun */
    .sidebar:not(.snap-full) {
        overflow-y: hidden;
    }

    /* ── İçerik düzenlemeleri ── */
    .building-list {
        flex-grow: 0;
        overflow-y: visible;
        max-height: none;
    }

    .stats-overview {
        flex-shrink: 0;
    }

    .sidebar-header {
        padding: 0.5rem 1rem 0.75rem;
    }

    .sidebar-header h1 {
        font-size: 1.05rem;
    }

    .subtitle {
        display: none;
    }

    .search-box {
        margin-bottom: 0.5rem;
    }

    /* Filtre + karşılaştırma butonlarını yatay kaydırır yap */
    .filters {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .filters::-webkit-scrollbar { display: none; }

    .filter-btn {
        flex-shrink: 0;
        padding: 0.45rem 0.75rem;
        font-size: 0.82rem;
    }

    /* Bina liste öğesi — daha büyük dokunma alanı */
    .list-item {
        padding: 0.9rem 1rem;
    }

    /* Kullanıcı paneli */
    .user-panel {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Detail panel: alttan kayar */
    .detail-panel {
        position: fixed !important;
        width: 100%;
        height: 78svh;
        right: 0;
        top: auto;
        bottom: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(110%);
        transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
        z-index: 300;
    }
    .detail-panel.open {
        transform: translateY(0);
    }

    /* Admin işlem butonlarını mobilde gizle */
    #adminDetailActions,
    #btnToggleTextEdit,
    #btnToggleAddText,
    .management-section,
    .admin-only-desktop {
        display: none !important;
    }

    /* 3D mod butonu kompakt */
    #btnToggle3D {
        font-size: 0.78rem;
        padding: 0.5rem 0.75rem;
    }

    /* Karşılaştır + Sorgula butonları kompakt */
    #btnOpenCompare,
    #btnOpenQuery {
        font-size: 0.78rem;
        padding: 0.45rem 0.6rem;
    }

    /* Modal tam genişlikte, tab bar üzerinde */
    .modal-overlay {
        padding-bottom: 60px;
    }
    .modal {
        width: 95%;
        max-width: 95%;
        margin: 10px auto;
        max-height: 85svh;
        overflow-y: auto;
    }

    /* 3D katman paneli — mobilde map-area stacking context'inden çıkar,
       sidebar (z-index:200) üzerinde görünsün */
    #cesiumLayerPanel {
        position: fixed !important;
        bottom: 100px !important;  /* mini sheet'in üzerinde */
        left: 12px !important;
        z-index: 300 !important;
    }

    #cesiumLayerPanel:hover .layer-panel-content.leaflet-style,
    #cesiumLayerPanel.open .layer-panel-content.leaflet-style {
        width: 280px !important;
    }

    /* Koordinat çubuğu küçük */
    #cesium-coords {
        font-size: 10px !important;
        padding: 4px 10px !important;
    }

    /* Leaflet sağ alt kontroller (zoom, attribution) panelin üzerinde kalsın.
       Mini snap = 90px görünür → kontroller onun üzerinde */
    .leaflet-bottom {
        bottom: 96px !important;
    }

    /* Leaflet katman kontrol paneli sağ üstte kalıyor, sorun yok.
       Ama sol üstteki kontroller de haritayla çakışmasın */
    .leaflet-top {
        top: 8px !important;
    }

    /* Katman kontrol açıldığında panel yüksekliğini sınırla */
    .leaflet-control-layers-expanded {
        max-height: calc(100svh - 180px);
        overflow-y: auto;
    }
}
