/* ============================================================
   ActivityDashboard — Responsive Dark Analytics UI
   Breakpoints: mobile <640  tablet <1024  desktop 1024+
   ============================================================ */

:root {
  --bg:          #1A1D27;
  --bg-2:        #13151F;
  --card:        #21253A;
  --card-border: rgba(255,255,255,0.07);
  --sidebar:     #0F1117;
  --sidebar-w:   240px;

  --text:        #E2E8F0;
  --text-dim:    #8892A4;
  --text-faint:  #4A5568;

  --accent:      #4F7FFA;
  --accent-dim:  #3A6AE8;
  --green:       #22C55E;
  --yellow:      #F59E0B;
  --red:         #EF4444;
  --purple:      #A855F7;
  --cyan:        #06B6D4;

  --line:        rgba(255,255,255,0.07);
  --radius:      8px;

  --font-body:    'Inter',          'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk',  'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Consolas', monospace;

  --topbar-h:    56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background:  var(--bg);
  color:       var(--text);
  font-family: var(--font-body);
  font-size:   14px;
  line-height: 1.6;
  margin:      0;
  overflow-x:  hidden;
}

h1,h2,h3,h4 { font-family: var(--font-display); margin-top: 0; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #fff; }
img { max-width: 100%; }

/* ── Shell layout ─────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.25s ease;
}

/* Mobile: hide sidebar off-screen by default */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.open {
    transform: translateX(0);
  }
}

/* Overlay behind sidebar on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
}
.sidebar-overlay.visible { display: block; }

.sidebar-brand {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--topbar-h);
}
.sidebar-brand .logo-mark {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; color: #fff; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-brand .brand-text { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-sub  { font-size: 0.65rem; color: var(--text-dim); font-family: var(--font-mono); letter-spacing: 0.04em; }
.sidebar-brand .brand-sub span { font-family: var(--font-mono); font-size: 0.63rem; letter-spacing: 0.08em; }

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  padding: 14px 20px 5px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-dim);
  font-size: 0.87rem;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-nav a:hover { background: rgba(79,127,250,0.08); color: var(--text); }
.sidebar-nav a.active { background: rgba(79,127,250,0.12); color: var(--accent); border-left-color: var(--accent); }
.sidebar-nav a i { width: 18px; text-align: center; font-size: 0.92rem; flex-shrink: 0; }

.sidebar-nav a[href^="/superadmin"].active { background: rgba(245,158,11,0.12); color: var(--yellow); border-left-color: var(--yellow); }
.sidebar-nav a[href^="/superadmin"]:hover  { background: rgba(245,158,11,0.07); color: var(--yellow); }

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 10px 0; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}
@media (max-width: 1023px) {
  .main-content { margin-left: 0; }
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.topbar-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* Hamburger button — shown only on mobile */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  flex-shrink: 0;
  line-height: 1;
}
.sidebar-toggle:hover { color: var(--text); background: rgba(255,255,255,0.06); }
@media (max-width: 1023px) {
  .sidebar-toggle { display: flex; align-items: center; }
  /* Hide clock on very small screens */
  .topbar-right .clock-text { display: none; }
}
@media (max-width: 479px) {
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: 0.9rem; }
}

/* ── Page body ────────────────────────────────────────────── */
.page-body { padding: 24px; flex: 1; }
@media (max-width: 767px)  { .page-body { padding: 16px; } }
@media (max-width: 479px)  { .page-body { padding: 12px; } }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem;
  color: #fff; flex-shrink: 0;
}

/* ── KPI grid ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width:  500px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.kpi-card.kpi-blue::before   { background: var(--accent); }
.kpi-card.kpi-green::before  { background: var(--green);  }
.kpi-card.kpi-yellow::before { background: var(--yellow); }
.kpi-card.kpi-purple::before { background: var(--purple); }

.kpi-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  margin-bottom: 5px;
}
.kpi-sub { font-size: 0.76rem; color: var(--text-dim); }
.kpi-icon {
  position: absolute;
  right: 16px; top: 16px;
  font-size: 1.5rem;
  opacity: 0.12;
}

/* ── Generic card ─────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: visible;
  /* Use clip-path to keep rounded corners without clipping scroll children */
}
/* Ensure the card's visual edges are preserved */
.card > .card-header { border-radius: var(--radius) var(--radius) 0 0; }
.card > .card-body   { border-radius: 0 0 var(--radius) var(--radius); }
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.card-header h3 { font-size: 0.9rem; font-weight: 600; margin: 0; color: var(--text); }
.card-header .card-action { font-size: 0.78rem; color: var(--accent); white-space: nowrap; }
.card-body { padding: 16px 18px; }
.mb-4 { margin-bottom: 16px; }

/* ── Two / three column grids ─────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
@media (max-width: 1023px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width:  900px) { .grid-3 { grid-template-columns: 1fr; } }

/* Responsive table wrapper — see .data-table-wrap below */

/* Scrollable table wrapper */
.data-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  border-radius: 0 0 var(--radius) var(--radius);
}

.data-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.data-table th {
  background: rgba(255,255,255,0.03);
  padding: 9px 13px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.025); }
.data-table td.mono { font-family: var(--font-mono); font-size: 0.79rem; color: var(--text-dim); }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.filter-bar label {
  font-family: var(--font-mono);
  font-size: 0.69rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  white-space: nowrap;
}
.filter-bar input[type="date"],
.filter-bar select {
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 0.83rem;
  font-family: var(--font-mono);
  min-width: 0;
  max-width: 100%;
}
.filter-bar input[type="date"]:focus,
.filter-bar select:focus { outline: none; border-color: var(--accent); }
@media (max-width: 600px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar > *,
  .filter-bar form { width: 100%; }
  .filter-bar form { display: flex; flex-direction: column; gap: 10px; }
  .filter-bar select,
  .filter-bar input[type="date"] { width: 100%; }
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 7px 15px;
  border-radius: 5px;
  font-size: 0.81rem;
  font-family: var(--font-mono);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-success { background: var(--green);  color: #fff; border-color: var(--green);  }
.btn-outline { background: transparent; color: var(--text-dim); border-color: rgba(255,255,255,0.14); }
.btn-outline:hover { color: var(--text); border-color: rgba(255,255,255,0.28); opacity: 1; }
.btn-sm { padding: 4px 10px; font-size: 0.74rem; }
@media (max-width: 479px) { .btn { padding: 6px 12px; } .btn-sm { padding: 4px 8px; } }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-high   { background: rgba(34,197,94,0.15);  color: var(--green);  }
.badge-medium { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-low    { background: rgba(239,68,68,0.15);  color: var(--red);    }
.badge-info   { background: rgba(6,182,212,0.15);  color: var(--cyan);   }

/* ── Progress bars ────────────────────────────────────────── */
.progress-bar-bg   { background: rgba(255,255,255,0.07); border-radius: 4px; height: 5px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.6s ease; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.alert-success { background: rgba(34,197,94,0.12);  color: var(--green); border: 1px solid rgba(34,197,94,0.2);  }
.alert-danger  { background: rgba(239,68,68,0.12);  color: var(--red);   border: 1px solid rgba(239,68,68,0.2);  }

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 36px 32px;
}
@media (max-width: 440px) { .login-box { padding: 24px 18px; } }
.login-box h2    { font-size: 1.4rem; margin-bottom: 6px; }
.login-box p     { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 24px; }
.form-group      { margin-bottom: 16px; }
.form-group label, .form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: var(--font-body);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,127,250,0.15); }
.form-control::placeholder { color: var(--text-faint); }
.text-danger { color: var(--red); font-size: 0.79rem; margin-top: 4px; display: block; }

/* ── Utility ──────────────────────────────────────────────── */
.text-dim        { color: var(--text-dim); }
.text-accent     { color: var(--accent);   }
.text-green      { color: var(--green);    }
.text-yellow     { color: var(--yellow);   }
.text-red        { color: var(--red);      }
.text-right      { text-align: right;      }
.mono            { font-family: var(--font-mono); }
.fw-bold         { font-weight: 700; }
.mt-4            { margin-top: 16px; }
.mb-4            { margin-bottom: 16px; }
.gap-2           { gap: 8px; }
.d-flex          { display: flex; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100           { width: 100%; }
.me-1            { margin-right: 4px; }
.me-2            { margin-right: 8px; }

/* ── API docs ─────────────────────────────────────────────── */
.api-block { background: var(--bg-2); border: 1px solid var(--card-border); border-radius: 6px; padding: 14px 16px; margin-bottom: 14px; }
.api-method { display: inline-block; padding: 2px 8px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.api-method.post { background: rgba(34,197,94,0.15); color: var(--green); }
.api-method.get  { background: rgba(79,127,250,0.15); color: var(--accent); }
.api-url { font-family: var(--font-mono); font-size: 0.84rem; color: var(--text); margin-left: 10px; }
pre.api-code { background: #0a0c14; border-radius: 6px; padding: 13px; overflow-x: auto; font-family: var(--font-mono); font-size: 0.79rem; color: #a8d8d5; margin: 10px 0 0; line-height: 1.6; }

/* ── SuperAdmin form labels ───────────────────────────────── */
.card .form-group { margin-bottom: 14px; }
.card .form-label { display: block; font-family: var(--font-mono); font-size: 0.71rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 6px; }

/* ── Chart container ──────────────────────────────────────── */
.chart-container { position: relative; }

/* ── Mobile-specific table tweaks ────────────────────────── */
@media (max-width: 640px) {
  .data-table th, .data-table td { padding: 8px 10px; font-size: 0.8rem; }
  .kpi-value { font-size: 1.6rem; }
}
