/* ================= SISTEMA DE DISEÑO DEL PANEL ADMINISTRATIVO ================= */
:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-border: #bae6fd;
  
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #0f172a;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  
  --border-subtle: #e2e8f0;
  --border-focus: #38bdf8;
  
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  
  --font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-display: 'Outfit', system-ui, sans-serif;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ================= PANTALLA DE BLOQUEO POR PIN ================= */
.pin-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.pin-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-float);
  animation: enter-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes enter-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.pin-icon {
  font-size: 46px;
  margin-bottom: 12px;
}

.pin-card h2 {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}

.pin-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.pin-input-group {
  margin-bottom: 16px;
}

.pin-input-group input {
  width: 100%;
  padding: 14px;
  text-align: center;
  font-size: 26px;
  letter-spacing: 8px;
  font-weight: 700;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}

.pin-input-group input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.15);
}

.pin-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 16px;
}

.btn-unlock {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-unlock:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.pin-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

.btn-return-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
}

.btn-return-link:hover {
  text-decoration: underline;
}

/* ================= WRAPPER PRINCIPAL DE ADMINISTRACIÓN ================= */
.admin-wrapper {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px 20px 60px 20px;
}

/* ================= HEADER ================= */
.admin-header {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-size: 28px;
  width: 44px;
  height: 44px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-header h1 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-header .highlight {
  color: #ea580c;
}

.badge-role {
  background: #0f172a;
  color: #38bdf8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 4px;
}

.domain-tag {
  font-size: 12px;
  color: #0284c7;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.btn-action-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action-nav:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-logout {
  color: var(--danger);
}

.btn-logout:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* ================= TELEMETRY BAR ================= */
.telemetry-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.telemetry-item {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.t-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.t-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
}

/* ================= TABS NAVEGACIÓN ================= */
.admin-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-subtle);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 18px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font-family);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(2, 132, 199, 0.04);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
  border-radius: 8px 8px 0 0;
}

/* ================= PANELES ================= */
.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
  animation: fade-in 0.2s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  color: var(--text-main);
}

.panel-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ================= FORMULARIO Y TARJETAS DE CONFIGURACIÓN ================= */
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.admin-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
}

.card-icon {
  font-size: 26px;
}

.card-head h3 {
  font-family: var(--font-display);
  font-size: 17.5px;
  font-weight: 700;
  color: var(--text-main);
}

.card-head p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 14px;
  background: #f8fafc;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.form-help {
  font-size: 12px;
  color: var(--text-light);
}

.preview-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
}

.info-alert {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #166534;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-save-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
  transition: all 0.2s;
}

.btn-save-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* ================= TAB 2: TABLA DE MODERACIÓN ================= */
.search-input {
  width: 320px;
  padding: 8px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 13.5px;
  outline: none;
}

.table-container {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.admin-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1.5px solid var(--border-subtle);
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #f8fafc;
}

.loading-td {
  text-align: center;
  padding: 30px !important;
  color: var(--text-muted);
}

.btn-delete-report {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fca5a5;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete-report:hover {
  background: var(--danger);
  color: #ffffff;
}

.intensity-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.i-1 { background: #f1f5f9; color: #475569; }
.i-2 { background: #dcfce7; color: #15803d; }
.i-3 { background: #fef3c7; color: #b45309; }
.i-4 { background: #ffedd5; color: #c2410c; }
.i-5 { background: #fee2e2; color: #dc2626; }

/* ================= TAB 3: RECURSOS DEL CNS ================= */
.recursos-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.recurso-admin-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.recurso-admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.recurso-admin-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* ================= TAB 4: TELEMETRÍA ================= */
.telemetry-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.telemetry-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.telemetry-card.full-width {
  grid-column: 1 / -1;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

.tag-status {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.tag-online {
  background: #dcfce7;
  color: #15803d;
}

.packet-detail-box {
  background: #0f172a;
  color: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 13.5px;
  line-height: 1.6;
}

/* ================= MODAL DE NUEVA CONFERENCIA ================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 100%;
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
}

.modal-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.modal-close-btn {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.btn-cancel {
  background: #f1f5f9;
  border: 1px solid var(--border-subtle);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
}

/* ================= TOASTS ================= */
.admin-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-toast {
  background: #0f172a;
  color: #ffffff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  animation: toast-in 0.25s ease-out;
}

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

/* ================= RESPONSIVE DESIGN ADMIN ================= */
@media (max-width: 900px) {
  .telemetry-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  .config-grid, .telemetry-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .admin-wrapper {
    padding: 12px 10px 50px 10px;
  }

  .admin-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 16px;
  }

  .header-right {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
  }

  .telemetry-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .telemetry-item {
    padding: 12px 14px;
  }

  .t-value {
    font-size: 20px;
  }

  .admin-tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 10px 14px;
    font-size: 13.5px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .panel-header .btn-save-primary {
    width: 100%;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-input, .search-input {
    font-size: 16px; /* Evita zoom molesto en iOS Safari */
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 680px; /* Permite scroll horizontal fluido para moderar columnas */
  }

  .form-actions-bar {
    justify-content: stretch;
  }

  .form-actions-bar .btn-save-primary {
    width: 100%;
    justify-content: center;
  }

  .modal-dialog {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
  }
}

@media (max-width: 440px) {
  .telemetry-bar {
    grid-template-columns: 1fr;
  }
}
