/* ============================================
   ThreatMesh Global Cyber Attacker Tracker
   Modern, clean design with dark mode support
   ============================================ */

/* Root Variables */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #60a5fa;
    --color-secondary: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #06b6d4;

    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark Mode Variables */
.dark-mode {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #374151;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
}

#container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   Header & Navigation
   ============================================ */

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #001122;
    transition: all 0.3s ease;
}

.dark-mode .sticky-header {
    background: #001122;
}

.nav-container {
    width: 100%;
    margin: 0;
    padding: 0 2rem;
}

.nav-content {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    padding: 1.25rem 0;
    gap: 2rem;
}

/* Logo */
.logo {
    text-decoration: none;
    justify-self: start;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    transition: color 0.2s ease;
}

.dark-mode .logo-text {
    color: var(--color-primary-light);
}

/* Header Center */
.header-center {
    text-align: center;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
}

.header-stat {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 0.95rem;
}

.dark-mode .header-stat {
    color: var(--color-primary-light);
}

.header-spacer {
    /* Empty spacer for grid balance */
}


/* Navigation Actions */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

/* Language Selector */
.language-selector {
    position: relative;
}

.lang-button,
.theme-button,
.mobile-menu-button {
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.dark-mode .lang-button,
.dark-mode .theme-button,
.dark-mode .mobile-menu-button {
    background: rgba(255, 255, 255, 0.05);
}

.lang-button:hover,
.theme-button:hover,
.mobile-menu-button:hover {
    background: rgba(0, 0, 0, 0.1);
}

.dark-mode .lang-button:hover,
.dark-mode .theme-button:hover,
.dark-mode .mobile-menu-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Language Dropdown */
.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 120px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.lang-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    background: none;
    border: none;
    text-align: left;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.lang-option:hover {
    background: var(--bg-secondary);
}

.lang-option:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.lang-option:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

.mobile-menu-button {
    display: none;
}

.title-icon {
    display: inline-block;
}

/* ============================================
   Main Content - 3 Column Layout
   ============================================ */

.main-content {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 0;
    flex: 1;
    background: #001122;
    overflow: hidden;
    height: calc(100vh - 73px);
    position: relative;
}

/* Sidebars */
.sidebar {
    background: #001122;
    border: none;
    overflow: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar.left {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-spacer {
    flex: 1;
    min-height: 0;
}

.sidebar.right {
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-subsection-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

/* Detection Stats */
.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(0, 34, 68, 0.3);
    border-radius: 0.5rem;
    border-left: 3px solid var(--color-primary);
    transition: all 0.2s ease;
}

.stat-row:hover {
    background: rgba(0, 34, 68, 0.5);
    transform: translateX(3px);
}

.stat-row .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-row .stat-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary);
}

.dark-mode .stat-row .stat-value {
    color: var(--color-primary-light);
}

/* Total Counter */
.total-counter {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    border-radius: 0.75rem;
}

.counter-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    display: block;
}

/* Connection Indicator */
.connection-indicator {
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.status-badge.status-connecting {
    background: rgba(245, 158, 11, 0.2);
    color: var(--color-warning);
}

.status-badge.status-connected {
    background: rgba(16, 185, 129, 0.2);
    color: var(--color-secondary);
}

.status-badge.status-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
}

.status-badge.status-demo {
    background: rgba(6, 182, 212, 0.2);
    color: var(--color-info);
}

/* Ranking Lists */
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rank-item {
    display: grid;
    grid-template-columns: 30px 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 34, 68, 0.3);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.rank-item:hover {
    background: rgba(0, 34, 68, 0.5);
    transform: translateX(3px);
}

.rank-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    color: #ffffff;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}

.rank-label {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

.rank-value {
    font-size: 0.875rem;
    color: var(--color-primary);
    font-weight: 700;
}

.dark-mode .rank-value {
    color: var(--color-primary-light);
}

/* Center Content */
#center-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#map-container {
    flex: 1;
    position: relative;
    background: #001122;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#world-map {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.country {
    transition: all 0.3s ease;
    cursor: pointer;
}

.country:hover {
    fill: #2a4a6a !important;
    stroke: none !important;
    filter: drop-shadow(0 0 5px rgba(96, 165, 250, 0.5));
}

.ocean {
    fill: #001122;
}

.gradient-overlay {
    pointer-events: none;
}

.attack-point {
    filter: drop-shadow(0 0 8px currentColor);
}

.country.source-highlight {
    fill: rgba(239, 68, 68, 0.3) !important;
    stroke: #ef4444 !important;
    stroke-width: 2 !important;
    animation: sourceGlow 2s ease-in-out;
}

.country.target-highlight {
    fill: rgba(96, 165, 250, 0.2) !important;
    stroke: #60a5fa !important;
    stroke-width: 2 !important;
    animation: targetGlow 2s ease-in-out;
}

@keyframes sourceGlow {
    0%, 100% {
        filter: drop-shadow(0 0 0px #ef4444);
    }
    50% {
        filter: drop-shadow(0 0 15px #ef4444);
    }
}

@keyframes targetGlow {
    0%, 100% {
        filter: drop-shadow(0 0 0px #60a5fa);
    }
    50% {
        filter: drop-shadow(0 0 10px #60a5fa);
    }
}

/* Tooltip */
#tooltip {
    position: absolute;
    background: rgba(17, 24, 39, 0.95);
    color: #fff;
    padding: 0;
    border-radius: 0.75rem;
    border: 2px solid var(--color-primary-light);
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
    min-width: 280px;
    max-width: 320px;
}

.tooltip-header {
    background: linear-gradient(135deg, #1e3a8a, #1e293b);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-primary-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0.5rem 0.5rem 0 0;
}

.severity-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 0.5rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: #000;
    text-shadow: none;
}

.tooltip-body {
    padding: 0.625rem 0.75rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.375rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.25rem;
}

.info-label {
    color: #aaa;
    font-size: 0.7rem;
    flex: 1;
}

.info-value {
    color: #fff;
    font-weight: 600;
    text-align: right;
    flex: 1;
    font-family: 'Courier New', monospace;
}

.attack-type-badge {
    color: var(--color-danger) !important;
    text-transform: uppercase;
}

#tooltip.hidden {
    display: none;
}


.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}


/* ============================================
   Footer
   ============================================ */

.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.footer-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section {
    display: flex;
    flex-direction: column;
}

.footer-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.dark-mode .footer-brand {
    color: var(--color-primary-light);
}

.footer-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.footer-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--color-primary);
}

.dark-mode .footer-link:hover {
    color: var(--color-primary-light);
}

.footer-bottom {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-copyright {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-link-brand {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.footer-link-brand:hover {
    text-decoration: underline;
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none;
}

.glow {
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 5px currentColor);
    }
    to {
        filter: drop-shadow(0 0 20px currentColor);
    }
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    #sidebar {
        width: 320px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 240px 1fr 240px;
    }

    .sidebar-section {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: calc(100vh - 65px);
    }

    .sidebar.left,
    .sidebar.right {
        border: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 30vh;
    }

    #center-content {
        min-height: 40vh;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .sticky-header,
    .site-footer,
    #sidebar {
        display: none;
    }

    #map-container {
        width: 100%;
        height: 100vh;
    }
}

/* ============================================
   Loading Screen
   ============================================ */

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: #fff;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 30px;
    border: 4px solid rgba(0, 255, 255, 0.1);
    border-top: 4px solid #00ffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 24px;
    font-weight: 600;
    color: #00ffff;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.loading-subtext {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 300;
}

/* ============================================
   CTA Section in Sidebar
   ============================================ */

.cta-section {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(29, 78, 216, 0.2));
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 0.75rem;
    margin: 0 1rem 1rem 1rem;
    flex-shrink: 0;
    position: relative;
    transition: all 0.3s ease;
}

.cta-section.hidden {
    display: none;
}

.cta-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 0.25rem;
}

.cta-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.cta-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary-light);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.cta-text {
    font-size: 0.8125rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 1rem;
    font-weight: 400;
}

.cta-button {
    display: inline-block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    color: #ffffff;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.cta-button:active {
    transform: translateY(0);
}

/* QR Code Container */
.cta-qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
}

#qrcode {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#qrcode img,
#qrcode canvas {
    display: block;
    margin: 0 auto;
}

.qr-label {
    margin-top: 0.75rem;
    margin-bottom: 0;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
    text-align: center;
}
