/* --- 1. Root Variables & Base Setup --- */
:root {
    --pertamina-blue: #3C6DB2;
    --pertamina-green: #ADC52D;
    --pertamina-red: #BA313B;
    --pertamina-black: #141410;
    --status-aman: #22c55e;      /* green-500 */
    --status-waspada: #f59e0b;   /* amber-500 */
    --status-bahaya: #ef4444;    /* red-500 */
    --bg-light: #f1f5f9;      /* slate-100 */
    --card-bg: #ffffff;
    --border-color: #e2e8f0;  /* slate-200 */
    --text-primary: #1e293b;  /* slate-800 */
    --text-secondary: #64748b; /* slate-500 */
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif, system-ui;
    background-color: var(--bg-light);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- 2. Header and Navigation --- */
.header {
    background-color: var(--card-bg);
    border-bottom: 4px solid var(--pertamina-blue);
    transition: box-shadow 0.3s ease;
}

.nav-tab {
    padding: 1rem 1.25rem;
    border-bottom: 4px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    top: 2px; /* Align with bottom border */
}

.nav-tab:hover {
    background-color: #f8fafc; /* slate-50 */
    color: var(--pertamina-blue);
}

.nav-tab.active {
    color: var(--pertamina-blue);
    border-bottom-color: var(--pertamina-blue);
    font-weight: 700;
}

#mobile-navigation-menu .nav-tab {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    border-left: 4px solid transparent;
    top: 0;
}
#mobile-navigation-menu .nav-tab.active {
    border-left-color: var(--pertamina-blue);
    border-bottom-color: var(--border-color);
    background-color: #f8fafc;
}
#mobile-navigation-menu .nav-tab:last-of-type {
    border-bottom: none;
}


/* --- 3. Leaflet Map Customization --- */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
}

.popup-title {
    font-weight: 700;
    color: var(--pertamina-blue);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.popup-button {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.popup-button-primary {
    background-color: var(--pertamina-blue);
}
.popup-button-primary:hover {
    background-color: #325c99;
}

.popup-button-secondary {
    background-color: #4b5563; /* gray-600 */
}
.popup-button-secondary:hover {
    background-color: #374151; /* gray-700 */
}

/* Marker Pulse Animation */
@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    70% { transform: scale(2.5); opacity: 0; }
    100% { transform: scale(2.5); opacity: 0; }
}

.pulse {
    animation: pulse 2s infinite cubic-bezier(0.455, 0.03, 0.515, 0.955);
    border-radius: 50%;
    position: absolute;
    width: 28px;
    height: 28px;
    left: 0px;
    top: 0px;
}

.map-marker-svg {
    filter: drop-shadow(0px 2px 2px rgba(0,0,0,0.4));
}

/* --- 4. Info Cuaca Tab --- */
.weather-detail-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: white;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
.weather-detail-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    border-color: var(--pertamina-blue);
}

/* NEW: Styles for the enhanced chart layout */
.secondary-chart-container {
    background-color: #f8fafc; /* slate-50 */
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem 1rem 1rem;
}
.secondary-chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
}


/* --- 5. Tentang Kami Tab --- */
.team-member-card {
    background-color: #f8fafc; /* slate-50 */
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}
.team-member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    border-left: 4px solid var(--pertamina-green);
}
.team-member-card img {
    border: 4px solid white;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* --- 6. Modal Styling --- */
.modal-backdrop {
    transition: opacity 0.3s ease;
}
.modal-content {
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: scale(0.95);
    opacity: 0;
}
.modal-backdrop:not(.hidden) .modal-content {
    transform: scale(1);
    opacity: 1;
}

#close-history-modal, #close-cctv-modal, #close-subscription-modal {
    transition: transform 0.2s ease, color 0.2s ease;
}
#close-history-modal:hover, #close-cctv-modal:hover, #close-subscription-modal:hover {
    transform: rotate(90deg);
    color: var(--pertamina-red);
}


/* --- 7. Loaders and Spinners --- */
.loader-text::after {
    content: '.';
    animation: dots 1.4s infinite;
}
@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60% { content: '...'; }
    80%, 100% { content: ''; }
}

.animate-spin {
    animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- 8. Form Elements --- */
#station-select {
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
#station-select:focus {
    box-shadow: 0 0 0 3px rgba(60, 109, 178, 0.3);
}

/* --- 9. General & Utility Classes --- */
.tab-content {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom scrollbar for panels */
.overflow-y-auto::-webkit-scrollbar {
    width: 8px;
}
.overflow-y-auto::-webkit-scrollbar-track {
    background: var(--bg-light); 
}
.overflow-y-auto::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
    border: 2px solid var(--bg-light);
}
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}


/* --- 9. Hint Popup --- */
.station-hint {
    position: absolute;
    top: 250px; /* Adjust this to position it vertically */
    right: 35%; /* Adjust this to position it horizontally */
    z-index: 1000;
    padding: 1rem;
    background-color: var(--pertamina-blue);
    color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 250px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    visibility: hidden;
}

.station-hint.show {
    opacity: 1;
    transform: scale(1);
    visibility: visible;
}

.hint-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.hint-button {
    margin-top: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    background-color: white;
    color: var(--pertamina-blue);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.hint-button:hover {
    background-color: #f0f0f0;
}
/* --- 10. Download Button --- */
.download-button {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background-color: var(--pertamina-green);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.download-button:hover {
    background-color: #89a320; /* Darker green */
}

/* --- 11. Interactive Weather Forecast (New) --- */
.forecast-tab {
    padding: 0.5rem 1rem;
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.forecast-tab:hover {
    color: var(--pertamina-blue);
    background-color: #f8fafc; /* slate-50 */
}

.forecast-tab.forecast-tab-active {
    color: var(--pertamina-blue);
    font-weight: 700;
    border-bottom-color: var(--pertamina-blue);
}

.forecast-content-panel {
    animation: fadeIn 0.3s ease-in-out;
}

/* Wind Display Styles */
.wind-forecast-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    flex-shrink: 0;
    width: 80px;
    height: 100%;
    padding: 1rem 0;
    border-right: 1px solid var(--border-color);
}
.wind-forecast-item:last-child { border-right: none; }
.wind-forecast-time { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }
.wind-forecast-speed { font-size: 1rem; font-weight: 600; margin: auto 0; }
.wind-forecast-arrow { font-size: 1.5rem; color: var(--pertamina-blue); transition: transform 0.5s ease-in-out; }

/* Daily Forecast Styles */
.daily-forecast-item {
    padding: 0.75rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: white;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
}
.daily-forecast-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.daily-forecast-day { font-weight: 600; }
.daily-forecast-icon { margin: 0.5rem auto; }
.daily-forecast-temps { font-size: 0.875rem; }
.daily-forecast-temps .low-temp { color: var(--text-secondary); }

.daily-forecast-item.active {
    border-color: var(--pertamina-blue);
    background-color: #eef2ff; /* A light blue shade */
    transform: translateY(-4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.daily-forecast-caption {
    font-size: 1rem; /* 12px */
    color: var(--text-secondary);
    margin-top: 0.25rem;
    height: 2.2em; /* Ensures all cards have same height */
    line-height: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
}


.leaflet-top.leaflet-center,
.leaflet-bottom.leaflet-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none; /* Allows clicking on the map beneath */
    width: auto;
}
.leaflet-top.leaflet-center .leaflet-control,
.leaflet-bottom.leaflet-center .leaflet-control {
    pointer-events: auto; /* Re-enables events for the actual controls */
    margin-bottom: 10px;
}

/* Style for the information box in the top-center */
.flood-info-control {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 0.9em;
    min-width: 220px;
    border: 1px solid var(--border-color);
}
.flood-info-control h4 {
    margin: 0 0 8px 0;
    font-weight: 700;
    color: var(--pertamina-blue);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}
.flood-info-control b {
    font-weight: 600;
    color: var(--text-primary);
}

/* Style for the NDWI colorbar legend in the bottom-center */
.legend-control {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
}
.legend-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.legend-labels {
    display: flex;
    width: 200px;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.legend-colorbar {
    width: 200px;
    height: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: linear-gradient(to right, rgb(0, 128, 0), rgb(255, 255, 255) 50%, rgb(0, 0, 204));
}

/* Style for the source attribution text */
.source-control {
    background-color: rgba(255, 255, 255, 0.7);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
    color: #333;
}
#subscription-modal.hidden {
    display: none;
}

#subscription-modal {
    display: flex;
}