* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
    color: #e0e0e0;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.world-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(30, 30, 30, 0.95);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.stat-card h2 {
    font-size: 1.2em;
    color: #60a5fa;
    margin-bottom: 15px;
}

.counter {
    font-size: 2.5em;
    font-weight: bold;
    color: #f0f0f0;
    margin: 15px 0;
    font-variant-numeric: tabular-nums;
}

.counter.births {
    color: #48bb78;
}

.counter.deaths {
    color: #f56565;
}

.growth {
    font-size: 1em;
    color: #b0b0b0;
    margin: 8px 0;
}

.growth .label {
    font-weight: 600;
    margin-right: 5px;
}

.growth span:last-child {
    color: #48bb78;
    font-weight: bold;
}

main {
    background: #1a1a1a;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.map-container {
    margin-bottom: 30px;
}

.map-container h2 {
    color: #60a5fa;
    margin-bottom: 15px;
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#resetZoom {
    padding: 10px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
}

#resetZoom:hover {
    background: #2563eb;
}

#searchCountry {
    padding: 10px 15px;
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 1em;
    flex: 1;
    max-width: 300px;
    transition: border-color 0.3s ease;
    background: #2a2a2a;
    color: #e0e0e0;
}

#searchCountry:focus {
    outline: none;
    border-color: #3b82f6;
}

#worldMap {
    width: 100%;
    height: 600px;
    background: #0a0a0a;
    border-radius: 10px;
    cursor: grab;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#worldMap:active {
    cursor: grabbing;
}

.country {
    fill: #2a2a2a;
    stroke: #444;
    stroke-width: 0.5;
    transition: fill 0.2s ease;
    cursor: pointer;
}

.country:hover {
    fill: #3b82f6;
    stroke: #60a5fa;
    stroke-width: 1;
}

.country.selected {
    fill: #2563eb;
}

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 15px 18px;
    border-radius: 10px;
    font-size: 0.9em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    max-width: 350px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    line-height: 1.6;
}

.tooltip.show {
    opacity: 1;
}

.tooltip h3 {
    margin-bottom: 8px;
    color: #fbbf24;
}

.tooltip p {
    margin: 4px 0;
}

.country-info {
    background: #0a0a0a;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.country-info h2 {
    color: #60a5fa;
    margin-bottom: 15px;
}

.country-info .country-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.country-stat {
    background: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.country-stat h3 {
    font-size: 0.9em;
    color: #9ca3af;
    margin-bottom: 8px;
}

.country-stat .value {
    font-size: 1.5em;
    font-weight: bold;
    color: #f0f0f0;
}

.country-stat-section {
    grid-column: 1/-1;
    margin-top: 10px;
}

.country-stat-section h3 {
    color: #60a5fa;
    font-size: 1.1em;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #333;
}

.top-countries {
    margin-top: 30px;
}

.top-countries h2 {
    color: #60a5fa;
    margin-bottom: 20px;
}

#topCountriesList {
    display: grid;
    gap: 12px;
}

.country-rank {
    display: flex;
    align-items: center;
    background: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.country-rank:hover {
    background: #333;
    transform: translateX(5px);
    border-color: #3b82f6;
}

.country-rank .rank {
    font-size: 1.5em;
    font-weight: bold;
    color: #60a5fa;
    min-width: 40px;
}

.country-rank .name {
    flex: 1;
    font-size: 1.1em;
    font-weight: 600;
    color: #f0f0f0;
}

.country-rank .population {
    font-size: 1.1em;
    color: #b0b0b0;
    font-variant-numeric: tabular-nums;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding: 20px 0;
}

.pagination-controls button {
    padding: 10px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.pagination-controls button:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-2px);
}

.pagination-controls button:disabled {
    background: #4a5568;
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination-controls #pageInfo {
    font-size: 1.1em;
    color: #e0e0e0;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    padding: 20px;
    font-size: 0.9em;
}

footer p {
    margin: 5px 0;
    opacity: 0.9;
}

.app-status {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.app-status span {
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.85em;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .world-stats {
        grid-template-columns: 1fr;
    }

    .counter {
        font-size: 2em;
    }

    #worldMap {
        height: 400px;
    }

    .controls {
        flex-direction: column;
    }

    #searchCountry {
        max-width: 100%;
    }
}

/* Animation for counters */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.counter.updating {
    animation: pulse 0.5s ease;
}

/* Animations pour les notifications */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* PWA Install button hover effect */
.install-button:hover {
    background: #2563eb !important;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5) !important;
}

/* Loading indicator */
#loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Offline indicator */
.offline-mode {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f59e0b;
    color: white;
    padding: 10px;
    text-align: center;
    z-index: 9999;
    font-weight: 600;
}

/* Skeleton Loading Screens */
.skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

.skeleton-text {
    height: 1em;
    width: 100%;
    margin: 4px 0;
}

.skeleton-text-sm {
    height: 0.8em;
    width: 60%;
}

.skeleton-counter {
    height: 2.5em;
    width: 80%;
    margin: 15px auto;
    border-radius: 8px;
}

.skeleton-counter-sm {
    height: 1.5em;
    width: 50%;
    display: inline-block;
    border-radius: 4px;
}

.skeleton-inline {
    display: inline-block;
    height: 1.2em;
    width: 120px;
    vertical-align: middle;
    border-radius: 4px;
}

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

/* Legacy loading indicators - kept for backwards compatibility */
.loading-indicator {
    display: none;
}

.loading-indicator-small {
    display: none;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* Enhanced stat cards with visual hierarchy */
.main-counter-card {
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.98) 0%, rgba(40, 40, 40, 0.98) 100%) !important;
    border: 2px solid rgba(96, 165, 250, 0.3) !important;
}

.births-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(30, 30, 30, 0.95) 100%) !important;
    border: 1px solid rgba(72, 187, 120, 0.3) !important;
}

.births-card h2 {
    color: #48bb78 !important;
}

.births-card .counter {
    color: #68d391 !important;
    text-shadow: 0 0 20px rgba(72, 187, 120, 0.3);
}

.deaths-card {
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.15) 0%, rgba(30, 30, 30, 0.95) 100%) !important;
    border: 1px solid rgba(156, 163, 175, 0.3) !important;
}

.deaths-card h2 {
    color: #9ca3af !important;
}

.deaths-card .counter {
    color: #d1d5db !important;
    text-shadow: 0 0 20px rgba(156, 163, 175, 0.2);
}

/* Projection cards animation */
.projection-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.projection-card:hover {
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4) !important;
}

/* Data loaded state - remove loading appearance */
.data-loaded .loading-indicator,
.data-loaded .loading-indicator-small {
    display: none;
}

/* Error state styling */
.data-error {
    color: #f87171 !important;
}

.data-error .counter {
    color: #f87171 !important;
}

/* Offline data indicator */
.offline-data-notice {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #fbbf24;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.offline-data-notice.hidden {
    display: none;
}

/* Success animation when data loads */
@keyframes dataLoaded {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.counter.loaded {
    animation: dataLoaded 0.5s ease-out;
}

/* Responsive improvements for mobile map */
@media (max-width: 768px) {
    .projection-cards {
        grid-template-columns: 1fr !important;
    }

    .projection-card {
        padding: 15px !important;
    }

    .projection-card .counter {
        font-size: 1.3em !important;
    }

    /* Better touch targets for map on mobile */
    #worldMap {
        touch-action: pan-x pan-y pinch-zoom;
    }

    .country {
        stroke-width: 1px;
    }
}

/* Settings Menu */
.settings-btn {
    padding: 10px 15px;
    background: #4a5568;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
}

.settings-btn:hover {
    background: #374151;
}

.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.settings-modal.show {
    display: flex;
}

.settings-content {
    background: #1a1a1a;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.settings-content h2 {
    color: #60a5fa;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.settings-section h3 {
    color: #9ca3af;
    font-size: 0.9em;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.settings-item label {
    color: #e0e0e0;
}

.settings-item button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.settings-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.5em;
    cursor: pointer;
    transition: color 0.3s ease;
}

.settings-close:hover {
    color: #f56565;
}

/* Fullscreen Map */
.map-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: #0a0a0a;
    padding: 20px;
    border-radius: 0;
    margin: 0;
}

.map-container.fullscreen #worldMap {
    height: calc(100vh - 120px);
    border-radius: 0;
}

.map-container.fullscreen .controls {
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.fullscreen-btn {
    padding: 10px 15px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.3s ease;
}

.fullscreen-btn:hover {
    background: #4f46e5;
}

/* Map Legend for Choropleth */
.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.9);
    padding: 15px;
    border-radius: 10px;
    z-index: 100;
    min-width: 200px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.map-legend h4 {
    color: #60a5fa;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.legend-scale {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85em;
    color: #b0b0b0;
}

.legend-color {
    width: 25px;
    height: 15px;
    border-radius: 3px;
}

.legend-gradient {
    height: 15px;
    width: 100%;
    border-radius: 3px;
    margin-bottom: 5px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: #9ca3af;
}

/* Country Comparison Tool */
.comparison-container {
    background: #0a0a0a;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.comparison-container h2 {
    color: #60a5fa;
    margin-bottom: 20px;
}

.comparison-selectors {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    margin-bottom: 25px;
}

.comparison-selectors .vs {
    font-size: 1.5em;
    font-weight: bold;
    color: #f59e0b;
}

.comparison-select {
    padding: 12px 15px;
    background: #2a2a2a;
    border: 2px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 1em;
    cursor: pointer;
    width: 100%;
}

.comparison-select:focus {
    border-color: #3b82f6;
    outline: none;
}

.comparison-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.comparison-country {
    background: #1a1a1a;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.comparison-country h3 {
    color: #fbbf24;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.comparison-metric {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.comparison-metric:last-child {
    border-bottom: none;
}

.comparison-metric .metric-label {
    color: #9ca3af;
}

.comparison-metric .metric-value {
    color: #e0e0e0;
    font-weight: 600;
}

.comparison-metric .metric-value.higher {
    color: #48bb78;
}

.comparison-metric .metric-value.lower {
    color: #f56565;
}

/* Trend Charts */
.chart-container {
    background: #0a0a0a;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-container h2 {
    color: #60a5fa;
    margin-bottom: 20px;
}

.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-svg {
    width: 100%;
    height: 100%;
}

.chart-line {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
}

.chart-line.historical {
    stroke: #3b82f6;
}

.chart-line.projection {
    stroke: #f59e0b;
    stroke-dasharray: 8, 4;
}

.chart-area {
    opacity: 0.2;
}

.chart-area.historical {
    fill: #3b82f6;
}

.chart-area.projection {
    fill: #f59e0b;
}

.chart-dot {
    fill: #60a5fa;
    stroke: white;
    stroke-width: 2;
    cursor: pointer;
    transition: r 0.2s ease;
}

.chart-dot:hover {
    r: 8;
}

.chart-axis {
    color: #6b7280;
}

.chart-axis line,
.chart-axis path {
    stroke: #374151;
}

.chart-axis text {
    fill: #9ca3af;
    font-size: 12px;
}

.chart-grid line {
    stroke: rgba(255, 255, 255, 0.05);
}

.chart-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9em;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.chart-tooltip.show {
    opacity: 1;
}

/* Did You Know Section */
.did-you-know {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(30, 30, 30, 0.95) 100%);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.did-you-know h2 {
    color: #818cf8;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.did-you-know .fact {
    font-size: 1.1em;
    color: #e0e0e0;
    line-height: 1.6;
    margin-bottom: 15px;
}

.did-you-know .fact-source {
    font-size: 0.85em;
    color: #9ca3af;
    font-style: italic;
}

.did-you-know .refresh-fact {
    padding: 8px 16px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.did-you-know .refresh-fact:hover {
    background: #4f46e5;
}

/* Sources Section */
.sources-section {
    background: #0a0a0a;
    padding: 25px;
    border-radius: 10px;
    margin-top: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sources-section h2 {
    color: #60a5fa;
    margin-bottom: 20px;
}

.source-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: background 0.3s ease;
}

.source-item:hover {
    background: #2a2a2a;
}

.source-icon {
    font-size: 1.5em;
}

.source-info h3 {
    color: #e0e0e0;
    margin-bottom: 5px;
}

.source-info p {
    color: #9ca3af;
    font-size: 0.9em;
    margin-bottom: 8px;
}

.source-info a {
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.85em;
}

.source-info a:hover {
    text-decoration: underline;
}

/* Projection Scenarios */
.projection-scenarios {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.scenario-btn {
    padding: 8px 16px;
    background: #2a2a2a;
    color: #9ca3af;
    border: 1px solid #374151;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.scenario-btn:hover {
    background: #374151;
    color: #e0e0e0;
}

.scenario-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.scenario-description {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 0.9em;
    color: #b0b0b0;
    line-height: 1.6;
}

/* Mobile Responsive for new components */
@media (max-width: 768px) {
    .comparison-selectors {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .comparison-selectors .vs {
        margin: 10px 0;
    }

    .comparison-results {
        grid-template-columns: 1fr;
    }

    .map-legend {
        position: relative;
        bottom: auto;
        left: auto;
        margin-top: 15px;
    }

    .chart-wrapper {
        height: 250px;
    }

    .settings-content {
        width: 95%;
        padding: 20px;
    }
}
