/* =====================================================
   ADMIN PANEL STYLES - NeverQuit MasterAdmin
   ===================================================== */

:root {
  --admin-primary: #6366f1;
  --admin-primary-dark: #4f46e5;
  --admin-primary-light: #818cf8;
  --admin-success: #10b981;
  --admin-success-light: #34d399;
  --admin-warning: #f59e0b;
  --admin-warning-light: #fbbf24;
  --admin-danger: #ef4444;
  --admin-danger-light: #f87171;
  --admin-info: #3b82f6;
  --admin-info-light: #60a5fa;

  --admin-bg: #0f172a;
  --admin-card-bg: #1e293b;
  --admin-card-hover: #334155;
  --admin-border: #475569;
  --admin-text: #f8fafc;
  --admin-text-secondary: #e2e8f0;
  --admin-text-muted: #94a3b8;
}

/* ── Panel container ────────────────────────────────── */
.nq-admin-panel {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  animation: nqAdminFadeIn 0.4s ease-out;
}

@keyframes nqAdminFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ─────────────────────────────────────────── */
.nq-admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--admin-border);
  flex-wrap: wrap;
  gap: 1rem;
}

.nq-admin-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--admin-text);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.nq-admin-badge {
  background: linear-gradient(135deg, var(--admin-primary), var(--admin-primary-dark));
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

.nq-admin-subtitle {
  color: var(--admin-text-muted);
  font-size: 1rem;
  margin: 0;
}

.nq-admin-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Stats grid ─────────────────────────────────────── */
.nq-admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.nq-stat-card {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 1rem;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.nq-stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  transition: background 0.3s ease;
}

.nq-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(99,102,241,0.15);
  border-color: var(--admin-primary);
}

.nq-stat-card:hover::before {
  background: linear-gradient(90deg, var(--admin-primary), var(--admin-primary-light));
}

.nq-stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.4rem;
}

.nq-stat-icon.users   { background: rgba(59,130,246,0.15);  color: var(--admin-info); }
.nq-stat-icon.beta    { background: rgba(245,158,11,0.15);  color: var(--admin-warning); }
.nq-stat-icon.paid    { background: rgba(16,185,129,0.15);  color: var(--admin-success); }
.nq-stat-icon.revenue { background: rgba(99,102,241,0.15);  color: var(--admin-primary); }

.nq-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--admin-text);
  line-height: 1.2;
}

.nq-stat-label {
  font-size: 0.8rem;
  color: var(--admin-text-muted);
  margin-top: 0.2rem;
}

/* ── Nav tabs ───────────────────────────────────────── */
.nq-admin-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--admin-border);
  padding-bottom: 1px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.nq-admin-nav::-webkit-scrollbar { display: none; }

.nq-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  color: var(--admin-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-radius: 0.5rem 0.5rem 0 0;
  font-family: inherit;
}

.nq-nav-btn:hover {
  color: var(--admin-text);
  background: rgba(99,102,241,0.05);
}

.nq-nav-btn.active {
  color: var(--admin-primary);
  border-bottom-color: var(--admin-primary);
  background: rgba(99,102,241,0.1);
}

/* ── Tab content ────────────────────────────────────── */
.nq-tab-pane {
  display: none;
  animation: nqAdminFadeIn 0.3s ease;
}

.nq-tab-pane.active { display: block; }

/* ── Section header ─────────────────────────────────── */
.nq-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.nq-section-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--admin-text);
  margin: 0;
}

.nq-section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--admin-text);
  margin: 1.5rem 0 1rem;
}

.nq-filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Form elements ──────────────────────────────────── */
.nq-search,
.nq-select,
.nq-input,
.nq-textarea {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  color: var(--admin-text);
  font-size: 0.875rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.nq-search { min-width: 240px; }

.nq-search:focus,
.nq-select:focus,
.nq-input:focus,
.nq-textarea:focus {
  outline: none;
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.nq-textarea {
  resize: vertical;
  min-height: 80px;
  width: 100%;
}

.nq-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

/* ── Tables ─────────────────────────────────────────── */
.nq-table-wrap {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 1rem;
  overflow: hidden;
  overflow-x: auto;
}

.nq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.nq-table th {
  background: rgba(99,102,241,0.05);
  padding: 0.875rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--admin-text);
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nq-table td {
  padding: 0.875rem 1rem;
  color: var(--admin-text-muted);
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.nq-table tbody tr { transition: background 0.2s ease; }
.nq-table tbody tr:hover { background: rgba(99,102,241,0.03); }
.nq-table tbody tr:last-child td { border-bottom: none; }

/* ── User cell ──────────────────────────────────────── */
.nq-user-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nq-user-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--admin-primary), var(--admin-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.nq-user-name { font-weight: 500; color: var(--admin-text); font-size: 0.875rem; }
.nq-user-email { font-size: 0.75rem; color: var(--admin-text-muted); }

/* ── Badges ─────────────────────────────────────────── */
.nq-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.nq-badge-beta     { background: rgba(245,158,11,0.15);  color: var(--admin-warning); }
.nq-badge-plan     { background: rgba(99,102,241,0.15);  color: var(--admin-primary); }
.nq-badge-active   { background: rgba(16,185,129,0.15);  color: var(--admin-success); }
.nq-badge-inactive { background: rgba(239,68,68,0.15);   color: var(--admin-danger); }
.nq-badge-new      { background: rgba(239,68,68,0.15);   color: var(--admin-danger); }
.nq-badge-read     { background: rgba(148,163,184,0.15); color: var(--admin-text-muted); }
.nq-badge-done     { background: rgba(16,185,129,0.15);  color: var(--admin-success); }

/* ── Action buttons ─────────────────────────────────── */
.nq-action-btns { display: flex; gap: 0.5rem; }

.nq-action-btn {
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.nq-action-btn:hover { background: rgba(99,102,241,0.1); transform: scale(1.05); }
.nq-action-btn.grant  { color: var(--admin-success); }
.nq-action-btn.grant:hover  { background: rgba(16,185,129,0.15); }
.nq-action-btn.revoke { color: var(--admin-danger); }
.nq-action-btn.revoke:hover { background: rgba(239,68,68,0.15); }
.nq-action-btn.edit   { color: var(--admin-info); }
.nq-action-btn.edit:hover   { background: rgba(59,130,246,0.15); }

/* ── Pagination ─────────────────────────────────────── */
.nq-pagination {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.nq-page-btn {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.625rem;
  border: 1px solid var(--admin-border);
  background: var(--admin-card-bg);
  color: var(--admin-text-muted);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: inherit;
}

.nq-page-btn:hover:not(:disabled) { border-color: var(--admin-primary); color: var(--admin-primary); }
.nq-page-btn.active { background: var(--admin-primary); border-color: var(--admin-primary); color: white; }
.nq-page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Plan cards ─────────────────────────────────────── */
.nq-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.nq-plan-card {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 1rem;
  padding: 1.5rem;
  position: relative;
  transition: all 0.3s ease;
}

.nq-plan-card:hover {
  border-color: var(--admin-primary);
  box-shadow: 0 10px 40px rgba(99,102,241,0.1);
  transform: translateY(-2px);
}

.nq-plan-card.inactive { opacity: 0.6; }

.nq-plan-card.inactive::after {
  content: 'INACTIVO';
  position: absolute;
  top: 1rem; right: 1rem;
  background: rgba(239,68,68,0.2);
  color: var(--admin-danger);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.nq-plan-name   { font-size: 1.1rem; font-weight: 600; color: var(--admin-text); margin-bottom: 0.25rem; }
.nq-plan-price  { font-size: 1.875rem; font-weight: 700; color: var(--admin-primary); line-height: 1; }
.nq-plan-price span { font-size: 0.875rem; color: var(--admin-text-muted); font-weight: 400; }
.nq-plan-desc   { font-size: 0.875rem; color: var(--admin-text-muted); margin: 0.75rem 0; line-height: 1.5; }

.nq-plan-features { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.nq-plan-features li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0; font-size: 0.875rem; color: var(--admin-text-muted);
}
.nq-plan-features li::before { content: "✓"; color: var(--admin-success); font-weight: 700; flex-shrink: 0; }

.nq-plan-actions { display: flex; gap: 0.5rem; }

/* ── Discount action card ───────────────────────────── */
.nq-action-card {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 520px;
  margin-bottom: 1.5rem;
}

.nq-action-card h3 { font-size: 1rem; font-weight: 600; color: var(--admin-text); margin: 0 0 0.4rem; }
.nq-action-card p  { font-size: 0.875rem; color: var(--admin-text-muted); margin: 0 0 1rem; }

.nq-inline-form { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.nq-inline-form input { width: 80px; text-align: center; }
.nq-inline-form input[type="number"]::-webkit-inner-spin-button,
.nq-inline-form input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── Feedback ───────────────────────────────────────── */
.nq-feedback-msg {
  font-size: 0.875rem;
  color: var(--admin-text);
  line-height: 1.5;
  max-width: 400px;
  word-break: break-word;
}

/* ── Metrics bars ───────────────────────────────────── */
.nq-metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }

.nq-kpi-card {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
}

.nq-kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--admin-text); }
.nq-kpi-label { font-size: 0.8rem; color: var(--admin-text-muted); margin-top: 0.25rem; }

.nq-bar-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.625rem; }
.nq-bar-label { font-size: 0.8rem; color: var(--admin-text-muted); width: 120px; flex-shrink: 0; }
.nq-bar-track { flex: 1; height: 8px; background: rgba(255,255,255,0.06); border-radius: 9999px; overflow: hidden; }
.nq-bar-fill  { height: 100%; border-radius: 9999px; background: var(--admin-primary); transition: width 0.5s ease; }
.nq-bar-fill.gold { background: var(--admin-warning); }
.nq-bar-count { font-size: 0.8rem; color: var(--admin-text-muted); width: 2.5rem; text-align: right; }

/* ── Modals ─────────────────────────────────────────── */
.nq-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal, 20000);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.nq-modal.active { display: flex; }

.nq-modal-box {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: 1rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  animation: nqModalIn 0.3s ease;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

@keyframes nqModalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.nq-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--admin-border);
}

.nq-modal-head h3 { font-size: 1.1rem; font-weight: 600; color: var(--admin-text); margin: 0; }

.nq-modal-close {
  background: none; border: none;
  color: var(--admin-text-muted);
  font-size: 1.25rem; cursor: pointer;
  width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.nq-modal-close:hover { color: var(--admin-danger); background: rgba(239,68,68,0.1); }

.nq-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.nq-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--admin-border);
  background: rgba(99,102,241,0.03);
}

/* ── Form groups ────────────────────────────────────── */
.nq-form-group { margin-bottom: 1.25rem; }
.nq-form-group:last-child { margin-bottom: 0; }
.nq-form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--admin-text);
  margin-bottom: 0.5rem;
}

.nq-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Buttons ────────────────────────────────────────── */
.nq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
}

.nq-btn-primary {
  background: linear-gradient(135deg, var(--admin-primary), var(--admin-primary-dark));
  color: white;
}
.nq-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }

.nq-btn-secondary { background: var(--admin-border); color: var(--admin-text); }
.nq-btn-secondary:hover { background: var(--admin-text-muted); }

.nq-btn-danger { background: var(--admin-danger); color: white; }
.nq-btn-danger:hover { background: var(--admin-danger-light); transform: translateY(-1px); }

.nq-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Code pill ──────────────────────────────────────── */
.nq-code {
  background: rgba(99,102,241,0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  color: var(--admin-primary);
}

/* ── Toast ──────────────────────────────────────────── */
.nq-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: var(--z-alert, 10001);
  animation: nqToastIn 0.3s ease;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

@keyframes nqToastIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

.nq-toast.success { background: var(--admin-success); }
.nq-toast.error   { background: var(--admin-danger); }
.nq-toast.info    { background: var(--admin-info); }
.nq-toast.warning { background: var(--admin-warning); }

/* ── Loading / empty ────────────────────────────────── */
.nq-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--admin-text-muted);
  gap: 0.75rem;
}

.nq-spinner {
  width: 1.5rem; height: 1.5rem;
  border: 2px solid var(--admin-border);
  border-top-color: var(--admin-primary);
  border-radius: 50%;
  animation: nqSpin 1s linear infinite;
}

@keyframes nqSpin { to { transform: rotate(360deg); } }

.nq-empty { text-align: center; padding: 3rem; color: var(--admin-text-muted); font-size: 0.875rem; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .nq-admin-panel { padding: 1rem; }
  .nq-admin-header { flex-direction: column; }
  .nq-admin-stats-grid { grid-template-columns: 1fr 1fr; }
  .nq-section-header { flex-direction: column; align-items: flex-start; }
  .nq-search { min-width: 100%; }
  .nq-form-row { grid-template-columns: 1fr; }
  .nq-toast { left: 1rem; right: 1rem; bottom: 1rem; max-width: none; }
  .nq-modal-box { max-height: 95vh; }
}

@media (max-width: 480px) {
  .nq-admin-stats-grid { grid-template-columns: 1fr; }
}

@media print {
  .nq-admin-nav, .nq-admin-actions, .nq-action-btns, .nq-btn { display: none !important; }
  .nq-tab-pane { display: block !important; }
}
