/* =============================================================================
 *  File:        style.css
 *  Project:     QS360 built-in dashboard
 *  Author:      Chandan Kumar
 *  Created:     2026-07-15
 *  Description: Styling for the QS360 dashboard. A calm, dark NOC-style theme
 *               with clear status colours. Self-contained; no external fonts.
 * =============================================================================
 */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-border: #21262d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #4f9cf9;
  --up: #3fb950;
  --down: #f85149;
  --trouble: #d29922;
  --pending: #6e7681;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ---- top bar ------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  background: var(--accent);
  color: #04101f;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 14px;
}

.brand-name {
  font-size: 18px;
  font-weight: 600;
}

.brand-tag {
  color: var(--text-dim);
  font-size: 12px;
}

.summary {
  color: var(--text-dim);
  font-size: 13px;
}

.summary strong {
  color: var(--text);
}

/* ---- layout -------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-areas:
    "form     alerts"
    "form     list"
    "channels detail"
    "channels deliveries";
  gap: 18px;
  padding: 18px 22px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

.form-panel {
  grid-area: form;
}
.channels-panel {
  grid-area: channels;
}
.alerts-panel {
  grid-area: alerts;
}
.list-panel {
  grid-area: list;
}
.detail-panel {
  grid-area: detail;
}
.deliveries-panel {
  grid-area: deliveries;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "form"
      "alerts"
      "list"
      "detail"
      "channels"
      "deliveries";
  }
}

/* ---- panels -------------------------------------------------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

/* ---- form ---------------------------------------------------------------- */
form label {
  display: block;
  margin-bottom: 12px;
  color: var(--text-dim);
  font-size: 12px;
}

form .row {
  display: flex;
  gap: 12px;
}

form input {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

form input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  width: 100%;
  padding: 9px 14px;
  background: var(--accent);
  color: #04101f;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

/* Type-specific form fields are toggled with the hidden attribute; the block
   display rule above would otherwise keep them visible. */
form label[hidden],
form .row[hidden] {
  display: none;
}

/* The monitor type shown alongside a target in the monitor list. */
.type-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.form-error {
  color: var(--down);
  font-size: 12px;
  min-height: 16px;
  margin: 8px 0 0;
}

/* ---- monitor list -------------------------------------------------------- */
.monitors {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.monitor {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #0d1117;
  cursor: pointer;
}

.monitor:hover {
  border-color: var(--accent);
}

.monitor.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.up {
  background: var(--up);
}
.dot.down {
  background: var(--down);
}
.dot.trouble {
  background: var(--trouble);
}
.dot.pending {
  background: var(--pending);
}

.monitor-main {
  flex: 1;
  min-width: 0;
}

.monitor-name {
  font-weight: 600;
}

.monitor-url {
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.monitor-meta {
  text-align: right;
  font-size: 12px;
  color: var(--text-dim);
}

.badge {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
}
.badge.up {
  color: var(--up);
}
.badge.down {
  color: var(--down);
}
.badge.trouble {
  color: var(--trouble);
}
.badge.pending {
  color: var(--pending);
}

.delete-btn {
  width: auto;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  padding: 4px 8px;
  font-size: 12px;
}

.delete-btn:hover {
  color: var(--down);
  border-color: var(--down);
  filter: none;
}

.empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 0;
}

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

.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--down);
  border-left-width: 4px;
  border-radius: 8px;
  background: rgba(248, 81, 73, 0.08);
}

.alert-item.acknowledged {
  border-color: #d29922;
  background: rgba(210, 153, 34, 0.08);
}

.alert-main {
  flex: 1;
  min-width: 0;
}

.alert-message {
  font-weight: 600;
}

.alert-meta {
  color: var(--text-dim);
  font-size: 12px;
}

.ack-btn {
  width: auto;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
  padding: 5px 10px;
  font-size: 12px;
}

.ack-btn:hover {
  border-color: var(--accent);
  filter: none;
}

.alert-ok {
  color: var(--up);
  font-size: 13px;
  padding: 8px 0;
}

/* ---- sign-in gate -------------------------------------------------------- */
.login-gate {
  display: flex;
  justify-content: center;
  padding: 64px 16px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.login-card h2 {
  margin: 0 0 18px;
  font-size: 16px;
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* A quiet dot: filled when updates are arriving live, hollow while polling. */
.live-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--text-dim);
  flex: none;
}

.live-indicator.on {
  background: var(--up);
  border-color: var(--up);
}

.session-user {
  color: var(--text-dim);
  font-size: 12px;
}

.link-button {
  width: auto;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}

.link-button:hover {
  color: var(--text);
  filter: none;
}

/* Forms hidden from a viewer, and the gate itself, must actually disappear —
   the block display rules above would otherwise override the attribute. */
form[hidden],
.login-gate[hidden],
.session[hidden],
main.layout[hidden] {
  display: none;
}

/* ---- single sign-on ------------------------------------------------------ */
.sso[hidden] {
  display: none;
}

.sso-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sso-divider::before,
.sso-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--panel-border);
}

.sso-button {
  display: block;
  padding: 9px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.sso-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- overview strip ------------------------------------------------------ */
.overview {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tile {
  min-width: 92px;
  padding: 6px 12px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-left-width: 3px;
  border-radius: 6px;
}

.tile.up { border-left-color: var(--up); }
.tile.down { border-left-color: var(--down); }
.tile.trouble { border-left-color: var(--trouble); }

.tile-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tile-label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- groups -------------------------------------------------------------- */
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-form input { flex: 1; margin-top: 0; }
.inline-form button { width: auto; padding: 8px 14px; }

.groups {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.group-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.group-main { flex: 1; min-width: 0; }
.group-name { font-size: 13px; font-weight: 600; }
.group-meta { color: var(--text-dim); font-size: 11px; }

/* ---- status pages -------------------------------------------------------- */
.status-pages-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.status-page-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.status-page-main { flex: 1; min-width: 0; }
.status-page-title { font-size: 13px; font-weight: 600; }

.status-page-link {
  color: var(--accent);
  font-size: 11px;
  text-decoration: none;
}

.status-page-link:hover { text-decoration: underline; }

/* ---- hosts --------------------------------------------------------------- */
.hosts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.host {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.host-main {
  flex: 1;
  min-width: 0;
}

.host-name {
  font-size: 14px;
  font-weight: 600;
}

.host-meta {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 12px;
}

.host-metrics {
  font-variant-numeric: tabular-nums;
}

/* ---- thresholds ---------------------------------------------------------- */
.thresholds-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.threshold-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.threshold-rule {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.threshold-meta {
  color: var(--text-dim);
  font-size: 11px;
}

.empty-hint {
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 0;
}

.empty-hint code {
  padding: 1px 5px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
}

/* ---- channels ------------------------------------------------------------ */
form select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  background: #0d1117;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.channels-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: #0d1117;
  font-size: 13px;
}

.channel-item .channel-type {
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
}

.channel-item .channel-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- deliveries ---------------------------------------------------------- */
.deliveries {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.delivery-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-left-width: 3px;
  border-radius: 6px;
  background: #0d1117;
  font-size: 13px;
}

.delivery-item.delivered {
  border-left-color: var(--up);
}
.delivery-item.failed {
  border-left-color: var(--down);
}

.delivery-main {
  flex: 1;
  min-width: 0;
}

.delivery-meta {
  color: var(--text-dim);
  font-size: 12px;
}

.delivery-status {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}
.delivery-status.delivered {
  color: var(--up);
}
.delivery-status.failed {
  color: var(--down);
}

/* ---- detail / chart ------------------------------------------------------ */
.detail-sub {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0 0 12px;
}

.chart {
  width: 100%;
  height: 240px;
  display: block;
}
