/* Professional Minimal Design System */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    
    --radius: 8px;
    --radius-lg: 12px;
}

/* Dark Theme */
body.dark-theme {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    
    --border: #374151;
    --border-light: #4b5563;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    min-height: 100vh;
    padding: 24px;
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.header {
    background: var(--bg-primary);
    padding: 24px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.header-content h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.status-dot.inactive {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.theme-toggle {
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
}

.theme-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

body.dark-theme .sun-icon {
    display: none;
}

body.dark-theme .moon-icon {
    display: block;
}

/* Dashboard Layout */
.dashboard {
    display: grid;
    grid-template-columns: 380px 1fr 380px;
    gap: 24px;
    margin-bottom: 24px;
}

.panel {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.panel h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.form-group select,
.form-group input[type="number"],
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-group select:focus,
.form-group input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.section-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

textarea {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--success);
    color: white;
}

.btn-secondary:hover {
    background: #047857;
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Results */
.result-card {
    margin-bottom: 16px;
    padding: 20px;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.result-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.result-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.risk-meter {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}

.risk-meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    transition: width 1s ease;
}

.priority-badge {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.priority-badge.low {
    background: var(--success);
    color: white;
}

.priority-badge.medium {
    background: var(--warning);
    color: white;
}

.priority-badge.high {
    background: var(--danger);
    color: white;
}

.recommendation-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Reasoning */
.reasoning-card {
    background: var(--bg-secondary);
}

.reasoning-list {
    list-style: none;
    padding: 0;
}

.reasoning-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-primary);
    padding-left: 20px;
    position: relative;
}

.reasoning-item:last-child {
    border-bottom: none;
}

.reasoning-item:before {
    content: "";
    position: absolute;
    left: 0;
    top: 16px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

/* Re-evaluation */
.reevaluation-section {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.reevaluation-section h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 600;
}

.form-group-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.section-title {
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

/* Insights */
.insight-card {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.insight-card h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
}

.gauge-container {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.gauge {
    width: 100%;
    max-width: 180px;
}

.gauge-fill {
    transition: stroke-dashoffset 1s ease, stroke 0.5s ease;
}

.gauge-text {
    font-size: 24px;
    font-weight: 700;
    fill: var(--text-primary);
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Resource Breakdown Styling */
.resource-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.resource-category {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.resource-label {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    font-size: 12px;
}

.resource-value {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.resource-good {
    background: rgba(5, 150, 105, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.resource-moderate {
    background: rgba(217, 119, 6, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.resource-critical {
    background: rgba(220, 38, 38, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* History */
.history-section,
.learnings-section {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.history-section h2,
.learnings-section h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    font-size: 18px;
    font-weight: 600;
}

.history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.history-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-item:hover {
    box-shadow: var(--shadow-md);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-disaster {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
    font-size: 14px;
}

.history-priority {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-priority.low {
    background: var(--success);
    color: white;
}

.history-priority.medium {
    background: var(--warning);
    color: white;
}

.history-priority.high {
    background: var(--danger);
    color: white;
}

.history-risk {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

/* Learnings */
.insights-container {
    display: grid;
    gap: 12px;
}

.insight-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--success);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Notifications */
#notificationContainer {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.notification {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.notification-header strong {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.notification-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.notification-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.notification-body {
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
}

.notification-success {
    border-left: 3px solid var(--success);
}

.notification-warning {
    border-left: 3px solid var(--warning);
}

.notification-danger {
    border-left: 3px solid var(--danger);
}

.notification-info {
    border-left: 3px solid var(--info);
}

/* SOS Button Styling */
.sos-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.3);
}

.sos-button:hover {
    background: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(220, 38, 38, 0.4);
}

.sos-button:active {
    transform: translateY(0);
}

.sos-button.sos-active {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

.sos-icon {
    width: 20px;
    height: 20px;
}

.sos-pulse {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sos-container-header {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
}

.sos-button-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

.sos-button-header:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.4);
}

.sos-button-header.sos-active {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

.sos-icon-small {
    width: 16px;
    height: 16px;
}

/* Responsive */
@media (max-width: 1400px) {
    .dashboard {
        grid-template-columns: 1fr 1fr;
    }
    
    .insights-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        gap: 16px;
    }
    
    .form-group-inline {
        grid-template-columns: 1fr;
    }
    
    .form-group-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    body {
        padding: 16px;
    }
    
    .panel {
        padding: 16px;
    }
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-large {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

.loading-container {
    text-align: center;
    padding: 40px 20px;
}

.loading-container p {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
