/* Custom styles for the River & Reservoir monitoring site */

:root {
    --color-dry: #FCD34D;
    --color-low: #F97316;
    --color-normal: #0EA5E9;
    --color-high: #6366F1;
    --color-flood: #DC2626;
}

body {
    background-color: #111827;
    color: #F3F4F6;
}

.mobile-full-height {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
}

/* Status badge colors */
.status-dry {
    background-color: var(--color-dry) !important;
    color: #1F2937 !important;
}

.status-low {
    background-color: var(--color-low) !important;
    color: white !important;
}

.status-normal {
    background-color: var(--color-normal) !important;
    color: white !important;
}

.status-high {
    background-color: var(--color-high) !important;
    color: white !important;
}

.status-flood {
    background-color: var(--color-flood) !important;
    color: white !important;
}

/* Button styles */
.btn {
    @apply inline-flex items-center justify-center font-medium transition-colors;
}

.btn-outline {
    @apply border border-gray-600 text-gray-300 hover:bg-gray-700 hover:text-white;
}

/* Tab navigation - fix layout issues */
.tab-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: #9CA3AF;
    white-space: nowrap;
}

.tab-link:hover {
    color: #F3F4F6;
    background-color: #374151;
}

.tab-link.active {
    color: #3B82F6;
    background-color: #1F2937;
}

/* Fix tab container spacing */
.tab-container {
    display: inline-flex;
    background-color: #1F2937;
    border-radius: 8px;
    padding: 4px;
    gap: 2px;
}

/* Time range buttons */
.time-range-btn,
.modal-time-range {
    color: #9CA3AF;
    background-color: transparent;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.time-range-btn:hover,
.modal-time-range:hover {
    color: #F3F4F6;
    background-color: #374151;
}

.time-range-btn.active,
.modal-time-range.active {
    color: #3B82F6;
    background-color: #1F2937;
}

/* Gauge toggle buttons - mobile optimized */
.gauge-toggle-btn {
    transition: all 0.2s ease;
    min-height: 48px;
    font-size: 11px;
}

.gauge-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Mobile-specific gauge button layout */
@media (max-width: 640px) {
    .gauge-toggle-btn {
        min-height: 40px;
        font-size: 10px;
        padding: 4px !important;
    }
    
    #gauge-toggles {
        gap: 4px !important;
    }
    
    /* Ensure scrollable area for mobile */
    .gauge-controls-container {
        max-height: 180px;
        overflow-y: auto;
    }
}

/* Gauge cards */
.gauge-card {
    transition: all 0.2s ease;
}

.gauge-card:hover {
    background-color: #374151;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Badge styles */
.badge {
    @apply inline-flex items-center font-medium rounded-full;
}

/* Modal styles - prevent layout issues */
.modal,
#gaugeChartModal {
    backdrop-filter: blur(8px);
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9999 !important;
    overflow: hidden !important;
}

.modal-content {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    max-height: 90vh;
    overflow-y: auto;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
    height: 100vh !important;
}

/* Chart modal specific fixes */
#gaugeChartModal .bg-gray-800\/95 {
    max-height: 85vh !important;
    overflow-y: auto !important;
}

#modalChart {
    max-height: 350px !important;
    height: 350px !important;
}

.professional-modal {
    animation: fadeIn 0.2s ease-out;
}

.professional-modal .modal-content {
    animation: slideInUp 0.3s ease-out;
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.95), rgba(17, 24, 39, 0.95));
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from { 
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Map container - ensure proper sizing */
#map {
    background-color: #1F2937;
    width: 100% !important;
    height: 100% !important;
    min-height: 400px !important;
}

/* Map container parent */
.map-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.gauge-marker {
    transition: transform 0.2s ease;
}

.gauge-marker:hover {
    transform: scale(1.2);
}

/* Thumbnail-style map control tiles (radar + map style) */
.map-control-tile {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(156, 163, 175, 0.55);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    background: #111827;
    padding: 0;
}

.map-control-tile:hover {
    transform: translateY(-1px) scale(1.04);
    border-color: rgba(229, 231, 235, 0.85);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
}

.map-control-tile:active {
    transform: translateY(0) scale(1.0);
}

.map-control-label {
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(17, 24, 39, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    z-index: 2;
    line-height: 1;
}

/* Radar active state — cyan ring to match timeline scrubber */
#radar-toggle.radar-active {
    border-color: rgb(34, 211, 238);
    box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.45), 0 6px 16px rgba(0, 0, 0, 0.55);
}

/* QPE rainfall active state — sky-blue accent (distinct from cyan radar) */
#qpe-toggle.qpe-active {
    border-color: rgb(56, 189, 248);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.45), 0 6px 16px rgba(0, 0, 0, 0.55);
}

.radar-tick {
    position: absolute;
    top: 50%;
    width: 2px;
    height: 10px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.radar-tick-past {
    background: rgba(255, 255, 255, 0.55);
    border-radius: 1px;
}

.radar-tick-nowcast {
    background: transparent;
    border-left: 1px dashed rgb(252, 211, 77);
    width: 0;
    height: 10px;
}

#radar-timeline:hover .radar-tick-past {
    background: rgba(255, 255, 255, 0.85);
}

.radar-subdued {
    opacity: 0.6;
    filter: saturate(0.8);
}

/* Mapbox popup transparency and blur - matching legend style */
.mapboxgl-popup-content {
    background: rgba(31, 41, 55, 0.95) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    padding: 0 !important;
    border-radius: 8px !important;
    border: 1px solid rgb(75, 85, 99) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
}

.mapboxgl-popup-tip {
    display: none !important;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 400px !important;
    max-height: 400px !important;
    overflow: hidden;
}

.chart-wrapper {
    position: relative;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden;
}

/* Chart containers - allow proper sizing */
.chart-container,
.chart-wrapper {
    height: 100% !important;
    width: 100% !important;
    position: relative !important;
    display: block !important;
}

/* Combined chart specific sizing */
#combinedChart {
    width: 100% !important;
    height: 100% !important;
    min-height: 400px !important;
    max-height: 400px !important;
}

/* Modal chart containers */
.modal .chart-container {
    height: 400px !important;
    max-height: 400px !important;
}

.modal .chart-container canvas {
    max-height: 400px !important;
    height: 400px !important;
}

/* Loading spinner */
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive design */
@media (max-width: 640px) {
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .gauge-card {
        padding: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
}

/* Info tooltip styling */
.group:hover .group-hover\:opacity-100 {
    opacity: 1 !important;
}

.group:hover .group-hover\:visible {
    visibility: visible !important;
}

.info-tooltip {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 8px;
    width: 256px;
    padding: 12px;
    background-color: rgba(31, 41, 55, 0.95);
    border: 1px solid rgb(75, 85, 99);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    font-size: 12px;
    color: white;
    z-index: 30;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.group:hover .info-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #6B7280;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .no-print {
        display: none !important;
    }
}