/**
 * LIVE RISK REPORT - CSS Styling
 * Styles for real-time rainfall + AI risk analysis display
 */

/* Modal styles */
#liveRiskReport {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideIn 0.3s ease-in-out;
}

#liveRiskReport.modal {
    display: none;
}

@keyframes slideIn {
    from {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Modal content */
.modal-content {
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Tab styles */
.tab-button {
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1em;
    transition: all 0.3s ease;
}

.tab-button:hover {
    background: #f0f0f0;
}

.tab-button.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Map styles */
#liveRiskMap {
    width: 100%;
    height: 500px;
    border: 2px solid #ddd;
    border-radius: 5px;
    background: #e8e8e8;
}

/* Leaflet overrides */
#liveRiskMap .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8);
}

/* Table styles */
#liveRiskTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

#liveRiskTable thead {
    background: #4CAF50;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

#liveRiskTable th {
    padding: 12px;
    text-align: left;
    border: 1px solid #ddd;
    font-weight: bold;
}

#liveRiskTable td {
    padding: 10px;
    border: 1px solid #ddd;
}

#liveRiskTable tbody tr {
    transition: background-color 0.2s ease;
}

#liveRiskTable tbody tr:hover {
    background-color: #f5f5f5;
    cursor: pointer;
}

#liveRiskTable tbody tr:nth-child(even) {
    background-color: #fafafa;
}

/* Detail panel styles */
#liveRiskDetails {
    margin-top: 20px;
    padding: 20px;
    background: #f9f9f9;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    display: none;
    animation: slideIn 0.3s ease-in-out;
}

#liveRiskDetails h3 {
    margin-top: 0;
    color: #333;
    font-size: 1.3em;
}

#liveRiskDetails h4 {
    margin-top: 0;
    color: #4CAF50;
}

/* Detail sections */
.detail-section {
    margin: 20px 0;
    padding: 15px;
    background: white;
    border-radius: 4px;
    border-left: 4px solid #ccc;
}

.rainfall-section {
    border-left-color: #0066FF;
}

.risk-section {
    border-left-color: #FF6B6B;
}

.alerts-section {
    border-left-color: #FF6B6B;
}

.trend-section {
    border-left-color: #4CAF50;
}

/* Stat grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 10px 0;
}

.stat {
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
}

.stat label {
    display: block;
    font-size: 0.85em;
    color: #666;
    margin-bottom: 5px;
}

.stat span {
    display: block;
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
}

/* Hazard cards */
.hazard-card {
    padding: 15px;
    border-left: 5px solid #ccc;
    background-color: #f9f9f9;
    border-radius: 4px;
    margin: 10px 0;
}

.flood-card {
    border-left-color: #0066FF;
    background-color: #F0F8FF;
}

.landslide-card {
    border-left-color: #8B4513;
    background-color: #FFF8DC;
}

.hazard-card h5 {
    margin: 0 0 10px 0;
    color: #333;
}

/* Risk bar */
.risk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.risk-value {
    font-size: 1.3em;
    font-weight: bold;
    min-width: 50px;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar > div {
    height: 100%;
    background: linear-gradient(90deg, #90EE90, #FFD700, #FF4500, #8B0000);
    transition: width 0.5s ease;
    border-radius: 10px;
}

/* Alert styles */
#detail_alerts_list {
    list-style: none;
    margin: 0;
    padding: 0;
}

#detail_alerts_list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    color: #333;
    font-size: 0.95em;
}

#detail_alerts_list li:last-child {
    border-bottom: none;
}

/* Action labels */
.action-label {
    margin: 10px 0 0 0;
    font-weight: bold;
    padding: 8px;
    border-radius: 4px;
    background: #f5f5f5;
}

/* Filter bar */
.report-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 5px;
    flex-wrap: wrap;
}

.report-filters div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-filters label {
    font-weight: bold;
    margin-right: 8px;
    white-space: nowrap;
}

.report-filters select,
.report-filters button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.report-filters select {
    background: white;
}

.report-filters select:hover,
.report-filters select:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

.report-filters button {
    background: white;
    color: #333;
}

.report-filters button:hover {
    background: #f0f0f0;
    border-color: #4CAF50;
}

/* Responsive design */
@media (max-width: 1200px) {
    #liveRiskReport {
        width: 95vw !important;
        max-width: 95vw;
    }
    
    .modal-content {
        padding: 15px;
    }
    
    #liveRiskMap {
        height: 400px;
    }
}

@media (max-width: 768px) {
    #liveRiskReport {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 98vw !important;
        max-height: 95vh !important;
    }
    
    .report-filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .report-filters div {
        width: 100%;
    }
    
    #liveRiskMap {
        height: 300px;
    }
    
    .stat-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Close button */
.close-button {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
    float: right;
}

.close-button:hover {
    color: #000;
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.9em;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Color reference legend */
.color-legend {
    display: flex;
    gap: 15px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 25px;
    height: 25px;
    border-radius: 4px;
    border: 1px solid #666;
}

.legend-label {
    font-size: 0.9em;
}

/* Scrollbar styling */
#liveRiskReport ::-webkit-scrollbar {
    width: 8px;
}

#liveRiskReport ::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#liveRiskReport ::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#liveRiskReport ::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Print styles */
@media print {
    #liveRiskReport {
        position: static;
        transform: none;
        z-index: auto;
        width: 100%;
        max-width: 100%;
    }
    
    .report-filters {
        display: none;
    }
    
    .tab-button {
        display: none;
    }
    
    #liveRiskMap {
        display: none;
    }
}
