/* LibreLox – base/main stylesheet (shared by all pages). */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --text: #1f2937;
  --text-700: #374151;
  --text-600: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --orange: #ea580c;
  --orange-dark: #c2410c;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --red: #dc2626;
  --green: #15803d;

  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3 { line-height: 1.25; }
p { margin-top: 0; }

/* ---------- Layout ---------- */

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

.sidebar {
  flex-shrink: 0;
  width: 33.3333%;
  max-width: 24rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}
.sidebar-content { padding: 1rem; }

.main { flex: 1; min-width: 0; overflow-y: auto; }

.topbar { background: var(--surface); box-shadow: var(--shadow-sm); }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
}
.page {
  width: 100%;
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.logo img { width: 2rem; height: 2rem; }
.logo h1 { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--orange); }

/* ---------- Panels / sections ---------- */

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack dl, .stack p, .stack ul { margin-top: 0; margin-bottom: 0; }

.card-title { margin: 0 0 1rem; font-size: 1.25rem; font-weight: 600; }
.stack .card-title { margin-bottom: 0; }
.page-title { margin: 0; font-size: 1.5rem; font-weight: 600; }
.subtitle { margin: 0 0 0.5rem; font-size: 1.125rem; font-weight: 600; }
.section-title { margin: 0 0 0.25rem; font-weight: 600; }
.section { margin-bottom: 1rem; }
.divider { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-light); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border: none;
  border-radius: 0.375rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.btn-gray { background: #e5e7eb; color: var(--text-700); }
.btn-gray:hover { background: #d1d5db; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-dark); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dark); }

/* Toggle button created dynamically in map_detail.ts */
.map-toggle-btn {
  width: 120px;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 1rem; }
.field-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.hint { font-size: 0.875rem; color: var(--text-600); }
.hint-muted { font-size: 0.75rem; color: var(--text-muted); }
.hint-error { color: var(--red); font-weight: 500; }

input[type="text"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: -1px;
}
input[type="range"] { width: 100%; }

.debug-box {
  padding: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-700);
  background: var(--surface-soft);
  border-radius: 0.375rem;
}

/* ---------- Tables ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 0.5rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-700);
  background: #e5e7eb;
  white-space: nowrap;
}
.table td {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-light);
}
.table tbody tr.row { cursor: pointer; }
.table tbody tr.row:hover { background: var(--surface-soft); }

.thumb {
  display: block;
  width: 5rem;
  height: 3.75rem;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: var(--shadow-sm);
}

/* ---------- Lists / links ---------- */

.list { display: flex; flex-direction: column; gap: 0.5rem; }
.list-item {
  padding: 0.5rem;
  background: var(--surface-soft);
  border: 1px solid var(--border-light);
  border-radius: 0.375rem;
}
.link { color: var(--blue); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- Maps ---------- */

.map-full { height: 100vh; }

/* ---------- Text helpers ---------- */

.strong { font-weight: 600; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.75rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- Toolbars / status ---------- */

.toolbar { display: flex; align-items: center; gap: 0.5rem; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; }
.status-ok { font-size: 0.75rem; color: var(--green); }
.status-error { font-size: 0.75rem; color: var(--red); }

/* ---------- Errors ---------- */

.error-box {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--red);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.375rem;
}

/* ---------- Native HTML popover (used instead of JS modals) ---------- */

[popover] {
  margin: auto;
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  max-width: calc(100vw - 2rem);
}
[popover]::backdrop { background-color: rgb(0 0 0 / 0.4); }
