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

:root {
    --primary: #1E3A8A;
    --secondary: #DC2626;
    --accent: #F59E0B;
    --success: #10B981;
    --info: #2563EB;
    --bg-dark: #0F172A;
    --bg-light: #F8FAFC;
    --text-dark: #1E293B;
    --text-light: #64748B;
    --border: #E2E8F0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    overflow: hidden;
    height: 100vh;
}

/* Header */
.header {
    background: white;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 1000;
}

.header-content {
    max-width: 100%;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.logo svg {
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-input {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    width: 300px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

/* Main Container */
.main-container {
    position: relative;
    height: calc(100vh - 73px);
    width: 100%;
}

#map {
    height: 100%;
    width: 100%;
    background: #e0e7ff;
}

/* Legend */
.legend {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    background: white;
    padding: 1.25rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 500;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.legend h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legend-item span {
    font-size: 0.8125rem;
    color: var(--text-light);
}

/* Custom Marker Styles */
.news-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.news-marker:hover {
    transform: scale(1.1);
}

.marker-stack {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 3px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 0 0 0 currentColor;
    }
    50% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 8px transparent;
    }
}

.marker-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--secondary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* News Popup */
.news-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    animation: popupSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.news-popup.hidden {
    display: none;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.popup-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

.popup-content {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 100px);
}

.news-card {
    background: var(--bg-light);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
}

.news-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.news-card:last-child {
    margin-bottom: 0;
}

.news-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: white;
}

.category-politics { background: #DC2626; }
.category-economy { background: #2563EB; }
.category-military { background: #F59E0B; }
.category-environment { background: #10B981; }

.news-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    line-height: 1.4;
}

.news-summary {
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-light);
}

.news-source {
    font-weight: 500;
}

.news-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.geopolitical-insight {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.05), rgba(37, 99, 235, 0.05));
    border-left: 3px solid var(--primary);
    padding: 1rem;
    margin-top: 1rem;
    border-radius: 0.5rem;
}

.geopolitical-insight h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.geopolitical-insight p {
    font-size: 0.8125rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay.hidden {
    display: none;
}

/* Scrollbar Styling */
.popup-content::-webkit-scrollbar {
    width: 8px;
}

.popup-content::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.popup-content::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 4px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-dark);
}

/* Drawing Toolbar */
.drawing-toolbar {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 500;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    min-width: 200px;
}

.drawing-toolbar h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.tool-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.tool-btn {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    transition: all 0.2s;
}

.tool-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(30, 58, 138, 0.2);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tool-btn.delete-btn {
    background: #FEE2E2;
    color: var(--secondary);
}

.tool-btn.delete-btn:hover {
    background: var(--secondary);
    color: white;
}

/* Drawing Annotations */
.drawing-annotation {
    position: absolute;
    pointer-events: none;
    z-index: 400;
}

.text-annotation {
    background: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--primary);
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff,
        0 0 4px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    pointer-events: auto;
    cursor: move;
}

.drawing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 399;
}

/* Region Highlight */
.region-highlight {
    fill-opacity: 0.2;
    stroke-width: 2;
    stroke-opacity: 0.6;
}
