@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;1,300&display=swap');

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1c2128;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #7d8590;
  --accent:    #58a6ff;
  --green:     #3fb950;
  --red:       #f85149;
  --amber:     #d29922;
  --purple:    #bc8cff;
  --tab-h:     42px;
}

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

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Login overlay ─────────────────────────────────────────────────────── */
#login-overlay {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#login-overlay.visible { display: flex; }
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  width: 320px;
}
.login-box h2 { font-size: 14px; color: var(--accent); margin-bottom: 6px; }
.login-box p  { font-size: 11px; color: var(--muted); margin-bottom: 20px; }
.login-box input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 8px 12px; color: var(--text);
  font-family: inherit; font-size: 13px; margin-bottom: 10px;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
#login-error { color: var(--red); font-size: 11px; margin-bottom: 8px; display: none; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
#shell { display: none; flex-direction: column; height: 100vh; }
#shell.visible { display: flex; }

/* ── Header ────────────────────────────────────────────────────────────── */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  height: var(--tab-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.logo { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.logo span { color: var(--muted); font-weight: 400; }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; margin-left: 8px; }
.tab {
  padding: 0 16px;
  height: var(--tab-h);
  display: flex; align-items: center;
  font-size: 12px; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.clock { font-size: 11px; color: var(--muted); }
.btn-refresh {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--muted); font-family: inherit; font-size: 11px;
  padding: 4px 10px; cursor: pointer; transition: all .15s;
}
.btn-refresh:hover { border-color: var(--accent); color: var(--accent); }

/* ── Content area ──────────────────────────────────────────────────────── */
.tab-content { display: none; flex: 1; overflow: auto; padding: 16px; }
.tab-content.active { display: flex; flex-direction: column; gap: 12px; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
}
.card-title {
  font-size: 10px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.card-title .host { color: var(--accent); text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ── Onglet 1 layout ───────────────────────────────────────────────────── */

#tab-machines.active {
  display: block;
  padding: 16px;
}

.t1-outer {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 12px;
  align-items: start;
  width: 100%;
}

.t1-left {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  /* align-items: stretch is the default — les cartes sur la même ligne
     s'étireront pour avoir la même hauteur */
}

.t1-jellyfin { grid-column: 1 / 3; }

.t1-vikunja {
  position: sticky; top: 0;
  max-height: calc(100vh - var(--tab-h) - 32px);
  display: flex; flex-direction: column; overflow: hidden;
}

/* ── Métriques ─────────────────────────────────────────────────────────── */
.metric { margin-bottom: 9px; }
.metric:last-child { margin-bottom: 0; }
.metric-row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.metric-label { font-size: 10px; color: var(--muted); }
.metric-value { font-size: 11px; font-weight: 500; }
.bar-wrap { height: 5px; background: var(--surface2); border-radius: 2px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; border-radius: 2px; transition: width .4s; background: var(--green); }
.bar-fill.warn   { background: var(--amber); }
.bar-fill.danger { background: var(--red); }
.bar-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ── Jellyfin sessions ─────────────────────────────────────────────────── */
.jf-stats { display: flex; gap: 20px; margin-bottom: 10px; }
.jf-stat .val { font-size: 22px; font-weight: 600; }
.jf-stat .lbl { font-size: 10px; color: var(--muted); }
.jf-sessions { display: flex; flex-direction: column; gap: 5px; }
.jf-session {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 4px; font-size: 11px;
}

/* ── Vikunja ───────────────────────────────────────────────────────────── */
.vk-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.vk-summary { font-size: 11px; color: var(--muted); margin-left: auto; }
.vk-select {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: inherit;
  font-size: 11px; padding: 4px 8px; flex: 1;
}

.vk-tasks {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.vk-task {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 8px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 11px; cursor: pointer; transition: border-color .15s;
}
.vk-task:hover { border-color: var(--accent); }
.vk-task.done { opacity: .4; }
.vk-task input[type=checkbox] { margin-top: 1px; flex-shrink: 0; accent-color: var(--accent); }
.vk-task-title { flex: 1; }
.vk-task-project { font-size: 10px; color: var(--muted); margin-top: 2px; }
.vk-task-due { font-size: 10px; color: var(--amber); }
.vk-empty { text-align: center; padding: 32px; color: var(--muted); font-size: 12px; }

/* ── Onglet 2 layout ───────────────────────────────────────────────────── */
.t2-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  align-items: start;
}
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.service-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  transition: border-color .15s; position: relative;
}
.service-card:hover { border-color: var(--accent); }
.service-card.no-link { cursor: default; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.dot.up      { background: var(--green); box-shadow: 0 0 5px var(--green); }
.dot.down    { background: var(--red);   box-shadow: 0 0 5px var(--red); }
.dot.pending { background: var(--amber); animation: pulse .8s infinite; }
.svc-name { font-size: 12px; font-weight: 500; }
.svc-host { font-size: 10px; color: var(--muted); }
.svc-badges { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.badge {
  font-size: 9px; padding: 1px 5px; border-radius: 8px;
  border: 1px solid; font-weight: 500;
}
.badge.public  { color: var(--green);  border-color: var(--green);  background: #3fb95012; }
.badge.private { color: var(--muted);  border-color: var(--border); background: transparent; }
.badge.update  { color: var(--amber);  border-color: var(--amber);  background: #d2992212; }

/* ── Scripts actions ───────────────────────────────────────────────────── */
.actions-col { display: flex; flex-direction: column; gap: 10px; }
.action-card { }
.action-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.action-status {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--muted);
}
.action-status.running { background: var(--amber); animation: pulse .6s infinite; }
.action-status.success { background: var(--green); box-shadow: 0 0 5px var(--green); }
.action-status.error   { background: var(--red);   box-shadow: 0 0 5px var(--red); }
.action-meta { font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.btn-action {
  width: 100%; padding: 7px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-family: inherit; font-size: 12px;
  cursor: pointer; transition: all .15s;
}
.btn-action:hover:not(:disabled) { border-color: var(--accent); background: #58a6ff10; }
.btn-action:disabled { opacity: .4; cursor: not-allowed; }

/* ── Onglet 3 logs ─────────────────────────────────────────────────────── */
.logs-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.logs-select {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: inherit;
  font-size: 12px; padding: 6px 10px; flex: 1;
}
.btn-load-logs {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: inherit;
  font-size: 12px; padding: 6px 14px; cursor: pointer; transition: all .15s;
}
.btn-load-logs:hover { border-color: var(--accent); }
.log-console {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 12px;
  height: calc(100vh - 160px);
  overflow-y: auto; font-size: 11px; line-height: 1.7;
  color: var(--muted);
}
.log-line { white-space: pre-wrap; word-break: break-all; }
.log-line.err { color: var(--red); }
.log-line.ok  { color: var(--green); }
.log-line.ts  { color: var(--muted); }

/* ── Offline banner ────────────────────────────────────────────────────── */
.offline { text-align: center; padding: 24px; color: var(--muted); font-size: 11px; }
.offline .ico { font-size: 20px; display: block; margin-bottom: 6px; }

/* ── Dot status générique ──────────────────────────────────────────────── */
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.status-dot.up   { background: var(--green); box-shadow: 0 0 5px var(--green); }
.status-dot.down { background: var(--red); }

/* ── Misc ──────────────────────────────────────────────────────────────── */
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:.25} }

@media (max-width: 900px) {
  .t1-outer { grid-template-columns: 1fr; }
  .t1-vikunja { position: static; max-height: none; }
  .t2-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .t1-left { grid-template-columns: 1fr; }
  .t1-jellyfin { grid-column: 1; }
}
