@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Crimson+Text:wght@400;600&display=swap');

:root {
  --bg: #111118;
  --surface: #1a1a28;
  --surface2: #222236;
  --border: #2a2a3a;
  --text: #c8c4b8;
  --muted: #6b6b88;
  --accent: #5a54cc;
  --ember: #d05030;
  --flame: #e8804a;
  --ok: #4caf50;
  --warn: #ffd166;
  --danger: #d05030;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Crimson Text', Georgia, serif;
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
}

/* ── LOGIN ───────────────────────────── */
#login-screen {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 100;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 1rem;
}
#login-screen.visible { display: flex; }

.login-title {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ember);
  letter-spacing: 0.1em;
}
.login-sub {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
#login-form { display: flex; flex-direction: column; gap: 0.75rem; width: min(320px, 85vw); }
#login-pass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.7rem 1rem;
  text-align: center;
  font-family: 'Courier New', monospace;
}
#login-pass:focus { outline: none; border-color: var(--accent); }
.login-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.7rem;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  cursor: pointer;
  letter-spacing: 0.05em;
}
.login-btn:hover { opacity: 0.9; }
#login-error { color: var(--danger); font-size: 0.85rem; text-align: center; min-height: 1.2em; }

/* ── DASHBOARD ──────────────────────── */
#dashboard { display: none; height: 100vh; overflow: hidden; }
#dashboard.visible { display: flex; flex-direction: column; }

.dash-header {
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  flex-shrink: 0;
}
.dash-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ember);
  letter-spacing: 0.08em;
}
.dash-title span { color: var(--muted); font-weight: 400; font-size: 0.75rem; letter-spacing: 0.15em; }

/* ── 3-COLUMN LAYOUT ─────────────────── */
.grid {
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 1px;
  background: var(--border);
  flex: 1;
  overflow: hidden;
}

.col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--border);
  gap: 1px;
}

.col-center {
  background: var(--bg);
}

.module {
  background: var(--bg);
  padding: 0.6rem;
  overflow: hidden;
  flex-shrink: 0;
}

/* Left column: stats compact, services/mail share space */
.col-left .module:nth-child(1) { flex-shrink: 0; }          /* stats - natural height */
.col-left .module:nth-child(2) { flex: 1; overflow: auto; }  /* services - fill */
.col-left .module:nth-child(3) { flex-shrink: 0; }          /* mail - natural height */

/* Center: terminal fills everything */
.col-center .module { flex: 1; padding: 0.3rem; }

/* Right column: containers/tmux compact, dns/files in accordions */
.col-right .module:nth-child(1) { flex-shrink: 0; }          /* containers */
.col-right .module:nth-child(2) { flex-shrink: 0; }          /* tmux */
.col-right .module:nth-child(3) { flex: 1; overflow: auto; } /* dns */
.col-right .module:nth-child(4) { flex-shrink: 0; }          /* files */

/* ── MODULE HEADERS ───────────────────── */
.mod-header {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding-bottom: 0.4rem;
  margin-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem;
  cursor: default;
}

/* Accordion support */
.mod-header.collapsible { cursor: pointer; user-select: none; }
.mod-header.collapsible::before { content: '\25BE'; font-size: 0.7rem; transition: transform 0.2s; }
.mod-header.collapsed::before { transform: rotate(-90deg); }
.mod-body { transition: max-height 0.3s ease; overflow: hidden; }
.mod-body.collapsed { max-height: 0 !important; padding: 0; }

/* ── STATS ──────────────────────────── */
.stats-grid { display: flex; flex-direction: column; gap: 0.3rem; }
.stat-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; }
.stat-label { width: 42px; color: var(--muted); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.03em; flex-shrink: 0; }
.stat-bar { flex: 1; height: 5px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.stat-fill { height: 100%; background: var(--ok); border-radius: 3px; transition: width 0.5s, background 0.3s; }
.stat-fill.mid { background: var(--warn); }
.stat-fill.warn { background: var(--danger); }
.stat-val { font-family: 'Courier New', monospace; font-size: 0.65rem; color: var(--text); min-width: 55px; text-align: right; }

/* ── SERVICES ───────────────────────── */
.svc-list { display: flex; flex-direction: column; gap: 0.4rem; }
.svc-cat { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.15rem; }
.svc-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; padding: 0.1rem 0; }
.svc-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.svc-dot.up { background: var(--ok); box-shadow: 0 0 4px rgba(76,175,80,0.5); }
.svc-dot.down { background: var(--danger); box-shadow: 0 0 4px rgba(208,80,48,0.5); }
.svc-dot.unknown { background: var(--muted); }
.svc-name { flex: 1; }
.svc-latency { font-family: 'Courier New', monospace; font-size: 0.6rem; color: var(--muted); }

/* ── DNS ────────────────────────────── */
.dns-zone { margin-bottom: 0.6rem; }
.dns-zone-name { font-family: 'Cinzel', serif; font-size: 0.7rem; color: var(--flame); margin-bottom: 0.3rem; }
.dns-records { width: 100%; border-collapse: collapse; font-size: 0.7rem; }
.dns-records th { text-align: left; padding: 0.2rem 0.3rem; color: var(--muted); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); }
.dns-records td { padding: 0.2rem 0.3rem; border-bottom: 1px solid rgba(255,255,255,0.03); }
.dns-type { font-family: 'Courier New', monospace; color: var(--accent); font-size: 0.65rem; }
.dns-name { font-family: 'Courier New', monospace; }
.dns-val { font-family: 'Courier New', monospace; font-size: 0.65rem; color: var(--muted); word-break: break-all; }
.dns-proxied { font-size: 0.6rem; background: rgba(255,140,66,0.2); color: var(--flame); padding: 0.1rem 0.3rem; border-radius: 3px; }
.dns-direct { font-size: 0.6rem; color: var(--muted); }
.dns-prop { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.prop-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; padding: 0.15rem 0; }
.prop-resolver { width: 60px; color: var(--muted); font-size: 0.65rem; }
.prop-val { font-family: 'Courier New', monospace; font-size: 0.65rem; }

/* ── CONTAINERS ─────────────────────── */
.ctr-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; padding: 0.2rem 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.ctr-name { font-family: 'Courier New', monospace; color: var(--flame); min-width: 80px; font-size: 0.7rem; }
.ctr-image { font-size: 0.6rem; color: var(--muted); flex: 1; display: none; }
.ctr-status { font-size: 0.6rem; color: var(--muted); }
.ctr-actions { display: flex; gap: 0.2rem; }

/* ── TMUX ───────────────────────────── */
.tmux-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.4rem; border-radius: 4px; font-size: 0.78rem; }
.tmux-row:hover { background: var(--surface); }
.tmux-claude { border-left: 2px solid var(--accent); }
.tmux-name { font-family: 'Courier New', monospace; color: var(--flame); font-size: 0.75rem; }
.tmux-info { font-size: 0.65rem; color: var(--muted); flex: 1; }
.tmux-badge { font-size: 0.55rem; padding: 0.1rem 0.35rem; border-radius: 3px; background: var(--surface2); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tmux-ai { background: rgba(90,84,204,0.2); color: var(--accent); }
.tmux-type { font-size: 0.55rem; padding: 0.1rem 0.3rem; border-radius: 3px; background: var(--surface2); color: var(--muted); text-transform: uppercase; }
.tmux-spawn { margin-left: auto; }
.tmux-section-label { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 0.3rem 0 0.15rem; }

/* ── MAIL ───────────────────────────── */
.mail-row { display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0; font-size: 0.78rem; }
.mail-name { flex: 1; }
.mail-count { font-family: 'Courier New', monospace; font-size: 0.65rem; color: var(--accent); background: rgba(90,84,204,0.15); padding: 0.1rem 0.35rem; border-radius: 3px; }
.mail-time { font-size: 0.6rem; color: var(--muted); font-family: 'Courier New', monospace; }

/* ── TERMINAL ───────────────────────── */
#mod-terminal { padding: 0; display: flex; flex-direction: column; }
.term-tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.term-tabs::-webkit-scrollbar { display: none; }
.term-tab {
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  padding: 0.35rem 0.7rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.term-tab:hover { color: var(--text); }
.term-tab.active { color: var(--flame); border-bottom-color: var(--flame); }
.term-tab-claude { color: var(--accent); }
.term-tab-claude.active { color: var(--accent); border-bottom-color: var(--accent); }
#term-container { flex: 1; min-height: 0; padding: 0.2rem; }

/* ── FILES ──────────────────────────── */
.files-path { font-family: 'Courier New', monospace; font-size: 0.65rem; color: var(--flame); margin-left: auto; font-weight: 400; }
.files-list { max-height: 200px; overflow-y: auto; }
.file-row { display: flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.3rem; font-size: 0.75rem; cursor: pointer; border-radius: 3px; }
.file-row:hover { background: var(--surface); }
.file-icon { font-size: 0.7rem; width: 1rem; text-align: center; }
.file-name { flex: 1; font-family: 'Courier New', monospace; font-size: 0.7rem; }
.file-dir .file-name { color: var(--flame); }
.file-size { font-size: 0.6rem; color: var(--muted); font-family: 'Courier New', monospace; }
.files-preview { margin-top: 0.4rem; border-top: 1px solid var(--border); }
.preview-header { font-size: 0.65rem; color: var(--muted); padding: 0.3rem 0; display: flex; justify-content: space-between; align-items: center; }
.preview-code { font-family: 'Courier New', monospace; font-size: 0.65rem; background: var(--surface); border-radius: 4px; padding: 0.4rem; max-height: 150px; overflow: auto; white-space: pre-wrap; word-break: break-all; color: var(--text); }

/* ── BUTTONS ────────────────────────── */
.btn-sm {
  font-family: 'Cinzel', serif; font-size: 0.5rem; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  padding: 0.15rem 0.4rem; border-radius: 4px; cursor: pointer; margin-left: auto;
}
.btn-sm:hover { border-color: var(--accent); color: var(--text); }
.btn-xs {
  font-size: 0.55rem; background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); padding: 0.1rem 0.3rem; border-radius: 3px; cursor: pointer;
  text-decoration: none;
}
.btn-xs:hover { border-color: var(--accent); color: var(--text); }
.btn-accent { border-color: var(--accent); color: var(--accent); }
.btn-accent:hover { background: rgba(90,84,204,0.2); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.error { color: var(--danger); font-size: 0.75rem; padding: 0.3rem; }
.empty { color: var(--muted); font-size: 0.78rem; font-style: italic; padding: 0.3rem; }

/* ── MOBILE NAV ─────────────────────── */
#mob-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.mob-nav-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 0.15rem;
  padding: 0.5rem 0.75rem;
  background: none; border: none; color: var(--muted); cursor: pointer;
  min-width: 52px;
}
.mob-nav-btn.active { color: var(--ember); }
.mob-icon { font-size: 1.1rem; }
.mob-label { font-size: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }

@media (max-width: 1200px) {
  .grid { grid-template-columns: 200px 1fr 230px; }
}

@media (max-width: 767px) {
  body { overflow: auto; height: auto; }
  #dashboard { height: auto; overflow: auto; }
  .dash-header { padding: 0.6rem 1rem; }
  .dash-title { font-size: 1rem; }
  .grid {
    display: flex; flex-direction: column;
    padding-bottom: 60px;
    background: var(--bg);
    gap: 0;
  }
  .col { display: contents; }
  .module { display: none; min-height: calc(100vh - 112px); overflow: auto; }
  .module.mob-active { display: block; }
  .ctr-image { display: block; }
  #mob-nav { display: flex; }
}
