/* ─────────────────────────────────────────────────────────────
   BattleTAI Admin
   Estilos autosuficientes para admin.battletai.com
   ───────────────────────────────────────────────────────────── */

:root {
  --bg: #050510;
  --bg-2: #08081a;
  --bg-3: #0c0b22;
  --white: #eef0ff;
  --text: #eef0ff;
  --text-muted: #9aa0c0;
  --text-dim: #6b6f8d;
  --blue: #00a0ff;
  --red: #ff2d55;
  --gold: #ffd700;
  --success: #00ff88;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.085);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --grad: linear-gradient(120deg, #00a0ff 0%, #ff2d55 100%);
  --shadow: 0 24px 70px -28px rgba(0, 0, 0, 0.78);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(900px 520px at 15% 0%, rgba(0, 160, 255, 0.16), transparent 62%),
    radial-gradient(760px 520px at 100% 20%, rgba(255, 45, 85, 0.15), transparent 58%),
    var(--bg);
  color: var(--white);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.admin-container {
  display: flex;
  min-height: 100vh;
}

/* ───────────────────────────────────────────────────────────── */
/* Sidebar */
/* ───────────────────────────────────────────────────────────── */

.admin-sidebar {
  width: 260px;
  background: rgba(5, 5, 16, 0.86);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  height: 32px;
  width: 32px;
  object-fit: contain;
}

.sidebar-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--white);
}

.nav-item.active {
  background: var(--grad);
  color: var(--white);
}

.nav-icon {
  font-size: 18px;
}

.nav-text {
  flex: 1;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-avatar {
  width: 40px;
  height: 40px;
  background: var(--grad);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.admin-details {
  flex: 1;
  min-width: 0;
}

.admin-email {
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-status {
  font-size: 12px;
  color: #00ff88;
  margin-top: 2px;
}

.btn-logout {
  background: rgba(255, 45, 85, 0.1);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

.btn-logout:hover {
  background: rgba(255, 45, 85, 0.2);
}

/* ───────────────────────────────────────────────────────────── */
/* Main Content */
/* ───────────────────────────────────────────────────────────── */

.admin-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(5, 5, 16, 0.68);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--white);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-info {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

.admin-section {
  display: none;
  padding: 32px;
}

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

/* ───────────────────────────────────────────────────────────── */
/* Metrics Cards */
/* ───────────────────────────────────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.metric-card {
  background: rgba(5, 5, 16, 0.76);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-icon {
  font-size: 32px;
}

.metric-content {
  flex: 1;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.metric-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

/* ───────────────────────────────────────────────────────────── */
/* Cards & Tables */
/* ───────────────────────────────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.card {
  background: rgba(5, 5, 16, 0.76);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--white);
}

.card-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search-input, .filter-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--white);
  font-size: 13px;
  min-width: 200px;
}

.search-input:focus, .filter-select:focus {
  outline: none;
  border-color: var(--blue);
}

.card-body {
  padding: 0;
}

.table-container {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 160, 255, 0.45) rgba(255, 255, 255, 0.06);
}

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

.data-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
  vertical-align: middle;
}

.data-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.data-table .loading {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  padding: 40px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pagination button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pagination button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

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

.pagination .page-info {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

/* ───────────────────────────────────────────────────────────── */
/* Buttons & Actions */
/* ───────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--grad);
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(0, 160, 255, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--white);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

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

.btn-danger {
  background: rgba(255, 45, 85, 0.1);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--red);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-danger:hover {
  background: rgba(255, 45, 85, 0.2);
}

.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ───────────────────────────────────────────────────────────── */
/* Status Badges */
/* ───────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(0, 255, 136, 0.1);
  color: var(--success);
}

.badge-danger {
  background: rgba(255, 45, 85, 0.1);
  color: var(--red);
}

.badge-warning {
  background: rgba(255, 215, 0, 0.1);
  color: var(--gold);
}

.badge-info {
  background: rgba(0, 160, 255, 0.1);
  color: var(--blue);
}

/* ───────────────────────────────────────────────────────────── */
/* Modal */
/* ───────────────────────────────────────────────────────────── */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: rgba(5, 5, 16, 0.95);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
}

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

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.3s ease;
}

.modal-close:hover {
  color: var(--white);
}

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
}

.form-group input,
.form-group select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--white);
  font-size: 14px;
}

.form-help {
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  margin-top: 8px;
}

.setup-secret {
  display: grid;
  gap: 8px;
  text-align: left;
}

.setup-secret code {
  display: block;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue);
}

/* ───────────────────────────────────────────────────────────── */
/* Backup Codes Display */
/* ───────────────────────────────────────────────────────────── */

.backup-codes-display {
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.backup-codes-display h3 {
  color: var(--gold);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.backup-codes-display p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  margin-bottom: 12px;
}

.backup-codes-list {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--gold);
  line-height: 1.8;
}

/* ───────────────────────────────────────────────────────────── */
/* Responsive */
/* ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .admin-sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
    position: sticky;
    top: 0;
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-container {
    display: block;
  }

  .sidebar-header {
    padding: 16px;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 12px 12px;
  }

  .nav-item {
    flex: 0 0 auto;
  }

  .sidebar-footer {
    display: none;
  }

  .admin-header {
    padding: 16px;
  }

  .admin-section {
    padding: 16px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .search-input,
  .filter-select {
    min-width: min(100%, 280px);
    width: 100%;
  }
}
