/* ============================================================
   EYE360 Portal — Stylesheet
   ============================================================ */

:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #21262d;
  --border:      #30363d;
  --accent:      #1f6feb;
  --accent-glow: rgba(31,111,235,0.25);
  --green:       #2ea043;
  --red:         #da3633;
  --amber:       #d29922;
  --text:        #e6edf3;
  --text2:       #8b949e;
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --radius:      8px;
  --radius-lg:   14px;
  --font:        'Inter', system-ui, sans-serif;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: width .25s ease;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .admin-chip span { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 17px; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--text2); display: block; }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--text2); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-item i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-logout:hover { color: var(--red); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.admin-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--bg3);
  border-radius: var(--radius); font-size: 13px; color: var(--text2);
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 16px;
  z-index: 90;
  transition: left .25s ease;
}
.topbar-toggle { background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; }
.topbar-title  { font-weight: 600; font-size: 16px; flex: 1; }
.topbar-right  { display: flex; align-items: center; gap: 12px; }
.topbar-time   { font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; }

/* ── Main content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px 32px;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left .25s ease;
}

/* ── Stat cards ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.green  { background: rgba(46,160,67,.15);  color: var(--green); }
.stat-icon.red    { background: rgba(218,54,51,.15);  color: var(--red); }
.stat-icon.amber  { background: rgba(210,153,34,.15); color: var(--amber); }
.stat-icon.blue   { background: rgba(31,111,235,.15); color: var(--accent); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 24px; overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 600; font-size: 15px; }
.card-body  { padding: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--bg3); padding: 11px 16px;
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text2); text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 12px 16px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content:''; width:6px; height:6px; border-radius:50%; }
.badge-active   { background: rgba(46,160,67,.15);  color: var(--green);  }
.badge-active::before { background: var(--green); }
.badge-inactive { background: rgba(218,54,51,.15);  color: var(--red);    }
.badge-inactive::before { background: var(--red); }
.badge-unknown  { background: rgba(139,148,158,.15); color: var(--text2); }
.badge-unknown::before { background: var(--text2); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; text-decoration: none; transition: opacity .15s, box-shadow .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--green);  color: #fff; }
.btn-danger  { background: var(--red);    color: #fff; }
.btn-outline {
  background: transparent; color: var(--text2);
  border: 1px solid var(--border);
}
.btn-outline:hover { color: var(--text); border-color: var(--text2); opacity: 1; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text2); }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  font-family: var(--font); transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: var(--accent); }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: rgba(46,160,67,.12); border: 1px solid rgba(46,160,67,.3);  color: #3fb950; }
.alert-error   { background: rgba(218,54,51,.12); border: 1px solid rgba(218,54,51,.3);  color: #f85149; }
.alert-info    { background: rgba(31,111,235,.12); border: 1px solid rgba(31,111,235,.3); color: #79c0ff; }
.alert-warning { background: rgba(210,153,34,.12); border: 1px solid rgba(210,153,34,.3); color: #e3b341; }

/* ── Token / Download box ────────────────────────────────── */
.token-box {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  font-family: monospace; font-size: 13px; word-break: break-all;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.token-box .copy-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 16px; flex-shrink: 0;
}

/* ── Grafana embed ───────────────────────────────────────── */
.grafana-frame {
  width: 100%; height: calc(100vh - 180px);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg2);
}

/* ── Login page ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 36px;
  box-shadow: var(--shadow);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .eye-icon {
  width: 64px; height: 64px; background: var(--accent);
  border-radius: 16px; display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 28px; color: #fff; margin-bottom: 14px;
  box-shadow: 0 0 32px var(--accent-glow);
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p  { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .brand-text,
  .sidebar .nav-item span,
  .sidebar .admin-chip span { display: none; }
  .topbar { left: 64px; }
  .main-content { margin-left: 64px; padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Misc helpers ────────────────────────────────────────── */
.text-muted  { color: var(--text2); }
.text-sm     { font-size: 13px; }
.mt-4        { margin-top: 16px; }
.mb-4        { margin-bottom: 16px; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-2       { gap: 8px; }
.justify-between { justify-content: space-between; }
.page-title  { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
