/* ═══════════════════════════════════════════════
   Astrocharts Admin Dashboard Styles
   ═══════════════════════════════════════════════ */

.admin-container {
  display: flex;
  min-height: calc(100vh - 64px);
  margin-top: 64px;
  position: relative;
}

/* ─── Sidebar ─── */
.admin-sidebar {
  width: 240px;
  background: var(--bg-elevated, #1a1a2e);
  border-right: 1px solid var(--border, rgba(255,255,255,0.08));
  position: fixed;
  top: 64px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 50;
}

.admin-sidebar-header {
  padding: 20px 16px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-secondary, #a0a0b8);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
}

.admin-nav {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text-secondary, #a0a0b8);
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.admin-nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary, #fff);
}

.admin-nav-item.active {
  background: var(--primary, #6c5ce7);
  color: #fff;
  font-weight: 600;
}

.admin-nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

/* ─── Main Content ─── */
.admin-main {
  flex: 1;
  margin-left: 240px;
  padding: 24px 32px;
  min-height: calc(100vh - 64px);
}

.admin-section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-section-title i {
  color: var(--primary, #6c5ce7);
}

/* ─── Tab Content ─── */
.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
  animation: adminFadeIn 0.25s ease;
}

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

/* ─── Stats Grid ─── */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.admin-stat-card {
  background: var(--bg-elevated, #1e1e36);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.admin-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.admin-stat-info {
  display: flex;
  flex-direction: column;
}

.admin-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  line-height: 1.2;
}

.admin-stat-label {
  font-size: 12px;
  color: var(--text-secondary, #a0a0b8);
  margin-top: 2px;
}

.admin-stat-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-radius: 20px;
  font-weight: 600;
}

/* ─── Chart Row ─── */
.admin-chart-row {
  display: flex;
  gap: 20px;
}

.admin-chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}

.admin-chart-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}

.admin-card {
  background: var(--bg-elevated, #1e1e36);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 20px;
}

.admin-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  margin-bottom: 16px;
}

.admin-card h3 i {
  color: var(--primary, #6c5ce7);
  margin-right: 6px;
}

/* ─── Toolbar ─── */
.admin-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.admin-input, .admin-select {
  padding: 8px 14px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 8px;
  background: var(--bg-elevated, #1e1e36);
  color: var(--text-primary, #fff);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.admin-input:focus, .admin-select:focus {
  border-color: var(--primary, #6c5ce7);
}

.admin-input {
  min-width: 240px;
}

/* ─── Buttons ─── */
.admin-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.admin-btn-primary {
  background: var(--primary, #6c5ce7);
  color: #fff;
}

.admin-btn-primary:hover {
  background: #5a4bd6;
}

.admin-btn-success {
  background: #10b981;
  color: #fff;
}

.admin-btn-success:hover {
  background: #059669;
}

.admin-btn-danger {
  background: #ef4444;
  color: #fff;
}

.admin-btn-danger:hover {
  background: #dc2626;
}

.admin-btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary, #fff);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
}

.admin-btn-ghost:hover {
  background: rgba(255,255,255,0.1);
}

.admin-btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

/* ─── Table ─── */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table thead th {
  background: var(--bg-elevated, #1a1a2e);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary, #a0a0b8);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.admin-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.04));
  color: var(--text-primary, #fff);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.admin-loading {
  text-align: center;
  color: var(--text-secondary, #a0a0b8);
  padding: 32px;
  font-style: italic;
}

/* ─── Status Badges ─── */
.admin-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.admin-badge-success { background: rgba(16,185,129,0.15); color: #10b981; }
.admin-badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.admin-badge-danger { background: rgba(239,68,68,0.15); color: #ef4444; }
.admin-badge-info { background: rgba(59,130,246,0.15); color: #3b82f6; }
.admin-badge-primary { background: rgba(108,92,231,0.15); color: #6c5ce7; }

/* ─── Role Badges ─── */
.admin-role-user { color: var(--text-secondary); }
.admin-role-premium { color: #f59e0b; font-weight: 600; }
.admin-role-admin { color: #ef4444; font-weight: 600; }

/* ─── Pagination ─── */
.admin-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 0;
}

.admin-pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 6px;
  background: var(--bg-elevated, #1e1e36);
  color: var(--text-primary, #fff);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-pagination button:hover {
  background: var(--primary, #6c5ce7);
  border-color: var(--primary, #6c5ce7);
}

.admin-pagination button.active {
  background: var(--primary, #6c5ce7);
  border-color: var(--primary, #6c5ce7);
  font-weight: 600;
}

.admin-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Feature Flags Grid ─── */
.admin-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.admin-feature-card {
  background: var(--bg-elevated, #1e1e36);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.admin-feature-card.enabled {
  border-color: rgba(16,185,129,0.3);
}

.admin-feature-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  margin-bottom: 4px;
}

.admin-feature-info p {
  font-size: 12px;
  color: var(--text-secondary, #a0a0b8);
}

/* Toggle Switch */
.admin-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.admin-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.admin-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 26px;
  transition: 0.3s;
}

.admin-toggle-slider:before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.admin-toggle input:checked + .admin-toggle-slider {
  background: #10b981;
}

.admin-toggle input:checked + .admin-toggle-slider:before {
  transform: translateX(22px);
}

/* ─── Knowledge Base Stats ─── */
.admin-kb-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-kb-stat {
  background: var(--bg-elevated, #1e1e36);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 12px;
}

.admin-kb-stat strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary, #6c5ce7);
  display: block;
}

/* ─── Funnel ─── */
.admin-funnel-step {
  padding: 12px 16px;
  margin-bottom: 6px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  position: relative;
  overflow: hidden;
}

.admin-funnel-step .funnel-bg {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 8px;
  opacity: 0.15;
  transition: width 0.6s ease;
}

.admin-funnel-step span {
  position: relative;
  z-index: 1;
}

.admin-funnel-step .funnel-value {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary, #fff);
}

.admin-funnel-step .funnel-pct {
  font-size: 11px;
  color: var(--text-secondary, #a0a0b8);
  margin-left: 6px;
}

/* ─── Modal ─── */
.admin-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-modal {
  background: var(--bg-surface, #1e1e36);
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.admin-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.admin-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #fff);
}

.admin-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

.admin-modal-body {
  padding: 24px;
}

.admin-modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #a0a0b8);
  margin-bottom: 4px;
  margin-top: 12px;
}

.admin-modal-body label:first-child {
  margin-top: 0;
}

.admin-modal-body input,
.admin-modal-body select,
.admin-modal-body textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: 8px;
  background: var(--bg-elevated, #151528);
  color: var(--text-primary, #fff);
  font-size: 13px;
}

.admin-modal-body textarea {
  min-height: 100px;
  resize: vertical;
}

.admin-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ─── Mobile Menu Toggle ─── */
.admin-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary, #6c5ce7);
  color: #fff;
  border: none;
  font-size: 20px;
  z-index: 200;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(108,92,231,0.5);
  transition: transform 0.2s;
}

.admin-mobile-toggle:active {
  transform: scale(0.92);
}

/* Mobile overlay when sidebar open */
.admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
}

/* ─── Responsive ─── */

/* Tablet */
@media (max-width: 1024px) {
  .admin-sidebar {
    width: 200px;
  }
  .admin-main {
    margin-left: 200px;
    padding: 20px;
  }
  .admin-stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* Mobile */
@media (max-width: 768px) {
  .admin-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .admin-overlay.active {
    display: block;
  }

  .admin-sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    top: 0;
    padding-top: 20px;
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
    padding: 16px 12px;
  }

  .admin-section-title {
    font-size: 18px;
    margin-bottom: 14px;
  }

  .admin-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .admin-stat-card {
    padding: 12px;
    gap: 10px;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .admin-stat-icon {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .admin-stat-value {
    font-size: 20px;
  }

  .admin-stat-label {
    font-size: 11px;
  }

  .admin-stat-badge {
    font-size: 9px;
    padding: 1px 6px;
    top: 8px;
    right: 8px;
  }

  .admin-chart-row {
    flex-direction: column;
  }

  .admin-chart-container {
    height: 180px;
  }

  .admin-card {
    padding: 14px;
  }

  .admin-card h3 {
    font-size: 13px;
  }

  /* Toolbar */
  .admin-toolbar {
    flex-direction: column;
    gap: 8px;
  }

  .admin-input {
    min-width: unset;
    width: 100%;
  }

  .admin-select {
    width: 100%;
  }

  /* Table scroll */
  .admin-table-wrap {
    border-radius: 8px;
  }

  .admin-table {
    font-size: 12px;
  }

  .admin-table thead th {
    padding: 8px 10px;
    font-size: 10px;
  }

  .admin-table tbody td {
    padding: 8px 10px;
  }

  /* Features grid */
  .admin-features-grid {
    grid-template-columns: 1fr;
  }

  /* KB stats */
  .admin-kb-stats {
    gap: 8px;
  }

  .admin-kb-stat {
    padding: 8px 12px;
    font-size: 11px;
    flex: 1;
    min-width: 80px;
  }

  .admin-kb-stat strong {
    font-size: 16px;
  }

  /* Modal */
  .admin-modal {
    width: 95%;
    max-height: 90vh;
  }

  .admin-modal-header {
    padding: 14px 16px;
  }

  .admin-modal-body {
    padding: 16px;
  }

  /* Pagination */
  .admin-pagination {
    gap: 4px;
  }

  .admin-pagination button {
    padding: 5px 10px;
    font-size: 11px;
  }

  /* Funnel */
  .admin-funnel-step {
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* Small phones */
@media (max-width: 400px) {
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }

  .admin-stat-card {
    flex-direction: row;
    align-items: center;
  }

  .admin-main {
    padding: 12px 8px;
  }
}
