/* Reset dan Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1a5276;
    --secondary-color: #2e86c1;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-color: #dee2e6;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --polygon-color: #3388ff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    overflow: hidden;
    height: 100vh;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    height: 70px;
    z-index: 100;
}

.logo {
    height: 50px;
    width: auto;
    border-radius: var(--radius);
    border: 2px solid white;
}

.header h1 {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.header h2 {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 400;
}

.header-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
}

.info-item i {
    color: #ffd700;
}

/* Layout Utama - 55% atas dan 45% bawah */
.main-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
    padding: 10px;
    gap: 10px;
}

/* Area Atas (55%) */
.top-area {
    height: 55%;
    display: flex;
    gap: 10px;
}

/* Area Bawah (45%) */
.bottom-area {
    height: 45%;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Panel Kiri (20%) */
.left-panel {
    width: 20%;
    min-width: 250px;
}

/* Panel Tengah (60%) */
.center-panel {
    width: 60%;
    flex: 1;
}

/* Panel Kanan (20%) */
.right-panel {
    width: 20%;
    min-width: 250px;
}

/* Panel Section untuk area kiri (lokasi) */
.panel-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.panel-section h3 {
    font-size: 1rem;
    padding: 15px;
    margin: 0;
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Pencarian Lokasi */
.search-box {
    position: relative;
    padding: 0 15px;
    margin: 10px 0;
}

.search-box input {
    padding-right: 35px;
    font-size: 0.85rem;
    height: 36px;
}

.search-icon {
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 0.9rem;
}

/* Daftar Lokasi */
.location-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 15px;
    margin-bottom: 10px;
}

.kecamatan-item {
    margin-bottom: 8px;
}

.kecamatan-header {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.kecamatan-header:hover {
    background: #e9ecef;
    border-color: var(--secondary-color);
}

.kecamatan-header i {
    margin-right: 8px;
    transition: transform 0.3s;
    font-size: 0.75rem;
}

.kecamatan-header.active i {
    transform: rotate(90deg);
}

.kecamatan-header span:first-of-type {
    flex: 1;
    font-weight: 500;
}

.desa-list {
    display: none;
    margin-left: 10px;
    margin-top: 5px;
}

.desa-list.show {
    display: block;
}

.desa-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin: 3px 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.desa-item:hover {
    background: #f0f7ff;
    border-color: var(--secondary-color);
}

.desa-item.active, .desa-item.selected {
    background: var(--secondary-color);
    color: white;
    border-color: var(--primary-color);
}

.desa-item i {
    margin-right: 8px;
    font-size: 0.75rem;
}

.desa-item span:first-of-type {
    flex: 1;
}

/* Lokasi Terpilih */
.selected-location {
    padding: 0 15px 15px;
    min-height: 40px;
}

.selected-location .alert {
    padding: 8px 10px;
    margin: 0;
    font-size: 0.8rem;
}

/* Map Container */
.map-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: white;
    position: relative;
}

.map-header {
    background: var(--dark-color);
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.map-header h3 {
    font-size: 1rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-controls .btn-group {
    gap: 5px;
}

#map {
    flex: 1;
    min-height: 200px;
    z-index: 1;
}

/* Layer Controls */
.layer-controls {
    position: absolute;
    top: 60px;
    right: 10px;
    z-index: 1000;
    background: white;
    padding: 12px 15px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    font-size: 0.85rem;
    min-width: 180px;
    display: none;
}

.layer-controls.show {
    display: block;
}

.layer-controls h6 {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--dark-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.layer-control-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    padding: 3px 0;
}

.layer-control-item:hover {
    background: var(--light-color);
    border-radius: 3px;
}

.layer-control-item input {
    margin-right: 10px;
    cursor: pointer;
}

.layer-control-item span {
    flex: 1;
    font-size: 0.8rem;
}

.layer-control-item i {
    width: 20px;
    color: var(--secondary-color);
}

/* Map Legend */
.map-legend {
    background-color: white;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    display: none;
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 200px;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.map-legend h5 {
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--dark-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.75rem;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 8px;
    border: 1px solid #ddd;
}

.legend-section {
    margin-bottom: 15px;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-section h6 {
    font-size: 0.8rem;
    margin-bottom: 8px;
    color: #666;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* Foto Container - Layout Baru */
.foto-container {
    height: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.foto-container h3 {
    font-size: 0.9rem;
    padding: 10px 15px;
    margin: 0;
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
    color: var(--dark-color);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    height: 40px;
}

.foto-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.foto-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.foto-display img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.no-foto {
    text-align: center;
    color: #6c757d;
    padding: 20px;
}

.no-foto i {
    margin-bottom: 10px;
    color: #dee2e6;
    font-size: 2.5rem;
}

.foto-controls {
    padding: 10px 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--light-color);
    flex-shrink: 0;
    height: 50px;
}

.foto-controls button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#foto-counter {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dark-color);
    min-width: 40px;
    text-align: center;
}

/* Table Container */
.table-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-header {
    padding: 15px;
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.table-header h3 {
    font-size: 1rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.table-responsive {
    flex: 1;
    overflow-y: auto;
    padding: 0 15px;
}

/* Table Styles */
#aset-table {
    font-size: 0.8rem;
    margin-bottom: 0;
    min-width: 1200px;
}

#aset-table thead th {
    position: sticky;
    top: 0;
    background-color: var(--dark-color);
    color: white;
    font-weight: 600;
    padding: 8px;
    white-space: nowrap;
    z-index: 10;
}

#aset-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

#aset-table tbody tr:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

#aset-table tbody tr.selected {
    background-color: rgba(52, 152, 219, 0.1);
    border-left: 3px solid var(--primary-color);
}

#aset-table td {
    padding: 8px;
    vertical-align: middle;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-footer {
    padding: 10px 15px;
    border-top: 1px solid var(--border-color);
    background: var(--light-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.pagination-info {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Badge Styles */
.badge {
    font-size: 0.75rem;
    padding: 3px 8px;
}

/* Button Styles */
.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Tooltip Custom */
.leaflet-tooltip {
    font-size: 0.85rem;
    padding: 6px 10px;
}

/* Modal Custom */
.modal-body {
    font-size: 0.9rem;
}

.modal-foto-count {
    background: var(--info-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 5px;
}

/* Polygon Styles */
.leaflet-polygon {
    stroke-width: 2;
    stroke-opacity: 0.8;
    fill-opacity: 0.3;
}

.leaflet-polygon.active {
    stroke-width: 3;
    stroke-opacity: 1;
    fill-opacity: 0.4;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .top-area {
        flex-direction: column;
        height: 70%;
    }
    
    .bottom-area {
        height: 30%;
    }
    
    .left-panel, .center-panel, .right-panel {
        width: 100%;
        height: 33.33%;
    }
    
    .left-panel, .right-panel {
        min-width: auto;
    }
    
    .map-container, .foto-container, .location-panel {
        height: 100%;
    }
    
    .table-responsive {
        min-height: 150px;
    }
    
    .layer-controls {
        top: 70px;
        right: 5px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        height: auto;
        padding: 10px;
        text-align: center;
        gap: 10px;
    }
    
    .header-info {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .main-content {
        height: auto;
        min-height: calc(100vh - 120px);
    }
    
    .table-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .table-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .table-actions .input-group {
        width: 100% !important;
    }
    
    #aset-table {
        font-size: 0.75rem;
    }
    
    #aset-table th, #aset-table td {
        padding: 4px 6px;
    }
    
    .layer-controls {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 300px;
    }
}

/* Loading Animation */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.loading i {
    font-size: 2rem;
    color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Marker Popup Custom */
.marker-popup .leaflet-popup-content {
    margin: 8px;
    font-size: 0.85rem;
    min-width: 200px;
}

.marker-popup h5 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--dark-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.marker-popup p {
    margin: 0 0 4px 0;
    font-size: 0.8rem;
}

.polygon-popup {
    font-size: 0.85rem;
}

.polygon-popup h5 {
    font-size: 0.9rem;
    margin: 0 0 8px 0;
    color: var(--dark-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* Thumbnail Foto */
.foto-thumbnails {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
}

.foto-thumbnail {
    width: 40px;
    height: 40px;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s;
}

.foto-thumbnail.active {
    border-color: var(--primary-color);
}

.foto-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Utility Classes */
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.h-100 {
    height: 100%;
}

.w-100 {
    width: 100%;
}

/* Foto Indicator Dots */
.foto-indicators {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
}

.foto-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc;
    cursor: pointer;
    transition: background-color 0.2s;
}

.foto-indicator.active {
    background-color: var(--primary-color);
}

/* Table Icon untuk polygon */
.table-polygon-icon {
    color: var(--polygon-color);
    margin-left: 5px;
    font-size: 0.85rem;
}