/* Impact Analysis Panel Styles */

.impact-panel {
    position: fixed;
    top: 70px;
    right: -420px;
    width: 400px;
    max-height: calc(100vh - 90px);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.impact-panel.visible {
    right: 0;
}

/* Header */
.impact-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    border-radius: 12px 0 0 0;
}

.impact-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.impact-panel-title i {
    font-size: 18px;
}

.impact-panel-actions {
    display: flex;
    gap: 8px;
}

.impact-panel-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.impact-panel-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Content */
.impact-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Loading State */
.impact-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    color: #64748b;
}

.impact-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.impact-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    text-align: center;
    color: #64748b;
}

.impact-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.impact-empty p {
    margin: 0;
    line-height: 1.6;
}

/* Error State */
.impact-error {
    padding: 40px 20px;
    text-align: center;
    color: #dc2626;
}

.impact-error i {
    font-size: 36px;
    margin-bottom: 12px;
}

.impact-error button {
    margin-top: 16px;
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Location Header */
.impact-location {
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.impact-location h2 {
    margin: 0 0 6px 0;
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.impact-area {
    font-size: 13px;
    color: #64748b;
}

/* Section */
.impact-section {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.impact-section:last-child {
    border-bottom: none;
}

.impact-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.impact-section-header i {
    color: #3b82f6;
    font-size: 14px;
}

.impact-resolution-badge {
    margin-left: auto;
    padding: 2px 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.impact-warning-badge {
    padding: 2px 6px;
    color: #f59e0b;
    font-size: 12px;
}

.impact-warning-badge i {
    color: #f59e0b !important;
}

/* Stats Row */
.impact-stats-row {
    display: flex;
    gap: 16px;
}

.impact-stat {
    flex: 1;
    text-align: center;
    padding: 16px;
    background: #f8fafc;
    border-radius: 10px;
}

.impact-stat.primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.impact-stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: #1e293b;
}

.impact-stat.primary .impact-stat-value {
    color: white;
}

.impact-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
    color: #64748b;
}

.impact-stat.primary .impact-stat-label {
    color: rgba(255, 255, 255, 0.8);
}

/* Demographics */
.impact-demographics {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.impact-demo-item {
    position: relative;
    background: #f1f5f9;
    border-radius: 8px;
    height: 60px;
    overflow: hidden;
}

.impact-demo-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    opacity: 0.9;
    border-radius: 8px 0 0 8px;
}

.impact-demo-info {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
    gap: 16px;
}

.impact-demo-percent {
    font-size: 22px;
    font-weight: 700;
    color: white;
    min-width: 60px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.impact-demo-count {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
}

.impact-demo-label {
    margin-left: auto;
    text-align: right;
    font-size: 12px;
    color: #64748b;
    line-height: 1.3;
}

.impact-demo-label small {
    font-size: 10px;
    color: #94a3b8;
}

/* Infrastructure Grid */
.impact-infrastructure {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.impact-infra-item {
    text-align: center;
    padding: 16px 8px;
    background: #f8fafc;
    border-radius: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.impact-infra-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.impact-infra-item.empty {
    opacity: 0.5;
}

.impact-infra-item.failed {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px dashed #f59e0b;
}

.impact-infra-item.failed .impact-infra-count {
    color: #f59e0b;
}

.impact-infra-item.failed .impact-infra-count i {
    font-size: 18px;
}

/* Infrastructure Error Message */
.impact-infra-error {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #dc2626;
}

.impact-infra-error i {
    font-size: 16px;
    color: #dc2626;
}

.impact-infra-item i {
    font-size: 20px;
    color: #3b82f6;
    margin-bottom: 8px;
}

.impact-infra-count {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.impact-infra-label {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Capital Exposure */
.impact-capital {
    text-align: center;
}

.impact-capital-total {
    padding: 20px;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    border-radius: 12px;
    margin-bottom: 16px;
}

.impact-capital-value {
    font-size: 32px;
    font-weight: 700;
    color: white;
}

.impact-capital-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.impact-capital-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.impact-capital-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 13px;
}

.impact-capital-item span:first-child {
    color: #64748b;
}

.impact-capital-item span:last-child {
    font-weight: 600;
    color: #1e293b;
}

/* Countries Affected */
.impact-countries {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #f8fafc;
}

.impact-countries-count {
    font-size: 28px;
    font-weight: 700;
    color: #3b82f6;
}

.impact-countries-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #64748b;
}

/* Footer */
.impact-panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    border-radius: 0 0 0 12px;
    font-size: 11px;
    color: #94a3b8;
}

/* History */
.impact-history {
    padding: 0;
}

.impact-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.impact-history-header h3 {
    margin: 0;
    font-size: 14px;
    color: #1e293b;
}

.impact-history-back {
    background: none;
    border: none;
    color: #3b82f6;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.impact-history-list {
    max-height: 400px;
    overflow-y: auto;
}

.impact-history-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.2s;
}

.impact-history-item:hover {
    background: #f8fafc;
}

.impact-history-location {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.impact-history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #64748b;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .impact-panel {
        background: rgba(30, 41, 59, 0.98);
    }

    .impact-panel-header {
        background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
        border-bottom-color: #334155;
    }

    .impact-location {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        border-bottom-color: #334155;
    }

    .impact-location h2 {
        color: #f1f5f9;
    }

    .impact-section {
        border-bottom-color: #334155;
    }

    .impact-stat {
        background: #334155;
    }

    .impact-stat-value {
        color: #f1f5f9;
    }

    .impact-stat-label {
        color: #94a3b8;
    }

    .impact-demo-item {
        background: #334155;
    }

    .impact-demo-count {
        color: #f1f5f9;
    }

    .impact-infra-item {
        background: #334155;
    }

    .impact-infra-count {
        color: #f1f5f9;
    }

    .impact-capital-item {
        background: #334155;
    }

    .impact-capital-item span:last-child {
        color: #f1f5f9;
    }

    .impact-countries {
        background: #334155;
    }

    .impact-panel-footer {
        background: #1e293b;
        border-top-color: #334155;
    }

    .impact-history-item {
        border-bottom-color: #334155;
    }

    .impact-history-item:hover {
        background: #334155;
    }

    .impact-history-location {
        color: #f1f5f9;
    }
}

/* Injected Analyze Button in Popups */
.impact-analyze-inject-container {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.impact-analyze-inject-btn {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.impact-analyze-inject-btn:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.impact-analyze-inject-btn i {
    font-size: 14px;
}

/* Infrastructure Markers */
.infrastructure-marker {
    background: transparent !important;
    border: none !important;
}

.infra-marker-icon {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}

.infra-marker-icon i {
    transform: rotate(45deg);
    color: white;
    font-size: 14px;
}

/* Infrastructure Popup */
.infra-popup-container .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
}

.infra-popup-container .leaflet-popup-content {
    margin: 0;
    min-width: 200px;
}

.infra-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: white;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.infra-popup-header i {
    font-size: 14px;
}

.infra-popup-content {
    padding: 12px 14px;
}

.infra-popup-name {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
    margin-bottom: 6px;
}

.infra-popup-detail {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.infra-popup-coords {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 8px;
    font-family: monospace;
}

/* Infrastructure Toggle in Panel */
.impact-infra-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.impact-infra-toggle-label {
    font-size: 12px;
    color: #64748b;
}

.impact-infra-toggle-btn {
    padding: 6px 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    min-width: 110px;
}

.impact-infra-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.impact-infra-toggle-btn.active {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.impact-infra-toggle-btn.loading {
    opacity: 0.7;
    cursor: wait;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .impact-panel {
        width: 100%;
        right: -100%;
        border-radius: 0;
        top: 60px;
        max-height: calc(100vh - 60px);
    }

    .impact-panel.visible {
        right: 0;
    }

    .impact-panel-header {
        border-radius: 0;
    }

    .impact-infrastructure {
        grid-template-columns: repeat(2, 1fr);
    }

    .impact-stats-row {
        flex-direction: column;
    }
}
