@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;600;700;900&display=swap');

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

:root {
  --bg:    #0a0a0a;
  --bar:   #111111;
  --border:#2a2a2a;
  --text:  #eeeeee;
  --muted: #888888;
}

html, body {
  height: 100%;
  font-family: 'Heebo', sans-serif;
  background: var(--bg);
  color: var(--text);
}

#home-view {
  display: none;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}
#home-view.active { display: flex; }

#map-home { flex: 1; height: 100%; z-index: 1; }

#logo-home {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  z-index: 1000;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 2px 16px rgba(0,0,0,0.6);
  object-fit: cover;
}

#sidebar {
  width: 360px;
  height: 100vh;
  background: var(--bar);
  display: flex;
  flex-direction: column;
  z-index: 500;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

#clock-bar {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
  background: #0d0d0d;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
#clock-date { font-size: 11px; color: var(--muted); font-weight: 300; letter-spacing: 0.5px; margin-bottom: 6px; }
#clock-time { font-size: 36px; font-weight: 700; color: var(--text); letter-spacing: 4px; font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 0 20px rgba(233,69,96,0.3); }

#sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'Heebo', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn.active {
  color: var(--text);
  border-bottom: 2px solid #e94560;
}
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; min-height: 0; }
.tab-content.active { display: flex; }

#tab-alerts { flex-direction: column; }

#alerts-container { flex: 1; overflow-y: auto; padding: 0; }
#alerts-container::-webkit-scrollbar { width: 4px; }
#alerts-container::-webkit-scrollbar-track { background: transparent; }
#alerts-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#no-alerts {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
}
#no-alerts .icon { font-size: 32px; opacity: 0.4; }

#sidebar-search {
  display: none;
  width: 100%;
  padding: 8px 12px;
  background: #0d0d0d;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: 'Heebo', sans-serif;
  font-size: 13px;
  box-sizing: border-box;
  flex-shrink: 0;
  outline: none;
}
#sidebar-search::placeholder { color: var(--muted); }
#sidebar-search:focus { background: #111; border-bottom-color: #444; }

.alert-block {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.alert-block-content { flex: 1; min-width: 0; }

.alert-cat-tab {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-radius: 4px 0 0 4px;
  margin: 6px 6px 6px 0;
}

.alert-header { display: flex; align-items: center; gap: 10px; padding: 14px 20px 10px; }

.alert-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 6px currentColor; animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:0.6; transform:scale(0.85); }
}

.alert-title-row { flex: 1; min-width: 0; }
.alert-type { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-count { font-size: 11px; color: var(--muted); font-weight: 300; margin-top: 1px; }
.alert-body { padding: 0 20px 14px; }
.alert-area-group { margin-bottom: 8px; }
.alert-area-name { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.alert-cities { display: flex; flex-wrap: wrap; gap: 4px; }

.city-chip {
  font-size: 12px; padding: 3px 8px; border-radius: 3px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
  white-space: nowrap; color: var(--text);
}
.city-chip:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); }
.city-chip.active { color: #000; font-weight: 600; border-color: transparent; }

.alert-timestamps { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.ts-row { font-size: 11px; color: var(--muted); direction: ltr; text-align: right; }
.ts-row span { color: rgba(255,255,255,0.45); margin-left: 6px; }
.ts-range { font-size: 11px; color: var(--muted); direction: ltr; text-align: right; margin-bottom: 4px; }
.ts-cities { display: flex; flex-direction: column; gap: 2px; }
.ts-city-row { font-size: 11px; color: var(--muted); }

.alert-instruction {
  margin-top: 10px; font-size: 12px; color: rgba(255,255,255,0.55);
  font-style: italic; border-top: 1px solid var(--border); padding-top: 8px;
}

.leaflet-tile-pane { filter: brightness(0.85) saturate(0.8); }
.leaflet-container { background: #1a1a1a; }

#tab-settings {
  overflow-y: auto;
  flex-direction: column;
}
#tab-settings::-webkit-scrollbar { width: 4px; }
#tab-settings::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#settings-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.settings-section { padding: 4px 0 12px; }

.settings-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.settings-section:last-child .settings-label {
  text-align: center;
}
.settings-sublabel {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.4;
}

#city-filter-inputs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }

.city-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.city-filter-input {
  flex: 1;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Heebo', sans-serif;
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.city-filter-input:focus { border-color: #555; }
.city-filter-input.valid { border-color: #22c55e; }

.city-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.city-remove-btn:hover { color: #e94560; }

#add-city-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-family: 'Heebo', sans-serif;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  width: 100%;
  transition: color 0.15s, border-color 0.15s;
  text-align: center;
}
#add-city-btn:hover { color: var(--text); border-color: #555; }
#add-city-btn:disabled { opacity: 0.35; cursor: default; }

.sound-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #2a2a2a;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  right: 3px; top: 3px;
  background: #888;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: #1a3a1a; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(-18px); background: #22c55e; }

#city-autocomplete-box {
  background: #161616;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 8px;
  overflow: hidden;
}
.autocomplete-item {
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: rgba(255,255,255,0.07); }
.autocomplete-item .ac-name { color: var(--text); }
.autocomplete-item .ac-area { color: var(--muted); font-size: 10px; margin-top: 1px; }

.settings-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0 16px;
}

.social-links {
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.15s;
}
.social-link:hover { opacity: 1; transform: scale(1.12); }
.desktop-only { display: block; }
@media (max-width: 700px) {
  #sidebar { width:100vw; height:45vh; position:fixed; bottom:0; left:0; right:0; border-right:none; border-top:1px solid var(--border); }
  #map-home { height:55vh; }
  #home-view { flex-direction:column; }
  #logo-home { top:10px; right:10px; width:44px; height:44px; }
  .desktop-only { display: none !important; }
}

#alert-view {
  display: none;
  padding: 0 20px 20px;
  min-height: 100vh;
  overflow: auto;
}
#alert-view.active { display: block; }

#alert-top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 16px;
  position: relative;
}

#alert-logo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  object-fit: cover;
  flex-shrink: 0;
}

#alert-top-bar h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 1.5em;
  font-weight: 700;
  color: #ff6b6b;
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
  pointer-events: none;
}

#alert-view h2 { text-align:center; color:#aaa; font-weight:normal; font-style:italic; }
#alert-view h3 { color:#e94560; margin-top:20px; margin-bottom:6px; font-size:1em; border-bottom:1px solid #e94560; padding-bottom:4px; }
#alert-view .area { margin-top:20px; }
#alert-view ul { display:grid; grid-template-columns:repeat(3,1fr); list-style:none; padding:0; gap:4px; }
#alert-view li { background:#16213e; padding:6px; border-right:3px solid #e94560; font-size:14px; color:#eee; }
#alert-view li.clickable { cursor:pointer; transition:background 0.15s; }
#alert-view li.clickable:hover { background:#1e2f5e; }
#alert-view li.active-city { background:#e94560; color:#fff; }

#alert-map { display:none; width:100%; height:400px; border-radius:8px; margin:20px 0; border:1px solid #e94560; }

#alert-search {
  display:none; width:100%; padding:10px; margin-bottom:16px;
  background:#16213e; border:1px solid #e94560; border-radius:6px;
  color:#eee; font-size:1em; box-sizing:border-box;
}

@media (max-width:600px) {
  #alert-view ul { grid-template-columns:repeat(2,1fr); }
  #alert-map { height:280px; }
}

#history-link {
  font-size: 11px;
  color: #e94560;
  cursor: pointer;
  margin-top: 6px;
  opacity: 0.8;
  transition: opacity 0.15s;
}
#history-link:hover { opacity: 1; }

#history-view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
#history-view.active { display: flex; }

#history-back {
  padding: 10px 20px;
  font-size: 12px;
  color: #e94560;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.15s;
}
#history-back:hover { background: rgba(233,69,96,0.07); }

#history-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
#history-container::-webkit-scrollbar { width: 4px; }
#history-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.history-block {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.history-cat-tab {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border-radius: 0 4px 4px 0;
  margin: 6px 0 6px 6px;
}
.history-block-content {
  flex: 1;
  padding: 14px 20px;
}
.history-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.history-type {
  font-size: 13px;
  font-weight: 700;
}
.history-time {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  direction: ltr;
  text-align: right;
}
.history-cities {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  line-height: 1.7;
}
.history-instruction {
  margin-top: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  font-style: italic;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
#history-loading {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 30px 20px;
}

#history-title {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#lang-switcher-home {
  border-right: 1px solid var(--border);
}
html[dir="ltr"] #lang-switcher-home {
  border-right: none;
  border-left: 1px solid var(--border);
}

.lang-switcher-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.lang-globe-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  padding: 0 12px;
  height: 100%;
  min-height: 38px;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lang-globe-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

.lang-dropdown {
  position: fixed;
  background: #161616;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  min-width: 120px;
  z-index: 99999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.lang-option {
  display: block;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  font-family: 'Heebo', sans-serif;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  text-align: center;
}
.lang-option:last-child { border-bottom: none; }
.lang-option:hover { background: rgba(255,255,255,0.07); }

#lang-switcher-alert {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
#lang-switcher-alert .lang-globe-btn {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  min-height: auto;
}

html[dir="ltr"] #sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}
html[dir="ltr"] #home-view {
  flex-direction: row-reverse;
}
html[dir="ltr"] #logo-home {
  left: auto;
  right: 16px;
}
html[dir="ltr"] #alert-top-bar {
  flex-direction: row;
}
html[dir="ltr"] .alert-cat-tab {
  border-radius: 0 4px 4px 0;
  margin: 6px 0 6px 6px;
}
html[dir="ltr"] .history-cat-tab {
  border-radius: 4px 0 0 4px;
  margin: 6px 6px 6px 0;
}
html[dir="ltr"] .sound-toggle-row {
  flex-direction: row-reverse;
}
.sound-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.sound-select {
  flex: 1;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: 'Heebo', sans-serif;
  font-size: 12px;
  padding: 6px 8px;
  outline: none;
}
.sound-preview-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 6px 12px;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sound-preview-btn:hover { border-color: #e94560; color: #e94560; }
