* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --iran: #009b3a;
    --iran-glow: rgba(0, 155, 58, 0.4);
    --hez: #ffd700;
    --hez-glow: rgba(255, 215, 0, 0.4);
    --missiles: #ff4444;
    --drones: #8b5cf6;
    --bg: #0a0a0f;
    --card-bg: #131320;
    --card-border: #1e1e30;
    --text: #e0e0e0;
    --muted: #777;
    --accent: #ff3b3b;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-y: scroll;
}

/* Header */
header {
    text-align: center;
    padding: 1.5rem 1rem 0.8rem;
    background: linear-gradient(180deg, #1a0a0a 0%, var(--bg) 100%);
}

header h1 { font-size: 2rem; color: var(--accent); margin-bottom: 0.2rem; }
header p { color: var(--muted); font-size: 0.85rem; }

/* Range tabs */
.range-tabs {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.8rem 1rem 0.3rem;
}

.range-btn {
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    border: 1px solid #333;
    background: var(--card-bg);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.range-btn:hover { border-color: #555; color: var(--text); }
.range-btn.active { background: var(--accent); border-color: var(--accent); color: white; }


.date-picker-row {
    display: flex;
    justify-content: center;
    min-height: 2.5rem;
}

.date-picker-row input {
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #333;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.9rem;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem 1rem 0.5rem;
    min-height: 3.5rem;
}

.controls input,
.controls button:not(.search-clear) {
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #333;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.9rem;
}

.search-wrapper { position: relative; }

.search-wrapper input {
    min-width: 240px;
    direction: rtl;
    text-align: right;
    padding-left: 1.8rem;
}

.search-clear {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    display: none;
}
.search-clear:hover { color: var(--text); }

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #1a1a28;
    border: 1px solid #333;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
}

.search-item {
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    direction: rtl;
    text-align: right;
    font-size: 0.9rem;
    transition: background 0.1s;
}

.search-item:hover { background: #252535; }
.search-item.dim { color: #666; }
.search-item .search-count { color: #666; font-size: 0.75rem; }

.controls button:not(.search-clear) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.controls button:not(.search-clear):hover { background: #ee3333; }

/* ===== OVERVIEW PAGE ===== */

/* Summary stats row */
.overview-stats {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    flex-wrap: wrap;
    min-height: 68px;
}

.overview-stat {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.6rem 1.2rem;
    text-align: center;
    min-width: 100px;
}

.overview-stat .value { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.overview-stat .label { font-size: 0.65rem; color: var(--muted); margin-top: 0.1rem; }
.overview-stat.iran { border-color: var(--iran); }
.overview-stat.iran .value { color: var(--iran); }
.overview-stat.hezbollah { border-color: var(--hez); }
.overview-stat.hezbollah .value { color: var(--hez); }

.overview-stat.iran .label { color: var(--iran); }
.overview-stat.hezbollah .label { color: var(--hez); }
.overview-stat.missiles { border-color: var(--missiles); }
.overview-stat.missiles .value { color: var(--missiles); }
.overview-stat.missiles .label { color: var(--missiles); }
.overview-stat.drones { border-color: var(--drones); }
.overview-stat.drones .value { color: var(--drones); }
.overview-stat.drones .label { color: var(--drones); }

/* Filter buttons */
.filter-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0 1rem;
}

.filter-row,
.toggle-row,
.city-data-toggle,
.city-graph-toggle,
.data-view-toggle,
.graph-controls {
    display: flex;
    justify-content: center;
    padding: 0.15rem 0;
}

/* Segmented toggle (shared pill style) */
.seg-toggle {
    display: inline-flex;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
}

.seg-toggle .view-btn,
.seg-toggle .graph-toggle-btn {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex: 1;
    text-align: center;
}

.seg-toggle .view-btn:hover,
.seg-toggle .graph-toggle-btn:hover {
    color: var(--text);
}

.seg-toggle .view-btn + .view-btn,
.seg-toggle .graph-toggle-btn + .graph-toggle-btn {
    border-right: 1px solid var(--card-border);
}

.seg-toggle .view-btn.active,
.seg-toggle .graph-toggle-btn.active {
    background: #2a2a40;
    color: var(--text);
}

.filter-bar.disabled .seg-toggle {
    opacity: 0.35;
    pointer-events: none;
}



/* ===== CITY DETAIL PAGE ===== */

.stats {
    max-width: 500px;
    margin: 0 auto;
    padding: 0.8rem 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.stats-grid:has(.stat-card:only-child) {
    grid-template-columns: 1fr;
    max-width: 200px;
    margin: 0 auto;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.7rem;
    text-align: center;
}

.stat-card .value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .label {
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

.stat-card.city-card {
    border-color: var(--card-border);
}

.stat-card.city-card .value {
    color: var(--text);
    direction: rtl;
}

.stat-card.iran-card {
    border-color: var(--iran);
}

.stat-card.iran-card .value {
    color: var(--iran);
}

.stat-card.iran-card .label {
    color: var(--iran);
}

.stat-card.hez-card {
    border-color: var(--hez);
}

.stat-card.hez-card .value {
    color: var(--hez);
}

.stat-card.hez-card .label {
    color: var(--hez);
}

/* ===== TIMELINE ===== */

/* Origin dot & tag colors */
.dot-iran {
    background: var(--iran) !important;
    box-shadow: 0 0 8px var(--iran-glow) !important;
}

.dot-hezbollah {
    background: var(--hez) !important;
    box-shadow: 0 0 8px var(--hez-glow) !important;
}

.tags-row { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.1rem; }
.origin-tag { font-size: 0.65rem; font-weight: 600; }
.origin-tag.iran { color: var(--iran); }
.origin-tag.hezbollah { color: var(--hez); }
.threat-tag { font-size: 0.6rem; font-weight: 600; }
.threat-tag.missile { color: var(--missiles); }
.threat-tag.drone { color: var(--drones); }

.timeline-container {
    max-width: 600px;
    margin: 0.5rem auto 2rem;
    padding: 0 1.5rem 3rem;
    position: relative;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #1a1a2a;
    transform: translateX(-50%);
}

.timeline-empty {
    text-align: center;
    color: #666;
    padding: 2rem 1rem;
    font-size: 1rem;
}

.alert-dot {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.alert-dot .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    box-shadow: 0 0 8px rgba(255, 59, 59, 0.5);
    transition: transform 0.15s;
}

.alert-dot:hover .dot { transform: translateX(-50%) scale(1.4); }

.alert-dot .info {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
}

.alert-dot .info .alert-date {
    font-size: 0.65rem;
    color: var(--muted);
    font-weight: 600;
}

.alert-dot .info .time {
    color: #ff6b6b;
    font-weight: 600;
    font-size: 0.85rem;
}

.alert-dot .info .city-name {
    color: #aaa;
    direction: rtl;
    font-size: 0.8rem;
}

.alert-dot.side-right .info { margin-right: auto; margin-left: 55%; }
.alert-dot.side-left .info { margin-left: auto; margin-right: 55%; text-align: right; }

.date-separator {
    position: relative;
    text-align: center;
    padding: 1rem 0 0.4rem;
    z-index: 3;
}

.date-separator span {
    background: var(--accent);
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    position: relative;
    z-index: 3;
}

.hour-marker {
    position: relative;
    text-align: center;
    color: #444;
    font-size: 0.7rem;
    padding: 0.6rem 0 0.2rem;
    font-weight: 600;
}

.hour-marker::before {
    content: '';
    position: absolute;
    left: 30%;
    right: 30%;
    top: 50%;
    height: 1px;
    background: #1a1a2a;
}

.hour-marker span {
    background: var(--bg);
    padding: 0 0.5rem;
    position: relative;
    z-index: 1;
}

/* ===== TOP CITIES BAR CHART ===== */

.top-cities {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.top-cities h3 {
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 0.6rem;
    text-align: center;
}

.city-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.city-bar:hover { background: var(--card-bg); }

.city-bar .name {
    min-width: 100px;
    text-align: right;
    direction: rtl;
    font-size: 0.85rem;
}

.city-bar .bar-container {
    flex: 1;
    display: flex;
    height: 18px;
    border-radius: 4px;
    overflow: hidden;
    transition: width 0.4s ease;
}

.city-bar .bar-iran {
    height: 100%;
    background: var(--iran);
    transition: width 0.4s ease;
}

.city-bar .bar-hezbollah {
    height: 100%;
    background: var(--hez);
    transition: width 0.4s ease;
}

.city-bar .bar {
    height: 18px;
    background: linear-gradient(90deg, #cc2222, #ff3b3b);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.city-bar .count {
    font-size: 0.8rem;
    color: var(--muted);
    min-width: 28px;
}


.bar-pre-alert {
    height: 100%;
    background: #ff8c00;
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* ===== GRAPH ===== */

.graph-section {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.graph-controls {
    min-height: 1.6rem;
}

.graph-toggle-btn {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    border: 1px solid #333;
    background: var(--card-bg);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
}

.graph-toggle-btn:hover { border-color: #555; color: var(--text); }
.graph-toggle-btn.active { background: #333; border-color: #555; color: var(--text); }


.city-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.graph-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 2rem 0.5rem 0.5rem;
    margin-top: 0.3rem;
    margin-bottom: 1rem;
    position: relative;
}

.graph-chart {
    display: flex;
    direction: ltr;
    align-items: flex-end;
    gap: 2px;
    height: 160px;
    padding: 0 0.3rem;
}

.graph-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    min-width: 0;
}

.graph-bar .bar-stack {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 2px 2px 0 0;
    overflow: hidden;
}

.graph-bar .bar-iran {
    background: var(--iran);
    width: 100%;
    transition: height 0.4s ease, background 0.3s ease;
}

.graph-bar .bar-hez {
    background: var(--hez);
    width: 100%;
    transition: height 0.4s ease, background 0.3s ease;
}

.graph-bar .bar-false-alarm {
    background: #ff8c00;
    width: 100%;
    transition: height 0.4s ease;
}

.graph-bar .bar-label {
    font-size: 0.55rem;
    color: var(--muted);
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

.graph-bar .bar-count {
    font-size: 0.5rem;
    color: var(--muted);
    margin-bottom: 0.15rem;
    text-align: center;
}

.graph-legend {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--muted);
}

.graph-legend span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.graph-legend .dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
}

.graph-legend .dot.iran { background: var(--iran); }
.graph-legend .dot.hez { background: var(--hez); }

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.loading .spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #333;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
