/**
 * Sistema de diseño compartido del panel admin: estructura general (shell,
 * topbar, contenido), tablas de datos, badges de estado, acciones tipo ícono,
 * switches y secciones de formulario colapsables. Lo usan TODAS las vistas del
 * admin (Dashboard, Productos, Categorías, Cotizaciones, WhatsApp).
 *
 * ⚠️ Igual que shared/components.css: si una regla es específica de UNA sola
 * vista del admin, va en su propio archivo bajo assets/css/pages/admin/, no acá.
 */

.admin-body { background: var(--color-bg); }
.admin-shell { display: flex; min-height: 100vh; }

/* ---------- Estructura principal ---------- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  height: 68px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-topbar-title { margin: 0; font-size: 1.15rem; flex: 1; }
.admin-topbar-actions { display: flex; align-items: center; gap: 1rem; }
.admin-sidebar-toggle { display: none; }
.admin-user { display: flex; align-items: center; gap: 0.6rem; }
.admin-user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.82rem; flex-shrink: 0;
}
.admin-user small { display: block; color: var(--color-text-muted); font-size: 0.72rem; }

/* Barra de progreso de navegación AJAX (SPA Katrina) */
#admin-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), #FF85C0);
  box-shadow: 0 0 10px rgba(255, 94, 167, 0.8);
  transition: width 0.25s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
}
#admin-progress-bar.is-active {
  opacity: 1;
}

.admin-content {
  padding: 1.75rem;
  flex: 1;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.admin-content.is-loading {
  opacity: 0.45;
  transform: translateY(4px);
  pointer-events: none;
}
.admin-page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.admin-page-header p { margin: 0.2rem 0 0; }

/* ---------- Tabla de datos (Productos, Categorías, Cotizaciones) ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.25rem 0; flex-wrap: wrap; }
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-top: 1rem; }
.data-table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--color-text-muted); padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table td { padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:nth-child(even) { background: var(--color-surface-2); }
.data-table tbody tr:hover { background: var(--color-primary-soft); }
.data-table tr:last-child td { border-bottom: none; }

/* ---------- Badges de estado ---------- */
.status-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.7rem; border-radius: var(--radius-pill); font-size: 0.72rem; font-weight: 700; }
.status-pendiente { background: #FDECC8; color: #92650B; }
.status-atendida { background: #DCEBFB; color: #205C9C; }
.status-cerrada { background: #DFF3DE; color: #2F7A2C; }
.status-anulada { background: #FBDCDC; color: #A82C2C; }
.status-activo { background: #DFF3DE; color: #2F7A2C; }
.status-inactivo { background: var(--color-surface-2); color: var(--color-text-muted); }

/* ---------- Acciones tipo ícono circular ---------- */
.icon-action { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: none; background: var(--color-surface-2); color: var(--color-text-muted); }
.icon-action svg { width: 16px; height: 16px; }
.icon-action.edit { background: var(--color-secondary-soft); color: #5B4A85; }
.icon-action.delete { background: #FBDCDC; color: #A82C2C; }
.icon-action:hover { filter: brightness(0.95); }

/* ---------- Switch (activo/inactivo) ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--color-border); border-radius: var(--radius-pill); transition: background var(--transition); cursor: pointer; }
.switch-track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform var(--transition); }
.switch input:checked + .switch-track { background: var(--color-primary); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* ---------- Formularios admin (secciones colapsables) ---------- */
.form-section { 
  margin-bottom: 1.25rem; 
  overflow: hidden; 
  transition: all var(--transition); 
  border-left: 4px solid transparent;
}
.form-section:hover { 
  box-shadow: var(--shadow-md);
  border-left-color: var(--color-primary);
}
.form-section[open] {
  border-left-color: var(--color-primary);
}
.form-section > summary {
  list-style: none; cursor: pointer; padding: 1.25rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 1rem;
  transition: background var(--transition);
}
.form-section > summary:hover {
  background: var(--color-primary-soft);
}
.form-section > summary::-webkit-details-marker { display: none; }
.form-section > summary::after { content: "\2303"; transform: rotate(180deg); color: var(--color-text-muted); transition: transform var(--transition); }
.form-section[open] > summary::after { transform: rotate(0deg); }
.form-section-body { padding: 0 1.5rem 1.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; }
.form-grid-full { grid-column: 1 / -1; }

.repeatable-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.9rem;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
}
.repeatable-remove { color: var(--color-danger); background: none; border: none; padding: 0.5rem; }

/* ---------- Drag & Drop File Area ---------- */
.file-drop-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 85px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  transition: all var(--transition);
  cursor: pointer;
  overflow: hidden;
  text-align: center;
}
.file-drop-area:hover, .file-drop-area.is-dragover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}
.file-msg {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  padding: 0.5rem;
  pointer-events: none;
}
.file-msg svg {
  width: 22px; height: 22px; margin-bottom: 0.25rem; color: var(--color-primary);
}
.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
  z-index: 2;
}
.file-preview {
  position: absolute;
  inset: 0;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.remove-file {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #fff;
  color: var(--color-danger);
  box-shadow: var(--shadow-soft);
  z-index: 4;
}

.admin-form-actions { 
  display: flex; 
  justify-content: flex-end; 
  gap: 0.75rem; 
  
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  padding: 1.25rem 1.75rem;
  margin: 1.5rem -1.75rem -1.75rem -1.75rem;
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -4px 15px rgba(0,0,0,0.03);
  z-index: 10;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .admin-content { padding: 1.1rem; }
  .repeatable-row { grid-template-columns: 1fr; }
}
