/* ===================================================
   admin.css — Janitorial Systems Admin Panel
   Matches the visual system of index.html / settings.html
   DM Sans font, CSS custom properties, light/dark support
   =================================================== */

/* ─────────────────────────────────────────────
   CSS TOKENS — mirrors index.html :root
   ───────────────────────────────────────────── */
:root {
  --bg:          #f4f6f9;
  --bg-card:     #ffffff;
  --bg-input:    #f1f5f9;
  --bg-hover:    #e8edf3;
  --border:      #dde3ec;
  --accent:      #3b82f6;
  --accent-hover:#2563eb;
  --success:     #10b981;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --text:        #0f172a;
  --text-sub:    #475569;
  --text-muted:  #94a3b8;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);
}

/* Dark mode — toggled by body.dark (same as index.html) */
body.dark {
  --bg:          #0f1419;
  --bg-card:     #1a2028;
  --bg-input:    #2a3441;
  --bg-hover:    #242d38;
  --border:      #334155;
  --text:        #f1f5f9;
  --text-sub:    #94a3b8;
  --text-muted:  #64748b;
  --shadow:      0 1px 4px rgba(0,0,0,0.3);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.4);
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

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

.hidden { display: none !important; }

/* ─────────────────────────────────────────────
   PAGE HEADER — matches topbar style
   ───────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.user-info {
  font-size: 0.82rem;
  color: var(--text-sub);
  font-weight: 600;
}

/* ─────────────────────────────────────────────
   STATUS BAR
   ───────────────────────────────────────────── */
.status-bar {
  padding: 10px 40px;
  font-size: 0.82rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.status-bar.hidden { display: none; }
.status-bar.info    { background: rgba(59,130,246,0.08);  color: var(--accent);  border-color: rgba(59,130,246,0.2); }
.status-bar.success { background: rgba(16,185,129,0.08);  color: var(--success); border-color: rgba(16,185,129,0.2); }
.status-bar.error   { background: rgba(239,68,68,0.08);   color: var(--danger);  border-color: rgba(239,68,68,0.2); }

/* ─────────────────────────────────────────────
   MAIN LAYOUT
   ───────────────────────────────────────────── */
.admin-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 40px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ─────────────────────────────────────────────
   CARD — matches settings.html .card
   ───────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.card h3 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  margin-top: 20px;
}

/* ─────────────────────────────────────────────
   LOADING / EMPTY STATES
   ───────────────────────────────────────────── */
.loading-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 12px 0;
}

.muted {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ─────────────────────────────────────────────
   INFO TABLE (key/value pairs)
   ───────────────────────────────────────────── */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.info-table th,
.info-table td {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.info-table tr:last-child th,
.info-table tr:last-child td {
  border-bottom: none;
}

.info-table th {
  width: 160px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-right: 20px;
}

.info-table td {
  color: var(--text);
  font-weight: 500;
}

/* ─────────────────────────────────────────────
   DATA TABLE (members, apps)
   ───────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead th {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.data-table tbody td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--bg-hover);
}

/* ─────────────────────────────────────────────
   BADGES
   ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-yes      { background: rgba(16,185,129,0.12);  color: #10b981; }
.badge-no       { background: rgba(100,116,139,0.12); color: #64748b; }
.badge-active   { background: rgba(16,185,129,0.12);  color: #10b981; }
.badge-inactive { background: rgba(100,116,139,0.12); color: #64748b; }
.badge-trialing { background: rgba(59,130,246,0.12);  color: #3b82f6; }
.badge-past_due { background: rgba(239,68,68,0.12);   color: #ef4444; }
.badge-canceled { background: rgba(239,68,68,0.12);   color: #ef4444; }
.badge-none     { background: rgba(100,116,139,0.12); color: #64748b; }

/* ─────────────────────────────────────────────
   ROLE SELECT (inline dropdown in members table)
   ───────────────────────────────────────────── */
.role-select {
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.role-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* ─────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary   { background: var(--accent);    color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-hover);  color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-input); }

.btn-success   { background: rgba(16,185,129,0.12); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.btn-success:hover:not(:disabled) { background: rgba(16,185,129,0.2); }

.btn-danger    { background: rgba(239,68,68,0.1);   color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.18); }

/* Small variant */
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* ─────────────────────────────────────────────
   BUTTON ROW
   ───────────────────────────────────────────── */
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ─────────────────────────────────────────────
   FORM GROUP (edit sections within cards)
   ───────────────────────────────────────────── */
.form-group {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-top: 12px;
}

.form-group label:first-of-type { margin-top: 0; }

.form-group input,
.form-group select {
  width: 100%;
  max-width: 400px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
  display: block;
  margin-bottom: 12px;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* ─────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-header { padding: 0 16px; }
  .admin-main  { padding: 20px 16px 60px; }
  .card        { padding: 18px 16px; }
  .info-table th { width: 110px; }
  .button-row  { flex-direction: column; }
  .btn         { width: 100%; justify-content: center; }
}
