/* ── Admin Backoffice ───────────────────────────────────── */

.admin-body { background: var(--navy); min-height: 100vh; }

/* ── Wrapper — clears the fixed 64px site nav ─────────── */
.adm-wrap { padding-top: 64px; }

/* ── Tab bar ──────────────────────────────────────────── */
.adm-tabbar {
  position: sticky;
  top: 64px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 24px;
  background: var(--navy2);
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.adm-nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 16px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.adm-nav-item:hover { color: var(--white); background: rgba(255,255,255,0.03); }
.adm-nav-item.active { color: var(--white); border-bottom-color: var(--blue); }

/* ── Main content — max-width container ───────────────── */
.adm-main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 36px 24px 60px;
}

/* ── Page headers ─────────────────────────────────────── */
.adm-page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.adm-page-title { font-size: 1.5rem; font-weight: 700; color: var(--white); margin-bottom: 4px; }
.adm-page-sub   { font-size: 0.85rem; color: var(--muted); }

/* ── Search row ───────────────────────────────────────── */
.adm-search-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.adm-search { flex: 1; min-width: 160px; background: var(--glass2); border: 1px solid var(--border); color: var(--white); padding: 9px 14px; border-radius: 8px; font-size: 0.875rem; outline: none; }
.adm-search:focus { border-color: var(--blue); }
.adm-filter-select { background: var(--glass2); border: 1px solid var(--border); color: var(--muted); padding: 9px 12px; border-radius: 8px; font-size: 0.875rem; outline: none; cursor: pointer; }
.adm-filter-select:focus { border-color: var(--blue); color: var(--white); }

/* ── Table ────────────────────────────────────────────── */
.adm-table-wrap { background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.adm-table th { padding: 12px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.02); }
.adm-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.adm-table tr:last-child td { border-bottom: none; }
.adm-table tr:hover td { background: var(--glass); }
.adm-loading { text-align: center; color: var(--muted); padding: 40px !important; }

.adm-user-cell { display: flex; align-items: center; gap: 12px; }
.adm-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--purple)); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; color: white; flex-shrink: 0; }
.adm-user-name  { font-weight: 600; color: var(--white); font-size: 0.875rem; }
.adm-user-email { font-size: 0.78rem; color: var(--muted); }

.adm-plan-badge { display: inline-block; padding: 3px 8px; border-radius: 100px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--pc); border: 1px solid var(--pc); background: transparent; opacity: 0.9; }
.adm-status { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 0.72rem; font-weight: 600; }
.adm-status-active    { background: rgba(34,197,94,0.12);  color: #4ade80; }
.adm-status-suspended { background: rgba(239,68,68,0.12);  color: #f87171; }
.adm-status-admin     { background: rgba(245,158,11,0.12); color: var(--gold); }

.adm-num  { font-variant-numeric: tabular-nums; color: var(--text); }
.adm-date { font-size: 0.8rem; color: var(--muted); }
.adm-actions { display: flex; gap: 6px; }
.adm-btn-edit { background: var(--glass2); border: 1px solid var(--border); color: var(--muted); font-size: 0.78rem; padding: 5px 10px; border-radius: 6px; cursor: pointer; transition: all 0.15s; }
.adm-btn-edit:hover { color: var(--white); border-color: rgba(255,255,255,0.2); }

/* ── Modal ────────────────────────────────────────────── */
.adm-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px); }
.adm-modal { background: var(--navy2); border: 1px solid var(--border); border-radius: var(--radius2); width: 540px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.adm-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.adm-modal-title  { font-size: 1.1rem; font-weight: 700; color: var(--white); }
.adm-modal-close  { background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; transition: all 0.15s; }
.adm-modal-close:hover { color: var(--white); background: var(--glass2); }
.adm-modal-body   { padding: 16px 24px; overflow-y: auto; flex: 1; }
.adm-modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

/* ── Tabs inside modal ────────────────────────────────── */
.adm-tabs { display: flex; gap: 2px; background: var(--glass); border: 1px solid var(--border); border-radius: 8px; padding: 3px; margin-bottom: 20px; }
.adm-tab { flex: 1; background: none; border: none; color: var(--muted); font-size: 0.78rem; font-weight: 600; padding: 7px 4px; border-radius: 6px; cursor: pointer; transition: all 0.15s; }
.adm-tab:hover { color: var(--white); }
.adm-tab.active { background: var(--glass2); color: var(--white); }
.adm-tab-danger.active { color: #f87171; }
.adm-tab-content { display: none; }
.adm-tab-content.active { display: block; }

/* ── Form fields ──────────────────────────────────────── */
.adm-form-row { display: flex; gap: 12px; }
.adm-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.adm-field label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.adm-field input, .adm-field select { background: var(--glass); border: 1px solid var(--border); color: var(--white); padding: 9px 12px; border-radius: 8px; font-size: 0.875rem; outline: none; transition: border-color 0.15s; }
.adm-field input:focus, .adm-field select:focus { border-color: var(--blue); }
.adm-field-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.adm-toggle-label { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--glass); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 0.875rem; font-weight: 500; color: var(--text); }
.adm-toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.adm-toggle input { opacity: 0; width: 0; height: 0; }
.adm-toggle-slider { position: absolute; inset: 0; background: var(--glass2); border: 1px solid var(--border); border-radius: 22px; transition: 0.2s; }
.adm-toggle-slider:before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: var(--muted); border-radius: 50%; transition: 0.2s; }
.adm-toggle input:checked + .adm-toggle-slider { background: rgba(239,68,68,0.3); border-color: #ef4444; }
.adm-toggle input:checked + .adm-toggle-slider:before { transform: translateX(18px); background: #f87171; }

/* ── Credits ──────────────────────────────────────────── */
.adm-credits-note { font-size: 0.82rem; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.adm-credits-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.adm-credit-card { background: var(--glass); border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.adm-credit-label   { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.adm-credit-current { font-size: 1.4rem; font-weight: 700; color: var(--white); }
.adm-credit-add { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.adm-credit-add input { width: 70px; background: var(--glass2); border: 1px solid var(--border); color: var(--white); padding: 5px 8px; border-radius: 6px; font-size: 0.85rem; outline: none; text-align: center; }
.adm-credit-add input:focus { border-color: var(--blue); }

/* ── Danger zone ──────────────────────────────────────── */
.adm-danger-zone { background: var(--glass); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.adm-danger-zone h3 { font-size: 0.95rem; font-weight: 700; color: var(--white); margin-bottom: 6px; }
.adm-danger-zone p  { font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }
.adm-danger-delete  { border-color: rgba(239,68,68,0.2); }
.adm-btn-delete { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #f87171; font-size: 0.85rem; font-weight: 600; padding: 8px 16px; border-radius: 7px; cursor: pointer; transition: all 0.15s; }
.adm-btn-delete:hover { background: rgba(239,68,68,0.2); border-color: #ef4444; }

/* ── Messages ─────────────────────────────────────────── */
.adm-msg { font-size: 0.82rem; padding: 8px 12px; border-radius: 6px; flex: 1; }
.adm-msg-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.adm-msg-ok    { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3);  color: #4ade80; }

/* ── Dashboard ────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.dash-stat { background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; }
.dash-stat-val { font-size: 2rem; font-weight: 700; color: var(--white); }
.dash-stat-lbl { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
.dash-card { background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.dash-card-title { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.dash-row { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 24px; }

/* ── Sections ─────────────────────────────────────────── */
.adm-section { display: none; }
.adm-section.active { display: block; }

/* ── Articles ─────────────────────────────────────────── */
.adm-ai-gen-btn { background: linear-gradient(135deg, var(--blue, #2563eb), #7c3aed); border: none; border-radius: 7px; color: #fff; font-size: 0.78rem; font-weight: 700; padding: 6px 14px; cursor: pointer; font-family: inherit; transition: opacity .15s; }
.adm-ai-gen-btn:hover { opacity: .85; }
.adm-ai-gen-btn:disabled { opacity: .4; cursor: not-allowed; }
.adm-action-btn { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 6px; color: var(--text,#e2e8f0); font-size: 0.75rem; font-weight: 600; padding: 4px 10px; cursor: pointer; font-family: inherit; transition: opacity .15s; }
.adm-action-btn:hover { opacity: .75; }
.adm-action-del { color: #f87171 !important; border-color: rgba(248,113,113,.25) !important; }

/* ── Usage buttons ────────────────────────────────────── */
.adm-btn-sm { background: var(--glass2); border: 1px solid var(--border); color: var(--muted); font-size: 0.72rem; padding: 4px 9px; border-radius: 6px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.adm-btn-sm:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }
.adm-btn-sm.adm-btn-warn { border-color: rgba(245,158,11,0.3); color: #fbbf24; }
.adm-btn-sm.adm-btn-warn:hover { background: rgba(245,158,11,0.12); }

/* ── Security log ─────────────────────────────────────── */
.sec-event { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sec-event:last-child { border-bottom: none; }
.sec-type   { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #f87171; flex-shrink: 0; }
.sec-detail { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-ip     { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.sec-time   { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }

/* ── Primary action button ────────────────────────────── */
.adm-btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border: none; color: #fff; font-size: 0.85rem; font-weight: 600;
  padding: 9px 18px; border-radius: 8px; cursor: pointer;
  transition: opacity 0.15s; white-space: nowrap;
}
.adm-btn-primary:hover { opacity: 0.85; }

/* ── Inline delete button in rows ─────────────────────── */
.adm-btn-delete-sm {
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2);
  color: #f87171; font-size: 0.82rem; padding: 5px 9px;
  border-radius: 6px; cursor: pointer; transition: all 0.15s; line-height: 1;
}
.adm-btn-delete-sm:hover { background: rgba(239,68,68,0.18); border-color: #ef4444; }
