/* Custom CSS for Humanitarian Dashboard */

:root {
    --primary-color: #1e3a8a;
    --secondary-color: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    --light-color: #f8fafc;
    --dark-color: #1e293b;
    --gradient-1: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.1);
    --prism-ease: cubic-bezier(.22, 1, .36, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(to bottom, #f8fafc 0%, #e2e8f0 100%);
    line-height: 1.6;
    color: var(--dark-color);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.4rem;
}

/* Card Styling */
.card {
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: all 0.4s var(--prism-ease);
    margin-bottom: 1.5rem;
    background: white;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.18);
}

.card-header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    border-radius: 16px 16px 0 0 !important;
    border: none;
    padding: 1.25rem 1.75rem;
    position: relative;
    overflow: hidden;
}

.card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.12) 0%, transparent 100%);
    pointer-events: none;
}

.card-header .card-title {
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

/* Metrics Cards */
.metric-card {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    border-radius: 16px;
    padding: 2rem 1.5rem;
    text-align: center;
    transition: all 0.4s var(--prism-ease);
    position: relative;
    overflow: hidden;
    border: none;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    transition: transform 0.5s var(--prism-ease);
}

.metric-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 16px 40px rgba(30, 64, 175, 0.25);
}

.metric-card:hover::before {
    transform: translate(-25%, -25%);
}

.metric-card .metric-value {
    font-size: 2.75rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metric-card .metric-label {
    font-size: 0.875rem;
    opacity: 0.95;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.metric-card .metric-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Chart Containers */
.chart-container {
    position: relative;
    height: 400px;
    margin: 1rem 0;
}

/* Country Details */
.country-info-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 12px;
    padding: 1.5rem;
}

.country-info-card h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
}

.info-value {
    font-weight: 600;
}

/* Severity and Risk Indicators */
.severity-indicator {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.severity-critical {
    background-color: var(--danger-color);
    color: white;
}

.severity-high {
    background-color: var(--warning-color);
    color: white;
}

.severity-medium {
    background-color: var(--info-color);
    color: white;
}

.severity-low {
    background-color: var(--success-color);
    color: white;
}

/* Funding Status */
.funding-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.funding-adequate {
    background-color: var(--success-color);
    color: white;
}

.funding-insufficient {
    background-color: var(--warning-color);
    color: white;
}

.funding-critical {
    background-color: var(--danger-color);
    color: white;
}

/* Data Tables */
.data-table {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.data-table table {
    margin: 0;
}

.data-table th {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
    padding: 1rem;
    border: none;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.03);
}

/* Loading States */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    height: 20px;
    margin: 0.5rem 0;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Mobile-First Responsive Design - ENHANCED */

/* Viewport meta tag handling */
.container {
    padding-left: 15px;
    padding-right: 15px;
}

/* Header/Title - Mobile Friendly */
h1, h2, h3 {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    line-height: 1.2;
}

/* Navbar - Mobile Optimized */
.navbar {
    padding: 0.5rem 1rem;
}

.navbar-brand {
    font-size: clamp(0.9rem, 3vw, 1.4rem);
    line-height: 1.3;
}

.navbar-toggler {
    border: none;
    padding: 0.5rem;
}

.navbar-collapse {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    padding: 1rem;
    border-radius: 14px;
    margin-top: 0.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

/* Nav Links - Touch-Friendly */
.nav-link {
    padding: 0.75rem 1rem !important;
    margin: 0.25rem 0;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.nav-link:hover, .nav-link:active {
    background: rgba(37, 99, 235, 0.1);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .metric-card {
        padding: 1.5rem 1rem;
    }

    .metric-card .metric-value {
        font-size: 2.25rem;
    }
}

@media (max-width: 992px) {
    .navbar-brand {
        font-size: 1.2rem;
    }

    .card-header {
        padding: 1rem 1.25rem;
    }

    .metric-card .metric-value {
        font-size: 2rem;
    }

    .metric-card .metric-icon {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    h2 {
        font-size: 1.5rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .metric-card {
        padding: 1.25rem 1rem;
        margin-bottom: 1rem;
    }

    .metric-card .metric-value {
        font-size: 1.75rem;
    }

    .metric-card .metric-icon {
        font-size: 1.75rem;
    }

    .metric-card .metric-label {
        font-size: 0.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.875rem 1rem;
    }

    .card-header .card-title {
        font-size: 1rem;
    }

    .chart-container {
        height: 300px;
    }

    .search-filter-container {
        padding: 1rem;
    }

    .search-input {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }

    .export-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }

    .form-select {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }

    .toast {
        min-width: 250px;
        padding: 0.875rem 1.25rem;
    }

    .loading-content {
        padding: 1.5rem 2rem;
    }

    .stat-badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.875rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }

    #mapContainer {
        height: 400px !important;
    }
}

@media (max-width: 576px) {
    /* Prevent Horizontal Overflow */
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    /* Container and Spacing */
    .container {
        padding-left: 10px;
        padding-right: 10px;
        width: 100%;
        max-width: 100%;
    }

    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Row fixes */
    .row {
        margin-left: -10px;
        margin-right: -10px;
    }

    .row > * {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Typography - Mobile Friendly */
    body {
        font-size: 15px;
        line-height: 1.5;
    }

    h1 {
        font-size: 1.75rem !important;
        line-height: 1.3;
        margin-bottom: 1rem;
    }

    h2 {
        font-size: 1.25rem !important;
        margin-bottom: 0.75rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* Navbar - Compact */
    .navbar {
        padding: 0.5rem 0.75rem;
    }

    .navbar-brand {
        font-size: 0.95rem !important;
        padding: 0.25rem 0;
    }

    /* Navigation Buttons */
    .nav-link {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem !important;
    }

    /* Cards - Mobile Optimized */
    .card {
        margin-bottom: 1rem;
        border-radius: 12px;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    .card-header .card-title {
        font-size: 0.95rem;
    }

    .card-body {
        padding: 1rem 0.875rem;
    }

    /* Metric Cards - Compact */
    .metric-card {
        padding: 1rem 0.75rem;
        margin-bottom: 0.75rem;
    }

    .metric-card .metric-value {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .metric-card .metric-icon {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .metric-card .metric-label {
        font-size: 0.7rem;
        line-height: 1.3;
    }

    /* Charts - Mobile Height */
    .chart-container {
        height: 250px;
        margin: 0.5rem 0;
    }

    /* Buttons - Touch Friendly */
    .export-btn, .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-height: 44px; /* iOS touch target */
    }

    .btn-sm {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
        min-height: 38px;
    }

    /* Tables - Scrollable */
    .data-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table table {
        font-size: 0.8rem;
        min-width: 600px; /* Force horizontal scroll */
    }

    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
        white-space: nowrap;
    }

    /* Search/Filter - Stack Vertically */
    .search-filter-container {
        padding: 1rem 0.875rem;
    }

    .search-filter-container .row {
        gap: 0.75rem;
    }

    .search-filter-container .col-md-6,
    .search-filter-container .col-md-4,
    .search-filter-container .col-md-3 {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .search-input, .form-select {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Map - Mobile Size */
    #mapContainer {
        height: 350px !important;
        border-radius: 8px;
    }

    /* Info Items - Stack Better */
    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        padding: 0.75rem 0;
    }

    /* Toast Notifications - Smaller */
    .toast {
        min-width: 280px;
        padding: 0.875rem 1rem;
        font-size: 0.85rem;
    }

    .toast-container {
        right: 10px;
        left: 10px;
        top: 70px;
    }

    /* Loading Overlay - Compact */
    .loading-content {
        padding: 1.5rem 1.25rem;
        margin: 0 1rem;
    }

    /* Badges and Pills - Readable */
    .stat-badge, .severity-indicator, .funding-status {
        font-size: 0.7rem;
        padding: 0.4rem 0.75rem;
        white-space: nowrap;
    }

    /* Remove Hover Effects on Touch Devices */
    .card:hover,
    .metric-card:hover {
        transform: none;
    }

    /* Better Tap Targets */
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Comparison Items - Full Width */
    .comparison-item {
        padding: 0.875rem;
        margin-bottom: 0.75rem;
    }

    /* Country Info Card - Mobile */
    .country-info-card {
        padding: 1.25rem 1rem;
    }

    .country-info-card h3 {
        font-size: 1.1rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .export-btn,
    .search-filter-container,
    .toast-container,
    .loading-overlay,
    footer {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    body {
        background: white;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s var(--prism-ease);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.5s var(--prism-ease);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.5s var(--prism-ease);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.bg-gradient-success {
    background: linear-gradient(135deg, var(--success-color), #2ecc71);
}

.bg-gradient-warning {
    background: linear-gradient(135deg, var(--warning-color), #f1c40f);
}

.bg-gradient-danger {
    background: linear-gradient(135deg, var(--danger-color), #c0392b);
}

/* Footer */
footer {
    margin-top: auto;
}

footer h5 {
    color: var(--secondary-color);
    font-weight: 600;
}

/* Form Styling */
.form-select {
    border-radius: 10px;
    border: 2px solid rgba(148, 163, 184, 0.2);
    padding: 0.75rem 1rem;
    transition: border-color 0.3s var(--prism-ease), box-shadow 0.3s var(--prism-ease);
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Alert Styling */
.alert {
    border: none;
    border-radius: 12px;
    padding: 1rem 1.5rem;
}

.alert-info {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
}

.alert-warning {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    color: white;
}

.alert-danger {
    background: linear-gradient(135deg, #fd79a8, #e84393);
    color: white;
}

.alert-success {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
}

/* Map Legend Styling */
.legend-container {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.legend {
    font-size: 12px;
}

.legend-item {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
}

.legend-item:last-child {
    margin-bottom: 0;
}

/* Map Container Styling */
#mapContainer {
    border-radius: 8px;
    overflow: hidden;
}

/* Leaflet Map Customization */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 0;
    line-height: 1.4;
}

.leaflet-control-zoom a {
    background-color: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
}

.leaflet-control-zoom a:hover {
    background-color: var(--secondary-color) !important;
}

/* Search and Filter Section */
.search-filter-container {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.search-input {
    border: 2px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s var(--prism-ease);
    width: 100%;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Export Button Styling */
.export-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.35s var(--prism-ease);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.export-btn i {
    font-size: 1.1rem;
}

/* Comparison View */
.comparison-card {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.comparison-item {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.35s var(--prism-ease);
}

.comparison-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-content {
    background: white;
    border-radius: 16px;
    padding: 2rem 3rem;
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.loading-spinner-large {
    width: 4rem;
    height: 4rem;
    border: 4px solid #e5e7eb;
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9998;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

.toast-info {
    border-left: 4px solid var(--info-color);
}

/* Stats Badges */
.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0c4a6e;
    margin: 0.25rem;
}
