/* ==========================================================================
   Website Monitor — Stylesheet
   Neutral gray-scale base UI. Google palette used ONLY as accents:
   status colors, buttons, links, active states, chart lines.
   ========================================================================== */

:root {
  /* ---- Neutral base (light mode) ---- */
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-alt: #f1f2f4;
  --border: #e1e3e6;
  --text: #202124;
  --text-muted: #5f6368;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);

  /* ---- Google accent palette (used sparingly) ---- */
  --accent-blue: #4285f4;
  --accent-blue-dark: #1a56d6;
  --accent-red: #ea4335;
  --accent-yellow: #fbbc05;
  --accent-green: #34a853;

  /* Semantic mapping */
  --status-up: var(--accent-green);
  --status-down: var(--accent-red);
  --status-warning: var(--accent-yellow);
  --status-pending: var(--text-muted);
  --link: var(--accent-blue);
  --focus-ring: var(--accent-blue);

  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #17181a;
  --surface: #212226;
  --surface-alt: #26282c;
  --border: #34363a;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.35);

  /* Slightly brighter accents for legibility on dark surfaces */
  --accent-blue: #669df6;
  --accent-red: #f28b82;
  --accent-yellow: #fdd663;
  --accent-green: #81c995;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

h1, h2, h3 { margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }

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

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-brand {
  font-size: 17px;
  font-weight: 700;
  padding: 8px 10px 20px;
  color: var(--text);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

.nav-link:hover { background: var(--surface-alt); text-decoration: none; color: var(--text); }

.nav-link.active {
  background: color-mix(in srgb, var(--accent-blue) 12%, transparent);
  color: var(--accent-blue-dark, var(--accent-blue));
}

[data-theme="dark"] .nav-link.active { color: var(--accent-blue); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.main {
  padding: 24px 28px 48px;
  max-width: 1200px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar h1 { font-size: 22px; }
.topbar p { margin: 0; color: var(--text-muted); font-size: 14px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------------------- */
/* Theme toggle                                                            */
/* ---------------------------------------------------------------------- */

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.theme-toggle:hover { background: var(--surface-alt); }
.theme-toggle:active { transform: scale(0.94); }

.login-theme-toggle { position: fixed; top: 20px; right: 20px; }

/* ---------------------------------------------------------------------- */
/* Cards / stat grid                                                       */
/* ---------------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.stat-card.accent-green .stat-value { color: var(--status-up); }
.stat-card.accent-red .stat-value { color: var(--status-down); }
.stat-card.accent-yellow .stat-value { color: var(--status-warning); }
.stat-card.accent-blue .stat-value { color: var(--accent-blue); }

/* ---------------------------------------------------------------------- */
/* Site list                                                               */
/* ---------------------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header h2 { font-size: 15px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.site-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.site-table th, .site-table td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.site-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
.site-table tbody tr:last-child td { border-bottom: none; }
.site-table tbody tr:hover { background: var(--surface-alt); }
.site-table tbody tr { cursor: pointer; }

.site-name { font-weight: 600; }
.site-url { color: var(--text-muted); font-size: 12.5px; }

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.status-dot.up { background: var(--status-up); }
.status-dot.down { background: var(--status-down); box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-down) 20%, transparent); }
.status-dot.warning { background: var(--status-warning); }
.status-dot.pending { background: var(--status-pending); }

.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.status-badge.up { color: var(--status-up); background: color-mix(in srgb, var(--status-up) 14%, transparent); }
.status-badge.down { color: var(--status-down); background: color-mix(in srgb, var(--status-down) 14%, transparent); }
.status-badge.warning { color: var(--status-warning); background: color-mix(in srgb, var(--status-warning) 18%, transparent); }
.status-badge.pending { color: var(--text-muted); background: var(--surface-alt); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------- */
/* Buttons + forms                                                         */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: var(--accent-blue-dark, #3367d6); }

.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-alt); }

.btn-danger { background: transparent; border-color: var(--accent-red); color: var(--accent-red); }
.btn-danger:hover { background: color-mix(in srgb, var(--accent-red) 10%, transparent); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13.5px; }
.field span { font-weight: 600; color: var(--text-muted); }

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}

.field input:focus, .field select:focus { border-color: var(--accent-blue); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { width: 38px; height: 20px; accent-color: var(--accent-blue); }

.search-input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  min-width: 200px;
}

.select-filter {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
}

/* ---------------------------------------------------------------------- */
/* Alerts                                                                  */
/* ---------------------------------------------------------------------- */

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

.alert-error { background: color-mix(in srgb, var(--accent-red) 12%, transparent); color: var(--accent-red); }
.alert-success { background: color-mix(in srgb, var(--accent-green) 12%, transparent); color: var(--status-up); }

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 3px solid var(--status-up); }
.toast.error { border-left: 3px solid var(--status-down); }

/* ---------------------------------------------------------------------- */
/* Modal                                                                   */
/* ---------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

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

/* ---------------------------------------------------------------------- */
/* Charts (vanilla SVG, no library)                                        */
/* ---------------------------------------------------------------------- */

.chart-wrap { padding: 16px 18px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--accent-blue); stroke-width: 2; }
.chart-area { fill: color-mix(in srgb, var(--accent-blue) 12%, transparent); stroke: none; }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-tick { fill: var(--text-muted); font-size: 10px; }

.timeline { display: flex; gap: 2px; padding: 16px 18px; flex-wrap: wrap; }
.timeline-bar { width: 6px; height: 26px; border-radius: 2px; background: var(--surface-alt); }
.timeline-bar.up { background: var(--status-up); }
.timeline-bar.down { background: var(--status-down); }
.timeline-bar.warning { background: var(--status-warning); }

/* ---------------------------------------------------------------------- */
/* Login page                                                              */
/* ---------------------------------------------------------------------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
}

.login-title { font-size: 20px; }
.login-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 4px 0 22px; }

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .sidebar-brand { padding: 0 14px 0 0; }
  .sidebar-footer { display: none; }
  .main { padding: 18px 16px 40px; }
  .site-table th:nth-child(4), .site-table td:nth-child(4) { display: none; }
  .field-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
