* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e5631;
    --secondary-color: #2d7a3e;
    --accent-color: #f4a261;
    --danger-color: #e74c3c;
    --success-color: #27ae60;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --bg-light: #f5f7fa;
    --white: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-dark);
    background: var(--white);
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-left h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-left p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.header-right {
    display: flex;
    gap: 1rem;
}

.btn-info {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-info:hover {
    background: white;
    color: var(--primary-color);
}

/* Container */
.container {
    display: flex;
    height: calc(100vh - 80px);
    margin-top: 80px;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    padding: 1.5rem 0;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--bg-light);
    padding-bottom: 1rem;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.btn-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

/* Search Box */
.search-box {
    display: flex;
    gap: 0.5rem;
    padding: 0 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--bg-light);
}

.search-box input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.search-box button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-box button:hover {
    background: var(--secondary-color);
}

/* Layer Control */
.layer-control,
.base-layer-control,
.statistics,
.tools,
.legend,
.contact-info {
    padding: 0 1.5rem 1.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--bg-light);
}

.layer-control h3,
.base-layer-control h3,
.statistics h3,
.tools h3,
.legend h3,
.contact-info h3 {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.layer-items,
.base-layer-items {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.layer-item,
.base-layer-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.layer-item:hover,
.base-layer-item:hover {
    color: var(--primary-color);
}

.layer-item input,
.base-layer-item input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.layer-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.layer-color.pertanian {
    background: #2ecc71;
}

.layer-color.hutan {
    background: #3498db;
}

.layer-color.perkotaan {
    background: #e74c3c;
}

.layer-color.pesisir {
    background: #f39c12;
}

.layer-color.infrastruktur {
    background: #9b59b6;
}

.layer-color.budaya {
    background: #1abc9c;
}

/* Statistics */
.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #eee;
}

.stat-item strong {
    color: var(--primary-color);
    font-weight: 600;
}

.stat-item.total {
    margin-top: 0.5rem;
    padding-top: 0.8rem;
    border-top: 2px solid var(--primary-color);
    border-bottom: none;
    font-weight: 600;
}

/* Tools */
.tool-btn {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    background: var(--bg-light);
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tool-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Legend */
.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.9rem;
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.legend-color.pertanian { background: #2ecc71; }
.legend-color.hutan { background: #3498db; }
.legend-color.perkotaan { background: #e74c3c; }
.legend-color.pesisir { background: #f39c12; }
.legend-color.infrastruktur { background: #9b59b6; }
.legend-color.budaya { background: #1abc9c; }

/* Contact Info */
.contact-info p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 0.4rem 0;
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Map */
.map {
    flex: 1;
    background: var(--bg-light);
    position: relative;
}

.map .leaflet-container {
    background: var(--bg-light);
}

/* Sidebar Toggle Button */
.btn-toggle-sidebar {
    display: none;
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: var(--white);
    border: 1px solid #ddd;
    padding: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    z-index: 40;
    box-shadow: var(--shadow);
    transition: all 0.3s;
}

.btn-toggle-sidebar:hover {
    background: var(--primary-color);
    color: white;
}

/* Info Panel */
.info-panel {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 30;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.info-panel.visible {
    display: block;
    animation: slideInUp 0.3s ease;
}

.btn-close-panel {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.info-content {
    padding: 1.5rem;
}

.info-content h3 {
    color: var(--primary-color);
    margin-bottom: 0.8rem;
    font-size: 1rem;
}

.info-content p,
.info-content div {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.info-content strong {
    color: var(--text-dark);
}

/* Toolbar */
.toolbar {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 35;
}

.toolbar-btn {
    background: white;
    border: 1px solid #ddd;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--primary-color);
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

.toolbar-btn:hover {
    background: var(--primary-color);
    color: white;
}

.scale-display {
    background: white;
    border: 1px solid #ddd;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    color: var(--text-light);
    box-shadow: var(--shadow);
    margin-top: 0.5rem;
}

/* Measure Panel */
.measure-panel {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 30;
    width: 250px;
}

.measure-panel h4 {
    color: var(--primary-color);
    margin-bottom: 0.8rem;
}

.measure-btn {
    width: 100%;
    padding: 0.6rem;
    margin-bottom: 0.5rem;
    background: var(--bg-light);
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.measure-btn:hover {
    background: var(--primary-color);
    color: white;
}

.measure-result {
    padding: 0.8rem;
    background: var(--bg-light);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.8rem;
}

/* Coordinates */
.coordinates {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    z-index: 20;
}

#latLng {
    font-family: 'Courier New', monospace;
}

/* Loading Indicator */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.spinner {
    border: 4px solid var(--bg-light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-light);
    font-size: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    border-radius: 8px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.close {
    float: right;
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #000;
}

.modal-body {
    margin-top: 1.5rem;
}

.modal-body h4 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
}

.modal-body ul,
.modal-body ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.modal-body li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Animations */
@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Leaflet Custom Styles */
.leaflet-popup-content-wrapper {
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    font-size: 0.9rem;
    max-width: 280px;
}

.leaflet-control {
    box-shadow: var(--shadow) !important;
    border-radius: 4px !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-left h1 {
        font-size: 1.2rem;
    }

    .header-left p {
        display: none;
    }

    .header-right {
        gap: 0.5rem;
    }

    .btn-info {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .container {
        height: calc(100vh - 60px);
        margin-top: 60px;
    }

    .header {
        padding: 0.8rem 1rem;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 60px;
        bottom: 0;
        width: 280px;
        z-index: 50;
        transform: translateX(-100%);
    }

    .sidebar.visible {
        transform: translateX(0);
    }

    .btn-close {
        display: block;
    }

    .btn-toggle-sidebar {
        display: flex;
    }

    .info-panel {
        width: 90%;
        right: 0.5rem;
        left: 0.5rem;
    }

    .measure-panel {
        width: 90%;
        left: 0.5rem;
        bottom: 0.5rem;
    }

    .toolbar {
        top: 0.5rem;
        right: 0.5rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .header-left h1 {
        font-size: 1rem;
    }

    .sidebar {
        width: 100%;
    }

    .toolbar-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .sidebar-header h2 {
        font-size: 1rem;
    }

    .layer-control h3 {
        font-size: 0.95rem;
    }

    .scale-display {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}
