/* ===================================
   RESET & BASE STYLES
   =================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary-color: #2563eb;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --dark-color: #1f2937;
    --light-color: #f9fafb;
    --border-color: #e5e7eb;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.5;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-modal: 1050;
    --z-tooltip: 1100;
}

html {
    font-size: var(--font-size-base);
}

body {
    font-family: var(--font-family);
    line-height: var(--line-height-base);
    color: var(--dark-color);
    background-color: var(--light-color);
}

/* ===================================
   LAYOUT
   =================================== */

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--spacing-md);
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(-1 * var(--spacing-md));
}

.col {
    flex: 1;
    padding: 0 var(--spacing-md);
}

/* ===================================
   TYPOGRAPHY
   =================================== */

h1, h2, h3, h4, h5, h6 {
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #1d4ed8;
}

/* ===================================
   BUTTONS
   =================================== */

.btn {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.125rem;
}

/* ===================================
   CARDS
   =================================== */

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background-color: var(--light-color);
}

/* ===================================
   FORMS
   =================================== */

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.form-control {
    display: block;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===================================
   UTILITIES
   =================================== */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }

.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

.p-1 { padding: var(--spacing-xs); }
.p-2 { padding: var(--spacing-sm); }
.p-3 { padding: var(--spacing-md); }
.p-4 { padding: var(--spacing-lg); }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Loading Spinner */
.spinner {
    border: 3px solid var(--light-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Placeholder untuk development */
.dev-placeholder {
    background: repeating-linear-gradient(
        45deg,
        #f0f0f0,
        #f0f0f0 10px,
        #e0e0e0 10px,
        #e0e0e0 20px
    );
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

/* ===================================
   NDVI TOOLTIP & POPUP STYLES
   =================================== */

/* NDVI Tooltip (hover) */
.ndvi-tooltip {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 0.5rem 0.75rem !important;
    font-family: var(--font-family) !important;
    backdrop-filter: blur(8px);
}

.ndvi-tooltip::before {
    border-top-color: rgba(255, 255, 255, 0.98) !important;
}

.ndvi-tooltip .badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    color: white;
    font-weight: 600;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* NDVI Popup (click) */
.ndvi-popup .leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.ndvi-popup .leaflet-popup-content {
    margin: 0;
    padding: 1rem;
    font-family: var(--font-family);
}

.ndvi-popup .leaflet-popup-tip {
    background: white;
}

.ndvi-popup .badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    color: white;
    font-weight: 600;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* ===================================
   NDVI COMPARISON MODAL
   =================================== */

.comparison-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.comparison-modal-content {
    width: 95%;
    height: 95%;
    background: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.comparison-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.comparison-year-selector {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.comparison-year-selector:hover {
    background: rgba(255, 255, 255, 0.3);
}

.comparison-year-selector option {
    background: #2a2a2a;
    color: white;
}

.comparison-control-selector {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.comparison-control-selector:hover {
    background: rgba(255, 255, 255, 0.3);
}

.comparison-control-selector option {
    background: #2a2a2a;
    color: white;
}

.comparison-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    user-select: none;
}

.comparison-checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.comparison-modal-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.comparison-modal-title i {
    font-size: 1.25rem;
}

.comparison-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.comparison-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.comparison-loading {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner i {
    color: #667eea;
}

.comparison-map-container {
    flex: 1;
    position: relative;
    background: #000;
}

.comparison-year-label {
    position: absolute;
    top: 20px;
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.comparison-year-left {
    left: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.comparison-year-right {
    right: 20px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.comparison-info-box {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    color: white;
    border-radius: 8px;
    z-index: 1000;
    display: flex;
    gap: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.comparison-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.comparison-info-item i {
    color: #667eea;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .comparison-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .comparison-year-label {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
    
    .comparison-info-box {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }
}

/* Compare button hover effect */
.btn-compare-ndvi:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.btn-compare-ndvi:active {
    transform: scale(0.98);
}

/* Territorial tooltip in comparison modal */
.territorial-tooltip {
    background: rgba(0, 0, 0, 0.9) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    pointer-events: none !important;
}

.leaflet-tooltip-top.territorial-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.9) !important;
}

.leaflet-tooltip-bottom.territorial-tooltip::before {
    border-bottom-color: rgba(0, 0, 0, 0.9) !important;
}

.leaflet-tooltip-left.territorial-tooltip::before {
    border-left-color: rgba(0, 0, 0, 0.9) !important;
}

.leaflet-tooltip-right.territorial-tooltip::before {
    border-right-color: rgba(0, 0, 0, 0.9) !important;
}

.territorial-popup .leaflet-popup-content-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.territorial-popup .leaflet-popup-content {
    margin: 0 !important;
}

.territorial-popup .leaflet-popup-tip {
    background: rgba(30, 30, 30, 0.95) !important;
}

.btn-compare-ndvi:active {
    transform: scale(0.98);
}

/* Side-by-side slider improvements */
.leaflet-sbs-range {
    z-index: 1001 !important;
}

.leaflet-sbs-divider {
    z-index: 1000 !important;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Ensure slider thumb is always on top and draggable */
.leaflet-sbs-range::-webkit-slider-thumb {
    z-index: 1002 !important;
    cursor: ew-resize !important;
    pointer-events: auto !important;
}

.leaflet-sbs-range::-moz-range-thumb {
    z-index: 1002 !important;
    cursor: ew-resize !important;
    pointer-events: auto !important;
}

.leaflet-sbs-range::-ms-thumb {
    z-index: 1002 !important;
    cursor: ew-resize !important;
    pointer-events: auto !important;
}

/* NDVI Comparison Popup (side-by-side comparison) */
.ndvi-comparison-popup .leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(10px);
}

.ndvi-comparison-popup .leaflet-popup-content {
    margin: 0;
    padding: 12px;
    font-family: var(--font-family);
    min-width: 500px;
    color: #ffffff;
}

.ndvi-comparison-popup .leaflet-popup-tip {
    background: rgba(0, 0, 0, 0.5) !important;
}

/* Ensure NDVI interaction layer captures mouse events */
.leaflet-pane.leaflet-ndviInteraction-pane {
    z-index: 425 !important;
    pointer-events: auto !important;
}

.leaflet-pane.leaflet-ndviInteraction-pane svg,
.leaflet-pane.leaflet-ndviInteraction-pane path {
    pointer-events: all !important;
    cursor: pointer !important;
    outline: none !important;
    stroke: none !important;
    stroke-width: 0 !important;
}

/* Disable all borders and outlines on interaction layer (prevent click highlight) */
.leaflet-pane.leaflet-ndviInteraction-pane svg *,
.leaflet-pane.leaflet-ndviInteraction-pane path,
.leaflet-pane.leaflet-ndviInteraction-pane .leaflet-interactive {
    outline: none !important;
    stroke: transparent !important;
    stroke-width: 0 !important;
    border: none !important;
}

/* Remove fade animation from popups and tooltips for instant display */
.leaflet-popup-fade-in {
    animation: none !important;
    opacity: 1 !important;
}

.leaflet-tooltip-fade-in {
    animation: none !important;
    opacity: 1 !important;
}

.leaflet-popup,
.leaflet-tooltip {
    animation: none !important;
    transition: none !important;
}

/* Ensure popups are always above slider and all other elements */
.leaflet-popup-pane {
    z-index: 10000 !important;
}

.leaflet-tooltip-pane {
    z-index: 9000 !important;
}
