/**
 * Fase 5 UI Styles
 * Estilos para las nuevas secciones de la interfaz
 */

/* ============================================
   PANELES DE VISTA
   ============================================ */

.view-panel {
  position: absolute;
  top: 80px;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  overflow-y: auto;
  padding: 30px;
  z-index: 500;
  box-sizing: border-box;
}

.view-panel.hidden {
  display: none;
}

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

.view-title {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-primary);
}

.view-actions {
  display: flex;
  gap: 12px;
}

/* ============================================
   CARDS Y CONTENEDORES
   ============================================ */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--dur) var(--ease);
  box-shadow: var(--shadow-1);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.card-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.card-body p {
  margin-bottom: 8px;
}

.card-body ul {
  list-style: none;
  padding-left: 0;
  margin: 10px 0;
}

.card-body ul li {
  padding: 4px 0;
  color: var(--text-primary);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

/* ============================================
   BADGES Y ESTADOS
   ============================================ */

.badge {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-success {
  background: var(--success-wash);
  color: var(--success-text);
  border: 1px solid transparent;
}

.badge-inactive {
  background: var(--bg-tertiary) !important;
  color: var(--text-tertiary) !important;
  border: 1px solid var(--border-color) !important;
}

/* Prioridad: contorno, como .prio de la guia. !important para ganarle al
   .badge global de theme.css, que pinta todas las pildoras igual. */
.badge-high {
  background: transparent !important;
  color: var(--error-text) !important;
  border: 1px solid var(--error) !important;
}

.badge-medium {
  background: transparent !important;
  color: var(--warning-text) !important;
  border: 1px solid var(--gold) !important;
}

.badge-low {
  background: transparent !important;
  color: var(--text-tertiary) !important;
  border: 1px solid var(--border-color) !important;
}

/* ============================================
   BOTONES
   ============================================ */

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--accent-on);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--accent-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--error-wash);
  color: var(--error-text);
  border: 1px solid var(--error);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--error) 18%, transparent);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================
   FORMULARIOS
   ============================================ */

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

.form-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--dur) var(--ease);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
  box-shadow: var(--ring);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ============================================
   ESTADOS VACÍOS
   ============================================ */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  font-size: 15px;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 20px;
  opacity: 0.5;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: var(--success);
  transition: width 250ms var(--ease);
}

.progress-text {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

/* ============================================
   MODALES
   ============================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 30px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--dur) var(--ease);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-hover);
  transition: var(--dur) var(--ease);
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--bg-secondary);
  transition: var(--dur) var(--ease);
  border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
  background-color: var(--accent-primary);
}

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

/* ============================================
   STATS CARDS
   ============================================ */

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

.stat-card-admin {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px;
  text-align: center;
}

.stat-card-admin .stat-value {
  font-size: 40px;
  font-family: var(--font-mono);
  font-weight: 500;
  line-height: 1.1;
  color: var(--text-primary);
  margin: 10px 0;
}

.stat-card-admin .stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}



/* ============================================
   MOBILE RESPONSIVE ADAPTATIONS (FASE 1)
   ============================================ */

@media (max-width: 768px) {
  .view-panel {
    top: 70px;
    padding: 16px 14px 20px 14px;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .view-title {
    font-size: 20px;
  }

  .view-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .view-actions .btn {
    flex: 1 1 48%;
    justify-content: center;
    min-height: 44px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .card {
    padding: 16px;
  }

  .card-title {
    font-size: 15px;
  }

  .card-actions {
    flex-direction: column;
  }

  .btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  .btn-sm {
    min-height: 40px;
    padding: 8px 12px;
  }

  .form-input,
  .form-select,
  .form-textarea {
    min-height: 48px;
    padding: 10px 12px;
    font-size: 15px;
  }

  .modal-content {
    width: 95%;
    max-height: 95vh;
    padding: 20px 16px;
  }

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

  .empty-state {
    padding: 40px 16px;
    font-size: 13px;
  }
}

/* ============================================
   TABLAS MINIMALISTAS
   ============================================ */

/* Tabla nivel 0: borde line, encabezado cream */
.alerts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 15px;
}

.alerts-table thead {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.alerts-table th {
  padding: 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.alerts-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  vertical-align: middle;
}

.alerts-table tr:last-child td {
  border-bottom: none;
}

.alerts-table tr:hover {
  background: var(--bg-hover);
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.status-dot.active {
  background-color: var(--success);
}

.status-dot.inactive {
  background-color: var(--text-tertiary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all var(--dur) var(--ease);
  font-size: 16px;
}

.btn-icon:hover {
  color: var(--accent-primary);
  background: var(--bg-hover);
}

.btn-icon.danger:hover {
  color: var(--error-text);
  background: var(--error-wash);
}

.text-sm {
  font-size: 13px;
}

.text-secondary {
  color: var(--text-secondary);
}

/* ─── Tooltip custom para botones de acción del row de colab ───────────
   Se activa con data-tip="texto" en cualquier elemento. Aparece arriba
   del elemento al hover con un delay corto + flecha. Reemplaza el
   title="..." nativo (que tarda ~1s y es feo) — mantenemos también
   el title por accesibilidad / screen readers. */
[data-tip] {
  position: relative;
}
[data-tip]::after,
[data-tip]::before {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease) 0.15s, transform 0.15s var(--ease) 0.15s;
}
/* Tooltip invertido: tinta como fondo, superficie como texto (sigue el tema) */
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: var(--shadow-1);
  letter-spacing: 0.2px;
}
[data-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
  z-index: 1000;
}

[data-tip]:hover::after,
[data-tip]:hover::before,
[data-tip]:focus-visible::after,
[data-tip]:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.font-medium {
  font-weight: 500;
}