/*
 * NaxoNet Backup Monitor — Dashboard Stylesheet
 * /assets/css/nbm-dashboard.css
 */

/* ── Variables ────────────────────────────────────────────────────────── */
:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --success:   #3fb950;
  --warning:   #d29922;
  --error:     #f85149;
  --unknown:   #6e7681;
  --none:      #21262d;
  --radius:    8px;
  --font:      'Cascadia Code','JetBrains Mono','Fira Code',monospace;
  --font-ui:   system-ui,-apple-system,sans-serif;
}

/* ── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.header h1 {
  font-size: 17px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Merienda One', cursive;
  letter-spacing: .04em;
  text-decoration: none;
  background: linear-gradient(90deg, #a0c4ff 0%, #58a6ff 50%, #a0c4ff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: header-shimmer 6s linear infinite;
}
.header h1:hover { opacity: .8; }
@keyframes header-shimmer {
  0%   { background-position: 0%   center; }
  100% { background-position: 200% center; }
}
.header-meta { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ── Layout ───────────────────────────────────────────────────────────── */
.container { max-width: 1900px; margin: 0 auto; padding: 20px 24px; }

/* ── Stats cards ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-card .val {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-card .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.s-success .val { color: var(--success); }
.s-error   .val { color: var(--error);   }
.s-warning .val { color: var(--warning); }
.s-neutral .val { color: var(--accent);  }

/* ── Navigation bar ───────────────────────────────────────────────────── */
.nav-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.nav-bar .nav-group { display: flex; align-items: center; gap: 4px; }
.nav-bar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 6px; }
.nav-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn.today-btn { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.nav-btn.today-btn:hover { opacity: .85; }
.nav-period { color: var(--text); font-size: 13px; font-weight: 600; padding: 0 8px; white-space: nowrap; }
.nav-anchor-badge {
  background: rgba(88,166,255,.15);
  color: var(--accent);
  border: 1px solid rgba(88,166,255,.3);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-family: var(--font);
}

/* ── Jump-to-date form ────────────────────────────────────────────────── */
.jump-form { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.jump-form label { color: var(--muted); font-size: 12px; }
.jump-form input[type=date] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
  color-scheme: dark;
}
.jump-form input[type=date]:focus { border-color: var(--accent); }
.jump-form button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* ── Filters ──────────────────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filters label { color: var(--muted); font-size: 12px; }
.filters select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  outline: none;
}
.filters select:focus { border-color: var(--accent); }
.filters button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-reset {
  background: transparent !important;
  color: var(--muted) !important;
  border: 1px solid var(--border) !important;
  font-weight: 400 !important;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
}

/* ── Legend ───────────────────────────────────────────────────────────── */
.legend { display: flex; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }

/* ── Section title ────────────────────────────────────────────────────── */
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Matrix table ─────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
}
table.matrix { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--font); }
table.matrix thead tr { background: var(--surface); position: sticky; top: 0; z-index: 2; }
table.matrix th {
  padding: 7px 5px;
  text-align: center;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
}
table.matrix th.col-info {
  text-align: left;
  padding-left: 12px;
  min-width: 210px;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 3;
}

/* Company row */
table.matrix tr.company-row td.co-toggle {
  background: #1c2128;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  border-top: 2px solid var(--accent);
  position: sticky;
  left: 0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  z-index: 2;
}
table.matrix tr.company-row td.co-toggle:hover { background: #222a35; }
.co-toggle-inner { display: flex; align-items: center; gap: 8px; padding: 6px 12px; }
.co-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: rgba(88,166,255,.15);
  color: var(--accent);
  font-size: 10px;
  flex-shrink: 0;
  transition: transform .2s;
}
tr.company-row.expanded .co-chevron { transform: rotate(90deg); }
.co-server-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 1px 7px;
}

/* Summary dot cells inside company-row */
table.matrix tr.company-row td.cell {
  width: 28px; min-width: 28px; max-width: 28px; height: 36px;
  text-align: center; vertical-align: middle; padding: 2px 2px 6px;
  background: #1c2128;
  border-top: 2px solid var(--accent);
  position: relative;
}
table.matrix tr.company-row td.cell.future { opacity: .35; }

/* Server rows hidden by default */
table.matrix tr.server-row { display: none; }
table.matrix tr.server-row.visible { display: table-row; }

/* Client rows */
table.matrix tr.client-row td.cl-toggle {
  background: #161f2e;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: #a5d6ff;
  border-top: 1px solid rgba(88,166,255,.2);
  position: sticky;
  left: 0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  z-index: 2;
}
table.matrix tr.client-row td.cl-toggle:hover { background: #1a2540; }
table.matrix tr.client-row td.cell {
  background: #161f2e;
  border-top: 1px solid rgba(88,166,255,.15);
  position: relative;
  padding: 2px 2px 6px;
}
.cl-toggle-inner { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 22px; }
.cl-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  background: rgba(88,166,255,.1);
  color: #a5d6ff;
  font-size: 9px;
  flex-shrink: 0;
  transition: transform .2s;
}
tr.client-row.cl-expanded .cl-chevron { transform: rotate(90deg); }

/* Server rows (leaf) */
table.matrix tr.srv-row { display: none; }
table.matrix tr.srv-row.visible { display: table-row; }
table.matrix tr.server-row td.col-server {
  padding: 5px 6px 5px 38px;
  color: var(--text);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--bg);
  z-index: 1;
}
table.matrix tr.server-row:hover td { background: #1a2033; }

/* Cell base */
table.matrix td.cell {
  width: 28px; min-width: 28px; max-width: 28px; height: 32px;
  text-align: center; vertical-align: middle; padding: 2px 2px 6px;
  cursor: default;
  position: relative;
}
table.matrix td.cell.future { opacity: .35; }

/* ── Status dots ──────────────────────────────────────────────────────── */
.dot { display: inline-block; width: 18px; height: 18px; border-radius: 4px; transition: transform .1s; }
td.cell:hover .dot { transform: scale(1.35); }
.dot-success { background: var(--success); }
.dot-error   { background: var(--error);   box-shadow: 0 0 5px var(--error); }
.dot-warning { background: var(--warning); }
.dot-unknown { background: var(--unknown); }
.dot-none    { background: var(--none);    border: 1px solid var(--border); }

/* ── Pending ring: shown on Company/Client cells when ─────────────────── */
/* at least one server has no email yet for that day                       */
.dot-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pending-ring {
  position: absolute;
  inset: -3px;
  border-radius: 6px;
  border: 2px dashed rgba(255, 200, 80, 0.7);
  animation: ring-pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ring-pulse {
  0%, 100% { opacity: .5; }
  50%       { opacity: 1;  }
}

/* ── Anomaly ring: solid orange ring on server cells with anomalies ────── */
.anomaly-ring {
  position: absolute;
  inset: -3px;
  border-radius: 6px;
  border: 2px solid rgba(255, 100, 50, 0.9);
  box-shadow: 0 0 6px rgba(255, 100, 50, 0.5);
  animation: anomaly-pulse 1.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes anomaly-pulse {
  0%, 100% { opacity: .6; box-shadow: 0 0 4px rgba(255,100,50,.4); }
  50%       { opacity: 1;  box-shadow: 0 0 10px rgba(255,100,50,.8); }
}

/* ── No-baseline dot: grey dot top-right when no baseline exists ────────── */
.no-baseline-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6e7681;
  border: 1px solid var(--bg);
  pointer-events: none;
}
.tooltip .tt-anomaly   { color: #ff6432; font-size: 11px; margin-top: 5px; }
.tooltip .tt-nobaseline{ color: var(--muted); font-size: 11px; margin-top: 5px; font-style: italic; }

/* Weekend / today / anchor column highlights */
th.weekend, td.weekend { background: rgba(255,255,255,.02); }
th.today-col  { color: var(--accent) !important;  border-bottom: 2px solid var(--accent)  !important; }
th.anchor-col { color: #f0c674       !important;  border-bottom: 2px solid #f0c674        !important; }

.month-chip {
  display: inline-block;
  font-size: 9px;
  background: rgba(88,166,255,.15);
  color: var(--accent);
  border-radius: 3px;
  padding: 1px 3px;
  margin-top: 2px;
}

/* ── Backup type pills ────────────────────────────────────────────────── */
.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: .02em;
}
.type-hourly  { background: rgba(139,148,158,.18); color: #8b949e; }
.type-daily   { background: rgba(88,166,255,.18);  color: #58a6ff; }
.type-weekly  { background: rgba(163,113,247,.18); color: #a371f7; }
.type-monthly { background: rgba(210,153,34,.18);  color: #d29922; }
.type-yearly  { background: rgba(63,185,80,.18);   color: #3fb950; }
.type-unknown { background: rgba(110,118,129,.12); color: #6e7681; }

/* ── Type indicator micro-dots ────────────────────────────────────────── */
.cell-types {
  display: flex;
  justify-content: center;
  gap: 1px;
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
}
.type-dot { width: 4px; height: 4px; border-radius: 50%; flex-shrink: 0; }
.type-dot-hourly  { background: #8b949e; }
.type-dot-daily   { background: #58a6ff; }
.type-dot-weekly  { background: #a371f7; }
.type-dot-monthly { background: #d29922; }
.type-dot-yearly  { background: #3fb950; }
.type-dot-unknown { background: #6e7681; }

/* ── Tooltip ──────────────────────────────────────────────────────────── */
.tooltip {
  display: none;
  position: fixed;
  z-index: 999;
  background: #1c2128;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  max-width: 340px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  /* pointer-events enabled so buttons inside are clickable */
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.tooltip .tt-header  { font-weight: 700; margin-bottom: 5px; color: var(--accent); }
.tooltip .tt-status  { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.tooltip .tt-error   { color: var(--error); font-size: 11px; margin-top: 6px; white-space: pre-wrap; max-height: 180px; overflow: auto; }
.tooltip .tt-pending { color: #ffc850; font-size: 11px; margin-top: 5px; }

/* ── Recent log table ─────────────────────────────────────────────────── */
table.logs { width: 100%; border-collapse: collapse; font-size: 12px; }
table.logs thead tr { background: var(--surface); }
table.logs th {
  padding: 9px 12px;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.logs td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-family: var(--font);
  font-size: 11px;
}
table.logs tr:hover td { background: #1a2033; }
.td-subject { color: var(--muted); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Badge ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-ui);
}
.badge-success { background: rgba(63,185,80,.15);   color: var(--success); }
.badge-error   { background: rgba(248,81,73,.15);   color: var(--error);   }
.badge-warning { background: rgba(210,153,34,.15);  color: var(--warning); }
.badge-unknown { background: rgba(110,118,129,.15); color: var(--unknown); }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.alert {
  background: rgba(248,81,73,.12);
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-family: var(--font);
  font-size: 13px;
}
.empty-state { text-align: center; padding: 48px; color: var(--muted); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 10px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
