* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  background: #111;
  color: #eee;
}

.layout {
  display: flex;
  flex-direction: row;
  height: 100vh;
}

.left-panel {
  flex: 2 1 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 200px;
}

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

.right-panel {
  flex: 1 1 0;
  min-width: 200px;
  overflow-y: auto;
  padding: 16px 16px 0 16px;
  background: #1a1a1a;
  border-left: 1px solid #2d2d2d;
  display: flex;
  flex-direction: column;
}

h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
}

h2 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

#statusLine {
  margin: 0 0 12px 0;
  color: #bdbdbd;
}

.card {
  background: #242424;
  border: 1px solid #343434;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.location-row {
  display: flex;
  gap: 8px;
}


.toggle-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #ddd;
}

.toggle-item input {
  cursor: pointer;
}

#locationInput {
  flex: 1;
  padding: 8px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #121212;
  color: #fff;
}

#addLocationBtn {
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: #1b7fff;
  color: #fff;
  cursor: pointer;
}

.actions-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#injectTestAlertsBtn,
#clearTestAlertsBtn {
  padding: 7px 10px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #121212;
  color: #fff;
  cursor: pointer;
}

#injectTestAlertsBtn {
  border-color: #1b7fff;
}

#clearTestAlertsBtn {
  border-color: #8858ff;
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

#toggleApiConsoleBtn {
  padding: 6px 10px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #121212;
  color: #fff;
  cursor: pointer;
}

.api-console-panel.hidden {
  display: none;
}

.api-console-output {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  background: #0e0e0e;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.35;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.tags {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #2f2f2f;
  border-radius: 999px;
  border: 1px solid #4c4c4c;
  font-size: 13px;
}

.tag.active-alert {
  border-color: #ff4b4b;
}

.tag.news-alert {
  border-color: #ff9800;
}

.tag.ended-alert {
  border-color: #23a55a;
}

.tag button {
  border: none;
  background: transparent;
  color: #ddd;
  cursor: pointer;
  font-size: 12px;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  border: 1px solid #464646;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}

.alert-item.red {
  border-left: 4px solid #ff3b30;
}

.alert-item.orange {
  border-left: 4px solid #ff9500;
}

.alert-item.green {
  border-left: 4px solid #30d158;
}

.alert-item--previewing {
  outline: 2px solid #1b7fff;
  background: #0d2040;
  box-shadow: 0 0 0 3px rgba(27, 127, 255, 0.35);
}

.history-preview-hint {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6000;
  background: rgba(27, 127, 255, 0.92);
  color: #fff;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.alert-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.meta {
  color: #bbbbbb;
  font-size: 12px;
}

.expand-btn {
  margin-top: 6px;
  padding: 5px 8px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #121212;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.full-cities {
  margin-top: 6px;
}

.warning-popup {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  background: #a50000;
  color: #fff;
  border: 2px solid #ff6b6b;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-weight: 700;
  max-width: min(90vw, 560px);
  text-align: center;
}

.alert-type-icon-wrapper {
  background: transparent !important;
  border: none !important;
}

.alert-type-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff;
}

.alert-type-icon svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: currentColor;
}

.panel-resizer {
  width: 8px;
  background: #2d2d2d;
  cursor: col-resize;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
  flex-shrink: 0;
}

.panel-resizer:hover,
.panel-resizer.dragging {
  background: #1b7fff;
}

.panel-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.gear-wrapper {
  position: relative;
}

.gear-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: #242424;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.gear-dropdown-btn {
  padding: 6px 10px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #1b1b1b;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  text-align: right;
}

.gear-dropdown-btn:hover {
  border-color: #1b7fff;
  background: #0d2040;
}

.panel-footer {
  padding: 8px 16px;
  font-size: 11px;
  color: #666;
  text-align: center;
  border-top: 1px solid #2d2d2d;
  background: #1a1a1a;
  flex-shrink: 0;
  margin-top: auto;
}

.panel-footer a {
  color: #1b7fff;
  text-decoration: none;
}

.panel-footer a:hover {
  text-decoration: underline;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-header h1 {
  margin: 0;
  flex: 1;
}

.ws-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #bdbdbd;
  padding: 4px 7px;
  border: 1px solid #3b3b3b;
  border-radius: 999px;
  background: #171717;
  white-space: nowrap;
}

.ws-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.ws-online {
  background: #23a55a;
}

.ws-offline {
  background: #ff3b30;
}

.settings-toggle-btn {
  padding: 6px 10px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #1b1b1b;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .layout {
    display: flex;
    flex-direction: column;
    grid-template-columns: unset;
    height: 100dvh;
    height: 100vh;
    overflow: hidden;
  }

  .right-panel {
    flex: 0 0 40%;
    max-height: 40%;
    min-height: 80px;
    overflow-y: auto;
    border-left: none;
    border-top: none;
    border-bottom: 2px solid #2d2d2d;
    padding: 10px 12px 0 12px;
    -webkit-overflow-scrolling: touch;
    order: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }

  .panel-footer {
    padding: 6px 12px;
    font-size: 10px;
  }

  /* On mobile the resizer becomes a horizontal drag handle */
  .panel-resizer {
    width: 100%;
    height: 8px;
    cursor: row-resize;
    border-top: none;
    border-bottom: none;
    order: 1;
    flex-shrink: 0;
  }

  .panel-resizer::after {
    width: 40px;
    height: 2px;
  }

  .left-panel {
    flex: 1 1 0;
    min-height: 80px;
    order: 2;
    overflow: hidden;
  }

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

  .right-panel h1 {
    font-size: 16px;
    margin-bottom: 0;
  }

  .ws-status-indicator {
    font-size: 10px;
    padding: 3px 6px;
  }

  #statusLine {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .card {
    padding: 8px 10px;
    margin-bottom: 8px;
  }

  .card h2 {
    font-size: 13px;
  }

  /* Settings card hidden by default on mobile; shown when toggled */
  .settings-card {
    display: none;
  }

  .settings-card.mobile-visible {
    display: block;
  }

  /* Hide the API console card on mobile */
  #apiConsoleCard {
    display: none !important;
  }

  .alert-item {
    padding: 6px 8px;
  }

  .meta {
    font-size: 11px;
  }

  /* Gear dropdown opens upward on mobile to avoid going off screen */
  .gear-dropdown {
    top: calc(100% + 6px);
    bottom: auto;
    left: 0;
  }
}

/* ===== Pull-to-refresh indicator ===== */
#ptr-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -52px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  will-change: transform, opacity;
}

@media (min-width: 901px) {
  #ptr-indicator { display: none; }
}
