/* Custom styles for the River & Reservoir monitoring site */

:root {
    --color-dry: #EAB308;
    --color-low: #F97316;
    --color-normal: #3B82F6;
    --color-high: #EF4444;
    --color-flood: #B91C1C;
}

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);
}

/* 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;
    }
}