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

body {
    background-color: #0a0a0a;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

:root {
    --header-height: 180px;
    --desktop-panel-gap: 20px;
}

/* Header Section */
.threat-header {
    background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);
    border-bottom: 1px solid #333;
    padding: 20px 40px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0;
    flex: 1 1 auto;
}

.threat-header h1 {
    color: #00ff88;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: 2px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.stats-summary {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    color: #888;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    color: #00ff88;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

/* Time Range Selector */
.time-range-selector {
    display: flex;
    gap: 10px;
    margin-top: 0;
    flex-wrap: wrap;
    flex: 0 0 auto;
    justify-content: flex-end;
    align-self: center;
}

.mobile-header-toggle {
    display: none;
    background: transparent;
    border: 1px solid #333;
    color: #00ff88;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-radius: 4px;
    align-self: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-header-toggle:hover {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.08);
}

.time-range-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #888;
    padding: 8px 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.time-range-btn:hover {
    background: #222;
    border-color: #00ff88;
    color: #00ff88;
}

.time-range-btn.active {
    background: #00ff88;
    border-color: #00ff88;
    color: #0a0a0a;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.5);
}

/* Map Container */
.map-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: #0a0a0a;
    overflow: hidden;
}

#threatMap {
    width: 100%;
    height: 100%;
}

/* DataMaps Override Styles */
.datamap {
    position: relative;
    width: 100% !important;
    height: 100% !important;
    top: -80px !important;
}

.datamaps-hoverover {
    background: rgba(26, 26, 26, 0.95) !important;
    background-color: rgba(26, 26, 26, 0.95) !important;
    border: 1px solid #00ff88 !important;
    color: #e0e0e0 !important;
    padding: 8px 12px !important;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3) !important;
    border-radius: 4px !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

.datamaps-hoverover,
.datamaps-hoverover .hoverinfo,
.datamaps-hoverover strong,
.datamaps-hoverover br {
    color: #e0e0e0 !important;
    background: transparent !important;
}

.datamaps-hoverover .hoverinfo {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    outline: none !important;
}

.datamaps-hoverover strong {
    color: #00ff88 !important;
    font-weight: 600 !important;
}

/* Countries Styling */
.datamaps-subunit {
    fill: #1a1a1a;
    stroke: #333;
    stroke-width: 0.5px;
    transition: fill 0.3s ease;
}

.datamaps-subunit:hover {
    fill: #252525;
}

/* Attack Arc Styles */
.attack-arc {
    fill: none;
    stroke-width: 2;
    opacity: 0;
    filter: drop-shadow(0 0 3px currentColor) drop-shadow(0 0 8px currentColor);
    animation: arcFade 2s ease-out forwards;
}

@keyframes arcFade {
    0% {
        stroke-dashoffset: 1000;
        opacity: 0.9;
    }
    50% {
        opacity: 1;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 0;
    }
}

/* Attack type colors */
.attack-arc.complex {
    stroke: #ff4444;
}

.attack-arc.blocklists {
    stroke: #ff8844;
}

.attack-arc.brute_force {
    stroke: #ffcc44;
}

.attack-arc.manual {
    stroke: #bb44ff;
}

/* Server Marker */
.server-marker {
    fill: #00ff88;
    stroke: #00ff88;
    stroke-width: 2;
    filter: drop-shadow(0 0 5px #00ff88) drop-shadow(0 0 10px #00ff88);
    animation: serverPulse 2s infinite;
    transform-origin: center;
    transform-box: fill-box;
}

@keyframes serverPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* Stats Panel */
.stats-panel {
    position: fixed;
    top: calc(var(--header-height) + var(--desktop-panel-gap));
    right: 20px;
    width: 280px;
    background: rgba(26, 26, 26, 0.95);
    border: 1px solid #333;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-height: calc(100vh - var(--header-height) - 60px);
    overflow-y: auto;
    z-index: 50;
}

.stats-panel h3 {
    color: #00ff88;
    font-size: 16px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

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

.country-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #222;
    color: #ccc;
    font-size: 13px;
}

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

.country-name {
    flex: 1;
}

.country-count {
    color: #00ff88;
    font-weight: bold;
}

.attack-types {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.attack-type-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.type-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    filter: drop-shadow(0 0 3px currentColor);
}

.type-label {
    flex: 1;
    color: #ccc;
}

.type-count {
    color: #00ff88;
    font-weight: bold;
}

/* Loading Indicator */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

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

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #333;
    border-top: 3px solid #00ff88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
    filter: drop-shadow(0 0 5px rgba(0, 255, 136, 0.3));
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p {
    color: #888;
    font-size: 14px;
    letter-spacing: 1px;
}

/* Navigation Link */
.nav-link {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
}

.nav-link a {
    color: #00ff88;
    text-decoration: none;
    font-size: 14px;
    padding: 10px 20px;
    background: rgba(26, 26, 26, 0.95);
    border: 1px solid #333;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: inline-block;
}

.nav-link a:hover {
    background: #1a1a1a;
    border-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

/* Scrollbar Styling */
.stats-panel::-webkit-scrollbar {
    width: 8px;
}

.stats-panel::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.stats-panel::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

.stats-panel::-webkit-scrollbar-thumb:hover {
    background: #00ff88;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .stats-panel {
        width: 240px;
        right: 10px;
    }
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
    }

    .threat-header {
        padding: 14px 16px;
        display: block;
    }

    .header-content {
        max-width: none;
    }

    .threat-header h1 {
        font-size: 22px;
        letter-spacing: 1px;
        line-height: 1.2;
    }

    .stats-summary {
        flex-direction: column;
        gap: 12px;
    }

    .stat-item {
        justify-content: space-between;
        align-items: flex-start;
        gap: 16px;
    }

    .stat-label {
        font-size: 12px;
    }

    .stat-value {
        font-size: 18px;
    }

    .stats-panel {
        position: relative;
        top: auto;
        right: auto;
        width: auto;
        margin: 16px;
        padding: 16px;
        max-height: none;
    }

    .map-container {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        height: 52vh;
        min-height: 300px;
        max-height: 420px;
    }

    .datamap {
        top: 0 !important;
    }

    .mobile-header-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin-top: 14px;
    }

    .mobile-header-toggle[aria-expanded="true"] {
        border-color: #00ff88;
        background: rgba(0, 255, 136, 0.1);
        box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
    }

    .time-range-selector {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-top: 16px;
    }

    .time-range-selector.mobile-collapsed {
        display: none;
    }

    .time-range-btn {
        width: 100%;
        padding: 10px 12px;
        font-size: 12px;
        text-align: center;
    }

    .country-item,
    .attack-type-item {
        font-size: 12px;
    }

    .datamaps-hoverover {
        max-width: 220px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    .threat-header {
        padding: 12px;
    }

    .time-range-selector {
        grid-template-columns: 1fr;
    }

    .map-container {
        height: 46vh;
        min-height: 260px;
    }

    .datamap {
        top: 0 !important;
    }

    .stats-panel {
        margin: 12px;
        padding: 14px;
    }
}

/* Additional Effects */
.country-highlight {
    fill: #ff4444 !important;
    filter: drop-shadow(0 0 5px #ff4444);
}

/* Particle effect for intense attacks (optional enhancement) */
@keyframes particleFloat {
    0% {
        transform: translate(0, 0);
        opacity: 1;
    }
    100% {
        transform: translate(var(--x), var(--y));
        opacity: 0;
    }
}
