/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --border:   #2a2d3a;
  --text:     #e2e4ed;
  --muted:    #6b7080;
  --accent:   #6366f1;
  --green:    #22c55e;
  --yellow:   #f59e0b;
  --red:      #ef4444;
  --radius:   8px;
  --gap:      16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

/* ── Layout ───────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gap) 48px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.last-refresh {
  font-size: 12px;
  color: var(--muted);
}

section {
  margin-bottom: 32px;
}

section > h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Health Bar ───────────────────────────────────────────────────── */
#health-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.disk-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--border);
}
.disk-pill .disk-label { opacity: 0.7; }
.disk-ok       { background: #16342a; color: var(--green); }
.disk-warning  { background: #3b2e0a; color: var(--yellow); }
.disk-critical { background: #3b1212; color: var(--red); }

.health-chip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.chip-ok      { background: #16342a; color: var(--green); }
.chip-warning { background: #3b2e0a; color: var(--yellow); }
.chip-error   { background: #3b1212; color: var(--red); }

/* ── Card Grid ────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap);
}

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

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

.card-title {
  font-size: 14px;
  font-weight: 600;
}

.card-body {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.card-body p { margin-bottom: 4px; }
.card-body span { color: var(--text); }

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-green  { background: #16342a; color: var(--green); }
.badge-red    { background: #3b1212; color: var(--red); }
.badge-yellow { background: #3b2e0a; color: var(--yellow); }
.badge-grey   { background: var(--border); color: var(--muted); }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { opacity: 0.85; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost   { background: transparent; border-color: var(--border); color: var(--text); }
.btn-danger  { background: #3b1212; border-color: var(--red); color: var(--red); }
.btn-action  { background: var(--border); color: var(--text); }

/* ── NAS Volumes ──────────────────────────────────────────────────── */
#nas-volumes { display: flex; flex-direction: column; gap: 12px; }

.volume-row { }
.volume-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.volume-label  { font-weight: 600; font-size: 13px; }

.progress-bar  {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.bar-green  { background: var(--green); }
.bar-yellow { background: var(--yellow); }
.bar-red    { background: var(--red); }

.volume-meta { font-size: 12px; color: var(--muted); }

/* ── Photos Card ─────────────────────────────────────────────────── */
.photos-stats {
  display: flex;
  gap: 20px;
  align-items: baseline;
}
.photos-count-big {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}
.photos-sub { font-size: 13px; color: var(--muted); }

/* ── PC Control ──────────────────────────────────────────────────── */
.pc-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.pc-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.pc-panel h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}

#scripts-panel, #apps-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Tim Config Form ─────────────────────────────────────────────── */
#tim-config-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 480px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-row select,
.form-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
}

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

/* ── Projects Grid ───────────────────────────────────────────────── */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.project-card.project-missing { opacity: 0.5; }
.project-name { font-weight: 600; margin-bottom: 4px; }
.project-type { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.version-pill {
  display: inline-block;
  background: var(--border);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-family: monospace;
}

/* ── Logs ────────────────────────────────────────────────────────── */
.log-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.log-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--border);
  color: var(--muted);
  border: none;
}
.log-tab.active {
  background: var(--accent);
  color: #fff;
}

.log-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.log-body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  font-family: monospace;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

.alert-body { color: var(--yellow); }

/* ── Grouped Alerts ──────────────────────────────────────────────── */
.alert-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.alert-item:hover { opacity: 0.85; }

.alert-item.alert-critical { border-left-color: var(--red); }
.alert-item.alert-error    { border-left-color: var(--red); }
.alert-item.alert-warning  { border-left-color: var(--yellow); }
.alert-item.alert-healthy  { border-left-color: var(--green); }
.alert-item.alert-info     { border-left-color: var(--muted); }

.alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.alert-badge { flex-shrink: 0; }

.alert-type {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}

.alert-preview {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-details {
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-size: 11px;
  font-family: monospace;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  max-width: 320px;
  animation: slideIn 0.2s ease;
}
.toast-success { background: #16342a; color: var(--green); border: 1px solid var(--green); }
.toast-error   { background: #3b1212; color: var(--red);   border: 1px solid var(--red); }
.toast-info    { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Misc ────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.error { color: var(--red); }

@media (max-width: 600px) {
  .pc-panels { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
