/* ==============================
   Theme variables
   ============================== */

:root {
  --bg: #fafafa;
  --text: #111;
  --muted: #444;
  --panel: #ffffff;
  --border: #d0d5dd;
  --btn-bg: #ffffff;
  --btn-hover: #efefef;
  --incident-bg: #f5f5f5;
  --incident-hover: #ececec;
  --accent: #2b6;
  --overlay: rgba(0, 0, 0, 0.55);
}

body.dark {
  --bg: #0f1115;
  --text: #f1f3f5;
  --muted: #c7cbd1;
  --panel: #151922;
  --border: #3a4152;
  --btn-bg: #151922;
  --btn-hover: #1c2230;
  --incident-bg: #151922;
  --incident-hover: #1c2230;
  --accent: #4ee08a;
  --overlay: rgba(0, 0, 0, 0.70);
}

/* ==============================
   Global defaults
   ============================== */
.section-spacer {
  margin-top: 60px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  margin: 16px;
  background: var(--bg);
  color: var(--text);
}

#appView {
  max-width: 1100px;
  margin: 0 auto;
}

h2, h3 {
  margin-bottom: 6px;
}

p em {
  color: var(--muted);
}

textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

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

/* ==============================
   Topbar + theme toggle
   ============================== */
.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand h2 {
  margin: 0 0 4px 0;
}

.brand p {
  margin: 0 0 12px 0;
}

/* Admin collapse: keep the header row visible, hide the rest */
#adminPanel.admin-collapsed #adminPanelBody {
  display: none !important;
}

/* Brand logo */
.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-logo {
  max-width: 260px;   /* adjust to taste */
  height: auto;
}

.brand-tagline {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.theme-label {
  font-size: 13px;
  color: var(--muted);
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: 0.2s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: var(--panel);
  border-radius: 999px;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* ==============================
   Incident Type Buttons
   ============================== */

.incident-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0 6px 0;
}

.incident-btn {
  padding: 12px 10px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--incident-bg);
  color: var(--text);
}

.incident-btn:hover {
  background: var(--incident-hover);
}

.incident-btn.selected {
  outline: 3px solid var(--accent);
  border-color: var(--accent);
}

/* ==============================
   Action buttons
   ============================== */

.actions button,
#finalizeBtn {
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--btn-bg);
  color: var(--text);
}

.actions button:hover,
#finalizeBtn:hover {
  background: var(--btn-hover);
}

.actions button:disabled,
#finalizeBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==============================
   App disabled until disclaimer acknowledged
   ============================== */

.app-disabled {
  pointer-events: none;
  opacity: 0.4;
  filter: grayscale(40%);
}

.incident-selected {
  margin-bottom: 12px;
  font-size: 14px;
}

/* ==============================
   Splash / Disclaimer Modal
   ============================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
  z-index: 9999;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: 16px 16px 12px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

.modal h3 {
  margin: 0 0 10px 0;
}

.modal p {
  margin: 0 0 10px 0;
  line-height: 1.35;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.modal button.primary {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--btn-bg);
  color: var(--text);
}

.modal button.primary:hover {
  background: var(--btn-hover);
}

.modal-footnote {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* ==============================
   Metrics panel
   ============================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.metrics-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
}

.metrics-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.metrics-big {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
}

.metrics-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.metrics-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.5;
}

.metrics-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.metrics-raw {
  white-space: pre-wrap;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  margin-top: 8px;
}
/* ==============================
   Login page
   ============================== */

.login-container {
  max-width: 360px;
  margin: 60px auto;
  padding: 24px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}

.login-logo {
  max-width: 260px;
  height: auto;
  margin-bottom: 10px;
}

.login-tagline {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--muted);
}

.login-container input {
  width: 100%;
  padding: 10px;
  font-size: 14px;
}

.login-container button {
  width: 100%;
  padding: 10px;
  font-size: 15px;
}

.login-error {
  margin-top: 10px;
  color: #b00;
  font-size: 13px;
}

/* ==============================
   Safe polish (no layout changes)
   ============================== */

/* Softer borders in light mode (optional) */
/* If you like your current border strength, skip this */
:root {
  --border: #d0d5dd;
}

/* Consistent form controls (inputs/selects) */
input, select, button {
  font: inherit;
}

input, select {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  padding: 10px;
}

/* Keep textareas exactly as you want (plain, non-distracting) */
textarea {
  background: var(--panel);
}

/* Button baseline (applies to all buttons, including admin) */
button {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.02s ease;
}

button:hover {
  background: var(--btn-hover);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Focus rings (keyboard users / accessibility) */
input:focus, select:focus, textarea:focus, button:focus {
  outline: none;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  box-shadow: 0 0 0 3px rgba(46, 224, 138, 0.25);
  border-color: var(--accent);
}

/* Tables look cleaner without changing structure */
table th, table td {
  vertical-align: top;
}

/* ==============================
   App feel upgrade (safe)
   ============================== */

/* Subtle page background - doesn't affect textboxes */
body {
  background: linear-gradient(180deg, var(--bg), var(--bg));
}

body.dark {
  background: radial-gradient(1200px 600px at 20% -10%, rgba(78, 224, 138, 0.08), transparent 60%),
              radial-gradient(900px 500px at 90% 0%, rgba(78, 224, 138, 0.05), transparent 55%),
              var(--bg);
}

/* Make the main app feel like a centered surface */
#appView {
  padding: 8px 2px;
}

/* Give sections a consistent "card" look WITHOUT changing layout */
#adminPanelBody > div,
#metricsPanel,
.login-container {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 14px 34px rgba(0,0,0,0.07);
}

/* Your admin sections already have inline borders — soften them visually */
#adminPanelBody > div[style*="border:1px solid"] {
  border-color: var(--border) !important;
}

/* Headings: add hierarchy without changing structure */
h2 {
  font-size: 22px;
  letter-spacing: -0.2px;
}

h3 {
  font-size: 16px;
  letter-spacing: -0.1px;
}

.brand-tagline,
.theme-label,
.metrics-title,
.modal-footnote {
  color: var(--muted);
}

/* Make hr less harsh */
hr {
  border: none;
  border-top: 1px solid var(--border);
  opacity: 0.6;
}

/* Buttons: more "app-like" while staying professional */
button {
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}

button:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

/* Keep textareas "paper" plain */
textarea {
  box-shadow: none;
}

/* Slightly improve table readability */
table th {
  font-size: 13px;
  color: var(--muted);
}

table td {
  font-size: 14px;
}

/* ==============================
   Card utility
   ============================== */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 14px 30px rgba(0,0,0,0.08);
}

/* Make cards feel a bit more finished */
.card {
  border-color: rgba(0,0,0,0.10);
}

body.dark .card {
  border-color: rgba(255,255,255,0.12);
}

/* Improve spacing between cards automatically */
.card + .card {
  margin-top: 14px;
}

/* Headings inside cards look more intentional */
.card h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

/* ==============================
   Modal form layout (stacked)
   ============================== */

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.form-stack label {
  font-size: 13px;
  color: var(--muted);
}

.form-stack input {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
