/* ============================================================
   UBBLY-TMS — Design System
   Paleta: Negro · Morado · Verde Lima   Tipografía: Poppins
   ============================================================ */

/* --- Variables de color --- */
:root {
  --black:        #0A0A0A;
  --black-2:      #111118;
  --black-3:      #1A1A26;
  --black-4:      #252535;
  --black-5:      #333348;
  --white:        #FFFFFF;
  --gray-100:     #F5F5F5;
  --gray-200:     #E5E5E5;
  --gray-400:     #9090A8;
  --gray-600:     #555568;

  /* Lima — acento principal */
  --lime:         #A3FF00;
  --lime-dark:    #7ACC00;
  --lime-bg:      #0D1A00;

  /* Morado — color de marca */
  --purple:       #9B5DE5;
  --purple-light: #C084FC;
  --purple-dark:  #7C3AED;
  --purple-mid:   #6B21A8;
  --purple-deep:  #3B0764;
  --purple-bg:    #1A0A2E;

  /* Semánticos */
  --green:        #22C55E;
  --green-dark:   #16A34A;
  --green-bg:     #052E16;
  --blue:         #60A5FA;
  --blue-dark:    #2563EB;
  --blue-bg:      #0F1F40;
  --amber:        #FBBF24;
  --amber-dark:   #D97706;
  --amber-bg:     #3D2A00;
  --red:          #F87171;
  --red-dark:     #DC2626;
  --red-bg:       #3D0A0A;

  /* Gradientes */
  --grad-bg:       radial-gradient(ellipse at 70% 0%, #2D0A5E 0%, #0A0A0A 60%);
  --grad-sidebar:  linear-gradient(180deg, #16102E 0%, #0A0A12 100%);
  --grad-card:     linear-gradient(135deg, #1A1A28 0%, #111118 100%);

  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 2px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.7);
  --shadow-lime: 0 0 24px rgba(163,255,0,0.25);
  --shadow-purple: 0 0 24px rgba(155,93,229,0.2);

  --font:        'Poppins', 'Segoe UI', system-ui, sans-serif;
  --transition:  0.18s ease;
}

/* --- Reset base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--black);
  color: var(--white);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--black-2); }
::-webkit-scrollbar-thumb { background: var(--purple-dark); border-radius: 3px; }

/* ============================================================
   LAYOUT ADMIN
   ============================================================ */
.admin-wrap {
  display: flex;
  min-height: 100vh;
  background: var(--grad-bg);
  background-attachment: fixed;
}

/* Sidebar */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--grad-sidebar);
  border-right: 1px solid var(--black-4);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 28px 36px 20px;
  border-bottom: 1px solid var(--black-4);
}
/* Marco de la imagen de portada del sidebar (logo de tienda subido por el
   usuario en tienda/perfil.php): degradado lima → morado, los dos colores
   de marca de Ubbly, con un halo sutil en vez de un borde plano. */
.sidebar-logo-frame {
  display: inline-block;
  padding: 3px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--lime), var(--purple));
  box-shadow: 0 6px 18px rgba(163, 255, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.06);
  margin-bottom: 6px;
}
.sidebar-logo-frame img {
  display: block;
  width: 64px;
  height: 56px;
  object-fit: cover;
  border-radius: 11px;
  background: var(--black-2);
}
.sidebar-nav { flex: 1; padding: 16px 22px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--black-4); color: var(--white); }
.sidebar-nav a.active {
  background: var(--lime);
  color: var(--black);
  font-weight: 700;
  box-shadow: var(--shadow-lime);
}
.sidebar-nav .nav-section {
  font-size: 10px;
  color: var(--black-5);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 16px 14px 6px;
  font-weight: 600;
}
.sidebar-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--black-4);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.sidebar-user .avatar {
  width: 34px; height: 34px;
  background: var(--purple-bg);
  border: 1px solid var(--purple-dark);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  color: var(--purple-light);
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }

/* Main content */
.main-content { flex: 1; overflow-x: hidden; display: flex; flex-direction: column; background: transparent; }
.topbar {
  height: 60px;
  background: rgba(17,17,24,0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--black-4);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 15px; font-weight: 700; flex: 1; }
.page-body { padding: 28px; flex: 1; }

/* ============================================================
   COMPONENTES UI
   ============================================================ */

/* Cards */
.card {
  background: var(--grad-card);
  border: 1px solid var(--black-4);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--black-5); }
.card-sm { padding: 16px 20px; border-radius: var(--radius); }

/* Metric cards */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card {
  background: var(--grad-card);
  border: 1px solid var(--black-4);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  background: radial-gradient(circle, rgba(155,93,229,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.metric-card .metric-label { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.metric-card .metric-value { font-size: 32px; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.metric-card .metric-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* Badges de estado */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.badge-gray    { background: var(--black-4); color: var(--gray-400); border: 1px solid var(--black-5); }
.badge-purple  { background: var(--purple-bg); color: var(--purple-light); border: 1px solid var(--purple-dark); }
.badge-blue    { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-dark); }
.badge-amber   { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-dark); }
.badge-green   { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-dark); }
.badge-red     { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-dark); }
.badge-lime    { background: var(--lime-bg); color: var(--lime); border: 1px solid var(--lime-dark); }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary  { background: var(--lime); color: var(--black); font-weight: 700; }
.btn-primary:hover { background: var(--lime-dark); box-shadow: var(--shadow-lime); }
.btn-danger   { background: var(--red); color: var(--white); }
.btn-danger:hover { background: var(--red-dark); }
.btn-success  { background: var(--green); color: var(--black); }
.btn-success:hover { background: var(--green-dark); }
.btn-purple   { background: var(--purple); color: var(--white); }
.btn-purple:hover { background: var(--purple-dark); box-shadow: var(--shadow-purple); }
.btn-ghost    { background: transparent; color: var(--gray-400); border: 1px solid var(--black-4); }
.btn-ghost:hover { background: var(--black-3); color: var(--white); border-color: var(--black-5); }
.btn-sm       { padding: 7px 14px; font-size: 12px; }
.btn-lg       { padding: 15px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-full     { width: 100%; justify-content: center; }

/* Tabla */
.table-wrap  { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--black-4); background: var(--black-2); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--black-3); }
th { padding: 12px 16px; text-align: left; font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; white-space: nowrap; }
td { padding: 14px 16px; font-size: 13px; border-top: 1px solid var(--black-4); }
tr:hover td { background: var(--black-3); }
.table-empty { padding: 40px; text-align: center; color: var(--gray-400); font-size: 14px; }

/* Formularios */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; color: var(--white); margin-bottom: 6px; font-weight: 500; letter-spacing: 0.3px; }
.form-section-block {
  padding: 18px 24px 4px;
  margin: 0 -24px 4px;
  border-radius: var(--radius-sm);
}
.form-section-block.bg-a { background: rgba(255, 255, 255, 0.01); }
.form-section-block.bg-b { background: rgba(255, 255, 255, 0.09); }
.form-section-block .form-section-title { margin-top: 0; }
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-light);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 24px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--black-4);
}
.form-section-title.section-toggle {
  cursor: pointer;
  display: flex;
  width: 100%;
  box-sizing: border-box;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  padding: 12px 16px;
  margin: 20px 0 0;
  border: 1px solid var(--green-dark);
  border-radius: var(--radius-sm);
  background: var(--green-bg);
  color: var(--green);
  font-size: 13px;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.form-section-title.section-toggle:hover {
  color: var(--lime);
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}
.form-section-title.section-toggle.open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.form-section-title.section-toggle .chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  font-size: 11px;
  line-height: 1;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.18);
  color: var(--green);
  transition: transform var(--transition), background var(--transition);
}
.form-section-title.section-toggle:hover .chevron { background: rgba(163, 255, 0, 0.25); color: var(--lime); }
.form-section-title.section-toggle.open .chevron { transform: rotate(180deg); }
.form-section-body {
  padding: 18px 16px 4px;
  margin-top: -1px;
  border: 1px solid var(--green-dark);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: rgba(34, 197, 94, 0.04);
}
.form-control {
  width: 100%;
  background: var(--black-3);
  border: 1px solid var(--white);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(155,93,229,0.15); }
.form-control::placeholder { color: var(--black-5); }
.form-control option { background: var(--black-3); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--black-5);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--lime); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--black); }

/* Alertas flash */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
  border-left: 3px solid;
}
.alert-success { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.alert-error   { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: var(--amber); }

/* Search box */
.search-box { position: relative; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.page-header p  { font-size: 13px; color: var(--gray-400); margin-top: 2px; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--black-4); margin: 20px 0; }

/* Checkbox custom */
.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition); }
.checkbox-row:hover { background: var(--black-3); }
.checkbox-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--lime); cursor: pointer; }

/* ============================================================
   PORTAL MENSAJERO (Mobile-first)
   ============================================================ */
.mob-wrap { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.mob-header {
  background: rgba(17,17,24,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--black-4);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.mob-body { flex: 1; padding: 20px 16px; }
.mob-footer { padding: 16px; border-top: 1px solid var(--black-4); }

/* Tarjeta de entrega */
.delivery-card {
  background: var(--grad-card);
  border: 1px solid var(--black-4);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: block;
}
.delivery-card:hover { border-color: var(--purple); box-shadow: var(--shadow-purple); }
.delivery-card .card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.delivery-card .tracking { font-size: 12px; color: var(--gray-400); font-weight: 600; letter-spacing: 1px; }
.delivery-card .address { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.delivery-card .client  { font-size: 13px; color: var(--gray-400); }

/* Boton de iniciar ruta */
.btn-route {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 20px;
  background: var(--lime);
  color: var(--black);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 18px;
  font-weight: 900;
  font-family: var(--font);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-lime);
  margin-bottom: 20px;
  text-decoration: none;
}
.btn-route:hover { background: var(--lime-dark); transform: translateY(-1px); }

/* Detalle de entrega */
.detail-row { display: flex; flex-direction: column; gap: 4px; padding: 14px 0; border-bottom: 1px solid var(--black-4); }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.detail-value { font-size: 15px; font-weight: 600; }

/* Botones de accion del mensajero */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.btn-confirm { background: var(--lime); color: var(--black); border: none; border-radius: var(--radius); padding: 18px; font-size: 15px; font-weight: 800; font-family: var(--font); cursor: pointer; transition: all var(--transition); }
.btn-confirm:hover { background: var(--lime-dark); box-shadow: var(--shadow-lime); }
.btn-confirm:disabled,
.btn-confirm:disabled:hover {
  background: var(--black-4);
  color: var(--gray-600);
  box-shadow: none !important;
  cursor: not-allowed;
}
.btn-report  { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); border-radius: var(--radius); padding: 18px; font-size: 15px; font-weight: 800; cursor: pointer; transition: all var(--transition); text-align: center; text-decoration: none; display: block; font-family: var(--font); }
.btn-report:hover { background: var(--red); color: var(--white); }

/* ============================================================
   TRACKING PUBLICO
   ============================================================ */
.tracking-wrap { max-width: 520px; margin: 0 auto; padding: 40px 20px; }
.tracking-header { text-align: center; margin-bottom: 40px; }
body.tracking-bg { background: radial-gradient(ellipse at top, #1e0a3c 0%, #0A0A0A 70%); }

/* Stepper */
.stepper { position: relative; padding-left: 28px; }
.stepper::before {
  content: '';
  position: absolute;
  left: 9px; top: 0; bottom: 0;
  width: 2px;
  background: var(--black-4);
}
.step { position: relative; margin-bottom: 28px; }
.step-dot {
  position: absolute;
  left: -28px; top: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--black-4);
  border: 2px solid var(--black-5);
  z-index: 1;
}
.step.active .step-dot   { background: var(--lime); border-color: var(--lime); box-shadow: 0 0 10px rgba(163,255,0,0.5); }
.step.done   .step-dot   { background: var(--purple); border-color: var(--purple); }
.step-title   { font-size: 15px; font-weight: 700; }
.step-sub     { font-size: 13px; color: var(--white); margin-top: 2px; line-height: 1.4; }
.step.inactive .step-title { color: var(--gray-600); }
.step.inactive .step-sub   { color: var(--gray-400); }
.step-time    { font-size: 11px; color: var(--gray-200); font-weight: 600; white-space: nowrap; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--grad-bg);
  background-attachment: fixed;
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: rgba(17,17,24,0.9);
  backdrop-filter: blur(20px);
  border: 1px solid var(--black-4);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(107,33,168,0.15);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.login-desc  { font-size: 13px; color: var(--gray-400); margin-bottom: 24px; text-align: center; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .admin-wrap { flex-direction: column; }
  .page-body { padding: 16px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 16px; }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   MAPA EN VIVO (Leaflet)
   ============================================================ */
.leaflet-popup-content-wrapper {
  background: var(--black-2) !important;
  border: 1px solid var(--black-4) !important;
  border-radius: var(--radius) !important;
  color: var(--white) !important;
  box-shadow: var(--shadow-lg) !important;
}
.leaflet-popup-tip { background: var(--black-2) !important; }
.leaflet-popup-content {
  color: var(--white) !important;
  font-family: var(--font) !important;
  font-size: 13px !important;
  margin: 12px 16px !important;
}
.leaflet-tile { filter: brightness(0.75) saturate(0.7) hue-rotate(240deg); }

/* Marcador UBBLY personalizado */
.ubbly-marker-wrap { position: relative; width: 48px; height: 58px; }
.ubbly-marker-icon {
  width: 48px; height: 48px;
  background: var(--lime);
  border-radius: 50%;
  border: 3px solid var(--black);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
  font-size: 20px; font-weight: 900;
  color: var(--black);
  box-shadow: var(--shadow-lime);
  letter-spacing: -1px;
  user-select: none;
}
.ubbly-marker-tail {
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 12px solid var(--lime);
  margin: 0 auto;
}
.ubbly-marker-pulse {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(163,255,0,0.1);
  animation: ubbly-pulse 2s infinite;
  pointer-events: none;
}
@keyframes ubbly-pulse {
  0%   { transform: translate(-50%,-50%) scale(0.8); opacity: 0.8; }
  100% { transform: translate(-50%,-50%) scale(1.7); opacity: 0; }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--gray-400); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.hidden { display: none; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   DASHBOARD — GRÁFICOS
   Paleta categórica validada (contraste + daltonismo) para los
   estados de pedido, distinta de los colores de --badge para no
   depender de una sola fuente de identidad. Ver dataviz skill.
   ============================================================ */
:root {
  --chart-pendiente:  #3987e5; /* azul */
  --chart-asignado:   #d95926; /* naranja */
  --chart-transito:   #199e70; /* aqua */
  --chart-novedad:    #c98500; /* amarillo/oro */
  --chart-entregado:  #008300; /* verde */
  --chart-fallido:    #e66767; /* rojo */
  --chart-anulado:    #9085e9; /* violeta */

  --chart-status-good:     #0ca30c;
  --chart-status-warning:  #fab219;
  --chart-status-critical: #d03b3b;

  --chart-grid:   var(--black-5);
  --chart-axis:   var(--gray-600);
}

.dash-chart-card { margin-bottom: 24px; }
.dash-chart-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.dash-chart-sub { font-size: 12px; color: var(--gray-400); margin-bottom: 16px; }

/* --- Barra apilada (parte-todo) --- */
.stackbar {
  display: flex;
  width: 100%;
  height: 30px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--black-4);
}
.stackbar-seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  margin-right: 2px;
  transition: filter var(--transition);
}
.stackbar-seg:last-child { margin-right: 0; }
.stackbar-seg:hover { filter: brightness(1.15); }

/* --- Leyenda (siempre presente para 2+ series) --- */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 14px;
}
.chart-legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--gray-400); }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.chart-legend-item strong { color: var(--white); font-weight: 700; }

/* --- Tabla de datos accesible (gemela de cada gráfico) --- */
.chart-table-toggle { margin-top: 12px; }
.chart-table-toggle summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 600;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-table-toggle summary::-webkit-details-marker { display: none; }
.chart-table-toggle summary::before { content: '▸'; transition: transform var(--transition); font-size: 10px; }
.chart-table-toggle[open] summary::before { transform: rotate(90deg); }
.chart-table-toggle table { margin-top: 10px; width: 100%; border-collapse: collapse; }
.chart-table-toggle th, .chart-table-toggle td { padding: 6px 10px; font-size: 12px; text-align: left; border-bottom: 1px solid var(--black-4); }
.chart-table-toggle th { color: var(--gray-400); font-weight: 600; }

/* --- Meter (razón contra un límite, p.ej. tasa de éxito) --- */
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row-compact .meter-track { height: 6px; }
.meter-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--black-5);
  overflow: hidden;
}
.meter-fill { height: 100%; border-radius: 999px; transition: width var(--transition); }
.meter-value { font-size: 13px; font-weight: 800; min-width: 46px; text-align: right; }

/* --- Gráfico de tendencia (SVG generado en servidor) --- */
.trend-chart-wrap { width: 100%; overflow-x: auto; }
.trend-chart-wrap svg { width: 100%; height: auto; display: block; }
.trend-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-area { opacity: 0.10; }
.trend-dot { stroke-width: 2; }
.trend-gridline { stroke: var(--chart-grid); stroke-width: 1; }
.trend-axis-label { fill: var(--gray-400); font-size: 10px; font-family: var(--font); }
.trend-end-label { font-size: 11px; font-weight: 700; font-family: var(--font); }

/* --- Estado vacío de un gráfico --- */
.dash-chart-empty {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  padding: 24px;
  background: var(--black-3);
  border-radius: var(--radius);
  border: 1px solid var(--black-4);
}

/* ============================================================
   SUBIDA DE EVIDENCIA FOTOGRÁFICA (portal mensajero)
   Reemplaza el <input type="file"> nativo por tarjetas
   "Subir evidencia 1 / 2" con preview integrado.
   ============================================================ */
.evidencia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.evidencia-slot {
  position: relative;
  display: block;
  min-height: 158px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--black-3);
  border: 2px dashed var(--black-5);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.evidencia-slot:hover,
.evidencia-slot:focus-within {
  border-color: var(--lime);
  background: var(--black-4);
  box-shadow: var(--shadow-lime);
}
/* El input real queda invisible pero cubriendo toda la tarjeta */
.evidencia-slot input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

/* --- Estado vacío --- */
.evidencia-slot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 158px;
  padding: 18px 12px;
  text-align: center;
}
.evidencia-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--lime);
  background: rgba(163, 255, 0, 0.10);
  border: 1px solid rgba(163, 255, 0, 0.30);
  transition: background var(--transition), transform var(--transition);
}
.evidencia-slot:hover .evidencia-icon { background: rgba(163, 255, 0, 0.20); transform: translateY(-2px); }
.evidencia-icon svg { width: 22px; height: 22px; display: block; }
.evidencia-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.2px;
  line-height: 1.2;
}
.evidencia-hint { font-size: 11px; color: var(--gray-400); line-height: 1.35; }

/* --- Estado: foto cargada --- */
.evidencia-preview {
  display: none;
  width: 100%;
  height: 158px;
  object-fit: cover;
}
.evidencia-slot.has-file {
  border-style: solid;
  border-color: var(--lime);
  background: var(--black-2);
}
.evidencia-slot.has-file .evidencia-slot-inner { display: none; }
.evidencia-slot.has-file .evidencia-preview { display: block; }

.evidencia-ok {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--black);
  font-size: 14px;
  font-weight: 900;
  box-shadow: var(--shadow-lime);
}
.evidencia-slot.has-file .evidencia-ok { display: flex; }

.evidencia-file {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10,10,10,0) 0%, rgba(10,10,10,0.92) 55%);
}
.evidencia-slot.has-file .evidencia-file { display: flex; }
.evidencia-file-name {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.evidencia-remove {
  pointer-events: auto;
  flex-shrink: 0;
  padding: 4px 11px;
  border: none;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
}
.evidencia-remove:hover { background: var(--red-dark); }

/* --- Estado: error de validación --- */
.evidencia-slot.has-error {
  border-style: solid;
  border-color: var(--red);
  background: var(--red-bg);
}
.evidencia-slot.has-error .evidencia-icon {
  color: var(--red);
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
}
.evidencia-error {
  display: none;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--red);
}

/* --- Barra de progreso dentro de la tarjeta (lectura de la foto) --- */
.evidencia-progress {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  display: none;
  height: 6px;
  border-radius: 999px;
  background: var(--black-5);
  overflow: hidden;
}
.evidencia-slot.is-loading .evidencia-progress { display: block; }
.evidencia-progress-bar {
  display: block; /* es un <span>: sin esto el width no aplica */
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--lime);
  transition: width 0.12s linear;
}
.evidencia-slot.is-loading {
  border-style: solid;
  border-color: var(--lime);
}
.evidencia-slot.is-loading .evidencia-icon {
  animation: evidencia-pulso 1s ease-in-out infinite;
}
@keyframes evidencia-pulso {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ============================================================
   OVERLAY DE SUBIDA — "Espere, estamos subiendo las imágenes"
   Ver assets/upload_overlay.php
   ============================================================ */
body.upload-locked { overflow: hidden; }

.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 28px;
  text-align: center;
  background: rgba(10, 10, 10, 0.94);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.upload-overlay.is-open { display: flex; }

.upload-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid var(--black-4);
  border-top-color: var(--lime);
  animation: upload-spin 0.8s linear infinite;
}
@keyframes upload-spin { to { transform: rotate(360deg); } }

.upload-overlay-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--white);
  max-width: 300px;
}
.upload-pct {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  color: var(--lime);
  letter-spacing: 0.5px;
}
.upload-bar {
  width: 100%;
  max-width: 290px;
  height: 10px;
  border-radius: 999px;
  background: var(--black-4);
  border: 1px solid var(--black-5);
  overflow: hidden;
}
.upload-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--lime-dark), var(--lime));
  transition: width 0.2s ease;
}
.upload-detail { font-size: 12px; color: var(--gray-200); }
.upload-overlay-sub {
  font-size: 12px;
  line-height: 1.45;
  color: var(--gray-400);
  max-width: 280px;
}

/* Respeta a quien pidió menos animación en el sistema */
@media (prefers-reduced-motion: reduce) {
  .upload-spinner { animation-duration: 2.4s; }
  .evidencia-slot.is-loading .evidencia-icon { animation: none; }
}

/* ── Campo de contraseña con botón Ver / Ocultar ── */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 76px; }
.pw-toggle {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  background: transparent; border: 0; cursor: pointer;
  color: var(--purple-light); font: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 8px; border-radius: 6px;
}
.pw-toggle:hover { color: var(--white, #fff); }
.pw-toggle:focus-visible { outline: 2px solid var(--purple); }

/* ============================================================
   TEMA CLARO — se activa con <html data-theme="light"> (ver
   assets/js/theme.js). Reasigna la misma paleta: "black" pasa a ser
   el fondo claro y "white" el texto oscuro, así que todo el CSS y los
   estilos en línea existentes siguen funcionando sin cambios.
   ============================================================ */
html[data-theme="light"] {
  color-scheme: light;
  --black:   #F4F4F8;
  --black-2: #FFFFFF;
  --black-3: #F0EFF6;
  --black-4: #DDDBE8;
  --black-5: #C2BFD3;
  --white:   #16151F;
  --gray-100: #2A2938;
  --gray-200: #3A3950;
  --gray-400: #5F5D73;
  --gray-600: #8B8AA0;

  /* En tema claro el acento "lima" pasa a ser el morado de marca */
  --lime:        #7C3AED;
  --lime-dark:   #6D28D9;
  --lime-bg:     #F3E8FF;
  --purple:      #7C3AED;
  --purple-light:#6D28D9;
  --purple-dark: #6D28D9;
  --purple-bg:   #F3E8FF;
  --green:       #15803D;
  --green-dark:  #166534;
  --green-bg:    #DCFCE7;
  --blue:        #1D4ED8;
  --blue-dark:   #1E40AF;
  --blue-bg:     #DBEAFE;
  --amber:       #B45309;
  --amber-dark:  #D97706;
  --amber-bg:    #FEF3C7;
  --red:         #B91C1C;
  --red-dark:    #991B1B;
  --red-bg:      #FEE2E2;

  --grad-bg:      radial-gradient(ellipse at 70% 0%, #E9DDFB 0%, #F4F4F8 60%);
  --grad-sidebar: linear-gradient(180deg, #FFFFFF 0%, #F1EFF8 100%);
  --grad-card:    linear-gradient(135deg, #FFFFFF 0%, #FAF9FD 100%);

  --shadow:        0 2px 16px rgba(30,20,60,0.10);
  --shadow-lg:     0 8px 40px rgba(30,20,60,0.18);
  --shadow-lime:   0 0 18px rgba(124,58,237,0.22);
  --shadow-purple: 0 0 18px rgba(124,58,237,0.18);
}
html[data-theme="light"] .topbar,
html[data-theme="light"] .mob-header { background: rgba(255,255,255,0.92); }
html[data-theme="light"] .form-section-block.bg-a { background: rgba(0,0,0,0.015); }
html[data-theme="light"] .form-section-block.bg-b { background: rgba(124,58,237,0.05); }
html[data-theme="light"] .form-control { border-color: var(--black-5); }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--black-5); }

/* Elementos con fondo de acento: el texto vuelve a ser blanco fijo */
html[data-theme="light"] .btn-primary,
html[data-theme="light"] .btn-success,
html[data-theme="light"] .btn-danger,
html[data-theme="light"] .btn-purple,
html[data-theme="light"] .btn-confirm,
html[data-theme="light"] .btn-route,
html[data-theme="light"] .btn-report:hover,
html[data-theme="light"] .sidebar-nav a.active,
html[data-theme="light"] .evidencia-remove,
html[data-theme="light"] .step.active .step-dot { --black: #FFFFFF; --white: #FFFFFF; }

/* Componentes sobre fondo oscuro fijo (fotos, overlays): conservan la paleta oscura */
html[data-theme="light"] .seg-lightbox,
html[data-theme="light"] .upload-overlay,
html[data-theme="light"] .evidencia-file {
  --black-3: #1A1A26; --black-4: #252535; --white: #FFFFFF; --gray-400: #9090A8;
}
html[data-theme="light"] .toggle-slider::before,
html[data-theme="light"] .toggle input:checked + .toggle-slider::before { background: #FFFFFF; }

/* Botón de cambio de tema (barra lateral) */
.theme-toggle { margin-bottom: 8px; }
html[data-theme="light"] .login-box { background: rgba(255,255,255,0.92); box-shadow: var(--shadow-lg), 0 0 60px rgba(124,58,237,0.10); }
/* Logo de Ubbly: en tema claro se cambia el logo blanco por el morado (assets/img/logo_light.png) */
.logo-light { display: none !important; }
html[data-theme="light"] .logo-dark { display: none !important; }
html[data-theme="light"] .logo-light { display: block !important; }
.login-logo .logo-light, .login-logo .logo-dark { margin-left: auto; margin-right: auto; }
html[data-theme="light"] .btn-success { background: var(--purple); }
html[data-theme="light"] .btn-success:hover { background: var(--purple-dark); }

/* Insignia naranja (semáforo de recompra: "última llamada") */
.badge-orange { background: rgba(249,115,22,0.15); color: #FB923C; border: 1px solid #EA580C; }
html[data-theme="light"] .badge-orange { background: #FFEDD5; color: #C2410C; border-color: #FB923C; }

/* --- Señal "En vivo": punto rojo que titila --- */
.live-indicator {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase;
  color: #EF4444;
}
.live-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #EF4444;
  animation: live-blink 1.2s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { opacity: 1;    box-shadow: 0 0 0 0 rgba(239,68,68,0.7); }
  50%      { opacity: 0.35; box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* --- Gráfico de torta (pedidos por estado) --- */
.pie-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.pie-svg { width: 190px; height: 190px; flex-shrink: 0; }
.pie-svg path, .pie-svg circle.pie-slice { stroke: var(--black-2); stroke-width: 2; transition: filter var(--transition); }
.pie-svg path:hover, .pie-svg circle.pie-slice:hover { filter: brightness(1.15); }
.pie-svg text { font-size: 11px; font-weight: 700; pointer-events: none; }
.pie-wrap .chart-legend { flex: 1; min-width: 170px; flex-direction: column; align-items: flex-start; gap: 8px; }

/* --- Recompra: total por tier clicable + ventana con la lista de clientes --- */
.rc-count-btn {
  background: none; border: 0; cursor: pointer; font: inherit; font-size: 20px; font-weight: 700;
  color: var(--purple-light); text-decoration: underline; text-underline-offset: 3px; padding: 0;
}
.rc-count-btn:hover { color: var(--white); }
.rc-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(5,5,8,0.7); display: flex; align-items: center; justify-content: center; padding: 20px; }
.rc-modal[hidden] { display: none; }
.rc-modal-box { background: var(--black-2); border: 1px solid var(--black-4); border-radius: var(--radius-lg); width: min(980px, 100%); max-height: 88vh; display: flex; flex-direction: column; padding: 20px; box-shadow: var(--shadow-lg); }
.rc-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.rc-modal-buscar { margin-bottom: 12px; }
.rc-modal-body { overflow: auto; border: 1px solid var(--black-4); border-radius: var(--radius); }
.rc-modal-body table { width: 100%; border-collapse: collapse; }
.rc-modal-body th, .rc-modal-body td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--black-4); vertical-align: top; }
.rc-modal-body th { position: sticky; top: 0; background: var(--black-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-400); }
.rc-fechas { display: flex; flex-wrap: wrap; gap: 4px; max-width: 320px; }
.rc-fecha { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--black-4); color: var(--gray-400); white-space: nowrap; }

/* ============================================================
   UBBLY BOT — mascota (ver assets/ubbly_bot.php)
   ============================================================ */
.ub-bot { display: block; flex-shrink: 0; animation: ub-flota 3.2s ease-in-out infinite; }
.ub-bot-ojo { transform-box: fill-box; transform-origin: center; animation: ub-parpadeo 4.5s infinite; }
.ub-bot-wave { transform-box: fill-box; transform-origin: 20% 90%; animation: ub-saluda 1.5s ease-in-out infinite; }
.ub-bot-gear { animation: ub-gira 6s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ub-flota { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes ub-parpadeo { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes ub-saluda { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-18deg); } }
@keyframes ub-gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ub-bot, .ub-bot-ojo, .ub-bot-wave, .ub-bot-gear { animation: none; } }

/* Nube de texto en movimiento: todo lo que "dice" la mascota sale aquí */
.ub-bot-fila { display: flex; align-items: center; gap: 6px; }
.ub-nube-wrap { position: relative; margin-left: 14px; max-width: 420px; }
.ub-nube {
  position: relative;
  background: var(--black-3);
  border-radius: 38px 42px 36px 44px / 34px 38px 40px 34px;
  padding: 14px 24px;
  font-size: 13px; line-height: 1.5; color: var(--white);
  /* Contorno de 1 px que sigue la silueta completa de la nube (cuerpo + bultos) y un halo suave */
  filter: drop-shadow(1px 0 0 var(--purple-dark)) drop-shadow(-1px 0 0 var(--purple-dark))
          drop-shadow(0 1px 0 var(--purple-dark)) drop-shadow(0 -1px 0 var(--purple-dark))
          drop-shadow(0 8px 14px rgba(124, 58, 237, 0.22));
  animation: ub-nube-mueve 7s ease-in-out infinite;
}
/* "Bultos" de la nube: círculos del mismo color que se funden con el cuerpo */
.ub-nube::before, .ub-nube::after {
  content: ''; position: absolute; background: var(--black-3); border-radius: 50%; z-index: -1;
}
.ub-nube::before { width: 38px; height: 38px; top: -16px; left: 26px; }
.ub-nube::after  { width: 30px; height: 30px; top: -12px; right: 36px; }
.ub-nube strong { color: var(--purple-light); }
/* Cola: dos circulitos que bajan hacia el bot (como una nube de pensamiento) */
.ub-nube-pt { position: absolute; background: var(--black-3); border: 1px solid var(--purple-dark); border-radius: 50%; animation: ub-nube-mueve 7s ease-in-out infinite; }
.ub-nube-pt1 { width: 12px; height: 12px; left: -12px; top: 58%; }
.ub-nube-pt2 { width: 7px;  height: 7px;  left: -22px; top: 74%; animation-delay: -1.2s; }
/* Variante: la cola apunta hacia arriba (bot encima de la nube) */
.ub-nube-arriba { margin: 14px 0 0; max-width: none; }
.ub-nube-arriba .ub-nube-pt1 { left: 50%; top: -22px; margin-left: -6px; }
.ub-nube-arriba .ub-nube-pt2 { left: 50%; top: -34px; margin-left: -3px; }
@keyframes ub-nube-mueve {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(5px, -4px); }
  50%      { transform: translate(0, -7px); }
  75%      { transform: translate(-5px, -3px); }
}
@media (prefers-reduced-motion: reduce) { .ub-nube, .ub-nube-pt { animation: none; } }

/* Login: el bot saluda debajo del logo */
.login-bot { display: flex; justify-content: center; margin: -4px 0 14px; }

/* Sección "Próximamente": contenido desenfocado + mascota por encima */
.cs-wrap { position: relative; min-height: 420px; }
.cs-blur { filter: blur(7px); opacity: .75; pointer-events: none; user-select: none; -webkit-user-select: none; }
.cs-overlay {
  position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 90px;
}
.cs-card { text-align: center; max-width: 420px; position: sticky; top: 90px; }
.cs-card .ub-bot { margin: 0 auto; }
.cs-card .ub-nube { background: var(--black-2); padding: 22px 30px; }
.cs-card .ub-nube::before, .cs-card .ub-nube::after { background: var(--black-2); }
.cs-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.cs-card p { font-size: 13.5px; line-height: 1.55; color: var(--gray-400); }

/* ============================================================
   EN VIVO — campanita, avisos y regiones que se actualizan solas
   (ver assets/campana.php y assets/js/live.js)
   ============================================================ */
.ub-bell { position: relative; }
.ub-bell-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  background: transparent; border: 1px solid var(--black-4); color: var(--gray-400);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.ub-bell-btn:hover { background: var(--black-3); color: var(--white); }
.ub-bell-activa { color: var(--purple-light); border-color: var(--purple); }
.ub-bell-activa svg { animation: ub-campana 1.6s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes ub-campana { 0%, 60%, 100% { transform: rotate(0); } 10% { transform: rotate(14deg); } 20% { transform: rotate(-12deg); } 30% { transform: rotate(8deg); } 40% { transform: rotate(-5deg); } }
.ub-bell-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: #EF4444; color: #fff; font-size: 10px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.ub-bell-badge[hidden] { display: none; }
.ub-bell-panel {
  position: absolute; right: 0; top: 46px; width: 340px; max-width: calc(100vw - 24px); z-index: 200;
  background: var(--black-2); border: 1px solid var(--black-4); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ub-bell-panel[hidden] { display: none; }
.ub-bell-cab { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--black-4); font-size: 13px; }
.ub-bell-marcar { background: none; border: 0; cursor: pointer; color: var(--purple-light); font: inherit; font-size: 12px; font-weight: 600; }
.ub-bell-lista { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.ub-bell-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--black-4); }
.ub-bell-item:last-child { border-bottom: 0; }
.ub-bell-nuevo { background: rgba(124, 58, 237, 0.10); }
.ub-bell-txt { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; line-height: 1.4; color: var(--white); min-width: 0; }
.ub-bell-sub { font-size: 11px; color: var(--gray-400); }
.ub-bell-punto { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.ub-bell-vacio { padding: 22px 16px; font-size: 12.5px; color: var(--gray-400); text-align: center; }
.ub-tono-morado { background: var(--purple); } .ub-tono-verde { background: var(--green); }
.ub-tono-amarillo { background: var(--amber); } .ub-tono-rojo { background: var(--red); }

.ub-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.ub-toast {
  background: var(--black-2); color: var(--white); border: 1px solid var(--black-4); border-left: 4px solid var(--purple);
  border-radius: var(--radius); padding: 10px 14px; font-size: 12.5px; line-height: 1.4; box-shadow: var(--shadow-lg);
  animation: ub-toast-entra .3s ease; transition: opacity .35s, transform .35s;
}
.ub-toast-sale { opacity: 0; transform: translateX(20px); }
.ub-tono-borde-verde { border-left-color: var(--green); } .ub-tono-borde-amarillo { border-left-color: var(--amber); }
.ub-tono-borde-rojo { border-left-color: var(--red); }
@keyframes ub-toast-entra { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* La región que se acaba de actualizar parpadea una vez para que se note */
.ub-live-pulso { animation: ub-pulso .9s ease; }
@keyframes ub-pulso { 0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, .45); } 100% { box-shadow: 0 0 0 14px rgba(124, 58, 237, 0); } }
.ub-live-ts { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--gray-400); margin-left: 6px; }
@media (prefers-reduced-motion: reduce) { .ub-bell-activa svg, .ub-live-pulso, .ub-toast { animation: none; } }

/* ============================================================
   UBBLY BOT FLOTANTE — botón + conversación (assets/ubbly_asistente.php)
   ============================================================ */
.ub-asist { position: fixed; right: 20px; bottom: 20px; z-index: 1900; }
.ub-asist-fab {
  width: 64px; height: 64px; border-radius: 50%; padding: 0; cursor: pointer; border: 2px solid var(--purple);
  background: var(--black-2); display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
  box-shadow: 0 8px 24px rgba(109, 40, 217, .4); transition: transform var(--transition), box-shadow var(--transition);
}
.ub-asist-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgba(109, 40, 217, .55); }
.ub-asist-fab .ub-bot { width: 54px; height: 54px; margin-bottom: -4px; }
.ub-asist-fab.ub-asist-abierto { border-color: var(--purple-light); }
.ub-asist-panel {
  position: absolute; right: 0; bottom: 78px; width: 350px; max-width: calc(100vw - 32px);
  height: 460px; max-height: calc(100vh - 130px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--black-2); border: 1px solid var(--black-4); border-radius: 18px; box-shadow: var(--shadow-lg);
  animation: ub-asist-sube .22s ease;
}
.ub-asist-panel[hidden] { display: none; }
@keyframes ub-asist-sube { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.ub-asist-cab { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: linear-gradient(135deg, var(--purple), var(--purple-dark)); color: #fff; }
.ub-asist-av { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.16); border: 1.5px solid rgba(255,255,255,.35); display: flex; align-items: flex-end; justify-content: center; overflow: hidden; flex-shrink: 0; }
.ub-asist-av .ub-bot { animation: none; width: 40px; height: 40px; margin-bottom: -3px; }
.ub-asist-tit { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ub-asist-tit b { font-size: 14px; font-weight: 700; }
.ub-asist-tit small { font-size: 11.5px; color: rgba(255,255,255,.8); }
.ub-asist-cerrar { background: transparent; border: none; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.ub-asist-cerrar:hover { background: rgba(255,255,255,.15); }
.ub-asist-msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; background: var(--black); }
.ub-asist-msg { display: flex; }
.ub-asist-bot { justify-content: flex-start; }
.ub-asist-user { justify-content: flex-end; }
.ub-asist-burb { max-width: 88%; padding: 9px 13px; border-radius: 16px; font-size: 13px; line-height: 1.45; word-break: break-word; }
.ub-asist-bot .ub-asist-burb { background: var(--black-3); border: 1px solid var(--purple-dark); color: var(--white); border-bottom-left-radius: 5px; }
.ub-asist-bot .ub-asist-burb strong { color: var(--purple-light); }
.ub-asist-user .ub-asist-burb { background: var(--purple-dark); color: #fff; border-bottom-right-radius: 5px; }
.ub-asist-ops { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ub-asist-op { text-align: left; background: var(--black-2); border: 1px solid var(--black-5); border-radius: 10px; padding: 7px 10px; cursor: pointer; color: var(--white); font-family: var(--font); display: flex; flex-direction: column; gap: 1px; }
.ub-asist-op span { font-size: 11.5px; color: var(--gray-400); }
.ub-asist-op:hover { border-color: var(--purple); }
.ub-asist-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--black-4); background: var(--black-2); }
.ub-asist-form input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--black-5); background: var(--black-3); color: var(--white); font-family: var(--font); font-size: 16px; }
.ub-asist-form input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(155,93,229,.15); }
.ub-asist-form button { flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, var(--purple), var(--purple-dark)); box-shadow: 0 4px 12px rgba(109,40,217,.35); }
.ub-asist-form button:hover { filter: brightness(1.1); }
/* Los avisos breves suben para no tapar el botón del bot */
.ub-toasts { bottom: 98px; }
@media (max-width: 600px) {
  .ub-asist { right: 14px; bottom: 14px; }
  .ub-asist-panel { position: fixed; right: 10px; left: 10px; bottom: 90px; width: auto; max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .ub-asist-panel { animation: none; } }
