/* BeepBoopAlive Stylesheet - Yellow-accented Light & Dark Theme, Mobile-First */

:root {
  --bg: #f8f7f2;
  --bg-grid: rgba(202, 138, 4, 0.14);
  --surface: #ffffff;
  --surface-alt: #f3f1e8;
  --surface-hover: #fbf9f1;
  --border: #dfd9c8;
  --text: #1c1917;
  --text-muted: #57534e;
  --accent: #eab308;
  --accent-strong: #ca8a04;
  --accent-soft: rgba(234, 179, 8, 0.16);
  --accent-ink: #1c1917;
  --up: #16a34a;
  --up-bg: rgba(22, 163, 74, 0.14);
  --down: #dc2626;
  --down-bg: rgba(220, 38, 38, 0.14);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.15);
  --muted-badge: #78716c;
  --muted-bg: rgba(120, 113, 108, 0.14);
  --shadow: 0 6px 20px rgba(28, 25, 23, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #111215;
  --bg-grid: rgba(250, 204, 21, 0.12);
  --surface: #191b20;
  --surface-alt: #22252c;
  --surface-hover: #282c34;
  --border: #323640;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --accent: #facc15;
  --accent-strong: #eab308;
  --accent-soft: rgba(250, 204, 21, 0.15);
  --accent-ink: #111215;
  --up: #22c55e;
  --up-bg: rgba(34, 197, 94, 0.18);
  --down: #f87171;
  --down-bg: rgba(248, 113, 113, 0.18);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.18);
  --muted-badge: #a1a1aa;
  --muted-bg: rgba(161, 161, 170, 0.16);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.88em;
}

pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 50;
}

.navbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.12rem;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.brand-pill {
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hamburger {
  display: none;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
}

.nav-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.nav-link {
  color: var(--text);
  padding: 0.4rem 0.68rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease;
}

.nav-link:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

/* Main container */
.main-content {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

/* Cards & layout helpers */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.card-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.55rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.48rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--surface-hover);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent-strong);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-danger {
  background: var(--down-bg);
  color: var(--down);
  border-color: var(--down);
}

.btn-sm {
  padding: 0.28rem 0.58rem;
  font-size: 0.82rem;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.form-field label {
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="email"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.52rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.94rem;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  font-weight: 500;
  margin: 0.4rem 0;
}

.help-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Status badges & pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.badge-up {
  background: var(--up-bg);
  color: var(--up);
}

.badge-down {
  background: var(--down-bg);
  color: var(--down);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-muted {
  background: var(--muted-bg);
  color: var(--muted-badge);
}

.badge-yellow {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid var(--accent);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-up {
  background: var(--up);
  box-shadow: 0 0 8px var(--up);
}

.dot-down {
  background: var(--down);
  box-shadow: 0 0 8px var(--down);
}

.dot-unknown {
  background: var(--muted-badge);
}

.dot-overdue {
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
}

/* Flash alerts */
.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 500;
}

.flash-success {
  border-left: 4px solid var(--up);
  background: var(--up-bg);
}

.flash-error {
  border-left: 4px solid var(--down);
  background: var(--down-bg);
}

.flash-warning {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}

.flash-info {
  border-left: 4px solid var(--muted-badge);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

tr.row-highlight {
  background: var(--accent-soft);
}

/* Tooltips */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.74rem;
  font-weight: 800;
  cursor: help;
  flex-shrink: 0;
  user-select: none;
}

.tip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(280px, 75vw);
  padding: 0.5rem 0.68rem;
  border-radius: var(--radius-sm);
  background: #1c1917;
  color: #fafaf9;
  border: 1px solid var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 90;
  white-space: normal;
  text-align: left;
}

.tip:hover::after,
.tip:focus::after,
.tip.tip-open::after {
  opacity: 1;
}

/* Status Map & Region Islands */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.map-viewport {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-alt);
  background-image: radial-gradient(var(--bg-grid) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  min-height: 540px;
  position: relative;
}

.map-canvas {
  position: relative;
  min-width: 100%;
  min-height: 540px;
}

.island {
  position: absolute;
  background: var(--surface);
  border: 2px solid var(--border);
  border-top: 5px solid var(--accent);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.9rem;
  min-width: 260px;
  max-width: 900px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.island.editing {
  border-style: dashed;
  border-color: var(--accent-strong);
}

.island-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.island.editing .island-header {
  cursor: grab;
  user-select: none;
}

.island.editing .island-header:active {
  cursor: grabbing;
}

.island-title {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.island-desc {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.island-resize-handle {
  display: none;
  position: absolute;
  top: 12px;
  right: 0;
  bottom: 12px;
  width: 10px;
  cursor: ew-resize;
  border-right: 3px solid var(--accent);
  opacity: 0.6;
}

.island.editing .island-resize-handle {
  display: block;
}

.host-block {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  margin-top: 0.6rem;
}

.host-block-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.host-name {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.site-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.site-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

.site-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.site-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
}

.site-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.reorder-controls {
  display: none;
  gap: 0.2rem;
  align-items: center;
}

.island.editing .reorder-controls {
  display: inline-flex;
}

.qr-box {
  background: #ffffff;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent);
  display: inline-block;
}

.qr-box img {
  display: block;
  width: 196px;
  height: 196px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
}

/* Responsive mobile overrides */
@media (max-width: 860px) {
  .hamburger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
  }

  .nav-menu {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-link {
    width: 100%;
  }
}

@media (max-width: 767px) {
  .map-viewport {
    min-height: auto;
    overflow: visible;
    padding: 0.75rem;
  }

  .map-canvas {
    min-height: auto;
    height: auto !important;
    width: 100% !important;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
  }

  .island {
    position: static !important;
    width: 100% !important;
    min-width: 0;
  }

  .island-resize-handle {
    display: none !important;
  }
}
