/* ==========================================================================
   SISTEMA DE INDICADORES DE CARGA
   Diseñado con la identidad visual nativa de la app (Azul Eléctrico / Verde / Slate)
   ========================================================================== */

:root {
  --loader-accent: #1f5bff;
  --loader-accent-rgb: 31, 91, 255;
  --loader-shimmer-base: #e2e8f0;
  --loader-shimmer-wave: #ffffff;
  --loader-border: rgba(31, 91, 255, 0.12);
  --loader-text: #0f172a;
  --loader-muted: #64748b;
  --loader-card-bg: #ffffff;
  --loader-card-border: #e2e8f0;
  --loader-card-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.admin-dark-mode,
body[data-page="reservas"],
body:not([data-page="admin"]):not([data-theme="light"]):not([data-page="barbero"]) {
  --loader-accent: #1f5bff;
  --loader-accent-rgb: 31, 91, 255;
  --loader-shimmer-base: rgba(255, 255, 255, 0.08);
  --loader-shimmer-wave: rgba(255, 255, 255, 0.22);
  --loader-border: rgba(255, 255, 255, 0.08);
  --loader-text: #f8fafc;
  --loader-muted: #94a3b8;
  --loader-card-bg: #17181d;
  --loader-card-border: rgba(255, 255, 255, 0.08);
  --loader-card-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* 1. SPINNER LOADER */
.ui-spinner {
  display: inline-block;
  vertical-align: middle;
  border-radius: 50%;
  border-style: solid;
  border-color: rgba(var(--loader-accent-rgb), 0.2);
  border-top-color: var(--loader-accent);
  animation: ui-spin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  box-sizing: border-box;
  flex-shrink: 0;
}

.ui-spinner--sm {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

.ui-spinner--md {
  width: 22px;
  height: 22px;
  border-width: 2.5px;
}

.ui-spinner--lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.ui-spinner--white {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
}

.ui-spinner--green {
  border-color: rgba(34, 197, 94, 0.2);
  border-top-color: #22c55e;
}

@keyframes ui-spin {
  to { transform: rotate(360deg); }
}

/* 2 & 8. SKELETON LOADER & SHIMMER */
.ui-skeleton,
.ui-shimmer {
  position: relative;
  overflow: hidden;
  background-color: var(--loader-shimmer-base);
  border-radius: 8px;
  display: inline-block;
  vertical-align: middle;
  box-sizing: border-box;
}

.ui-skeleton--shimmer,
.ui-shimmer {
  background: linear-gradient(
    90deg,
    var(--loader-shimmer-base) 0%,
    var(--loader-shimmer-wave) 50%,
    var(--loader-shimmer-base) 100%
  );
  background-size: 200% 100%;
  animation: ui-shimmer-wave 1.6s ease-in-out infinite;
}

@keyframes ui-shimmer-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ui-skeleton-text {
  height: 13px;
  width: 100%;
  margin: 4px 0;
  border-radius: 4px;
}

.ui-skeleton-title {
  height: 18px;
  width: 55%;
  margin: 5px 0;
  border-radius: 6px;
}

.ui-skeleton-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ui-skeleton-badge {
  height: 22px;
  width: 76px;
  border-radius: 12px;
}

.ui-skeleton-chip {
  height: 36px;
  width: 76px;
  border-radius: 8px;
}

/* Card Skeletons */
.ui-skeleton-reserva-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--loader-card-bg);
  border: 1px solid var(--loader-card-border);
  border-radius: 14px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.ui-skeleton-reserva-card .col-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ui-skeleton-barbero-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--loader-card-bg);
  border: 1px solid var(--loader-card-border);
  border-radius: 14px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.ui-skeleton-barbero-card .col-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ui-skeleton-cierre-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--loader-card-bg);
  border: 1px solid var(--loader-card-border);
  border-radius: 12px;
  margin-bottom: 8px;
}

.ui-skeleton-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.ui-skeleton-stat-card {
  padding: 16px;
  background: var(--loader-card-bg);
  border: 1px solid var(--loader-card-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ui-skeleton-agenda-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--loader-card-bg);
  border: 1px solid var(--loader-card-border);
  border-radius: 16px;
}

.ui-skeleton-agenda-header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.ui-skeleton-agenda-cols {
  display: grid;
  grid-template-columns: 70px repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.ui-skeleton-agenda-slot {
  height: 60px;
  border-radius: 8px;
}

/* 3. PROGRESS BAR */
.ui-progress-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-sizing: border-box;
}

.ui-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--loader-text);
}

.ui-progress-pct {
  font-variant-numeric: tabular-nums;
  color: var(--loader-accent);
}

.ui-progress-track {
  width: 100%;
  height: 6px;
  background: var(--loader-shimmer-base);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.ui-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1f5bff, #3b82f6);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 0 10px rgba(31, 91, 255, 0.35);
}

/* 4. CIRCULAR PROGRESS */
.ui-circular-progress {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-sizing: border-box;
}

.ui-circular-progress__svg {
  transform: rotate(-90deg);
  overflow: visible;
}

.ui-circular-progress__track {
  stroke: var(--loader-shimmer-base);
  fill: none;
}

.ui-circular-progress__fill {
  stroke: var(--loader-accent);
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.ui-circular-progress__content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}

.ui-circular-progress__value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--loader-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ui-circular-progress__sub {
  font-size: 0.7rem;
  color: var(--loader-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* 5. DOTS / PULSING DOTS */
.ui-dots-loader {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
  padding: 0 3px;
}

.ui-dots-loader span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--loader-accent);
  display: inline-block;
  animation: ui-dots-pulse 1.3s infinite ease-in-out both;
}

.ui-dots-loader span:nth-child(1) { animation-delay: -0.32s; }
.ui-dots-loader span:nth-child(2) { animation-delay: -0.16s; }
.ui-dots-loader span:nth-child(3) { animation-delay: 0s; }

.ui-dots-loader--sm span { width: 3.5px; height: 3.5px; }
.ui-dots-loader--white span { background-color: #ffffff; }

@keyframes ui-dots-pulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.35; }
  40% { transform: scale(1.1); opacity: 1; }
}

.ui-loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--loader-muted);
  font-size: 0.85rem;
}

/* 6. BUTTON LOADER */
.ui-btn-loading {
  position: relative !important;
  pointer-events: none !important;
  cursor: not-allowed !important;
  opacity: 0.88 !important;
}

.ui-btn-loading-content {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
}

.ui-btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: ui-spin 0.65s linear infinite;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

button.secondary .ui-btn-spinner,
button.cf-btn--ghost .ui-btn-spinner,
button.br-btn--ghost .ui-btn-spinner,
button.sv-btn--ghost .ui-btn-spinner {
  border-color: rgba(var(--loader-accent-rgb), 0.25);
  border-top-color: var(--loader-accent);
}

/* ═══════════════════════════════════════════════════════════════
   PULL-TO-REFRESH INDICATOR (Móvil nativo)
   ═══════════════════════════════════════════════════════════════ */
.ptr-indicator {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-90px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: var(--loader-card-bg, #ffffff);
  border: 1px solid var(--loader-card-border, #e2e8f0);
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  box-sizing: border-box;
}

.ptr-indicator .ui-spinner {
  width: 20px;
  height: 20px;
  border-width: 2.5px;
}

.admin-dark-mode .ptr-indicator {
  background: #1e2029;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

@media (min-width: 769px) {
  .ptr-indicator {
    display: none !important;
  }
}

/* Skeleton adicional para Clientes y Perfil */
.ui-skeleton-client-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--loader-card-bg, #ffffff);
  border: 1px solid var(--loader-card-border, #e2e8f0);
  border-radius: 14px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.ui-skeleton-profile-card {
  padding: 20px;
  background: var(--loader-card-bg, #ffffff);
  border: 1px solid var(--loader-card-border, #e2e8f0);
  border-radius: 16px;
  box-sizing: border-box;
  margin-bottom: 16px;
}

.admin-dark-mode .stats-metric-card {
  background: #293646 !important;
  border-color: #405267 !important;
}

.admin-dark-mode .ui-skeleton-client-card, 
.admin-dark-mode .ui-skeleton-profile-card {
  background: #17181d;
  border-color: rgba(255, 255, 255, 0.08);
}

/* Fade suave al montar contenido real */
.section-entering {
  animation: section-fade-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD INICIO SKELETON STATE (Nunca se traba ni rompe eventos)
   ═══════════════════════════════════════════════════════════════ */
.dh.dh--skeleton .dh-hero__title,
.dh.dh--skeleton .dh-hero__text,
.dh.dh--skeleton .dh-chip,
.dh.dh--skeleton .dh-profile__name,
.dh.dh--skeleton .dh-tag,
.dh.dh--skeleton .dh-stat__value,
.dh.dh--skeleton .dh-stat__label {
  color: transparent !important;
  border-color: transparent !important;
  background-color: var(--loader-shimmer-base) !important;
  background: linear-gradient(
    90deg,
    var(--loader-shimmer-base) 0%,
    var(--loader-shimmer-wave) 50%,
    var(--loader-shimmer-base) 100%
  ) !important;
  background-size: 200% 100% !important;
  animation: ui-shimmer-wave 1.4s ease-in-out infinite !important;
  border-radius: 6px !important;
  pointer-events: none !important;
  user-select: none !important;
}

.dh.dh--skeleton .dh-hero__title {
  display: inline-block;
  min-width: 180px;
  min-height: 26px;
}

.dh.dh--skeleton .dh-hero__text {
  display: inline-block;
  min-width: 240px;
  min-height: 14px;
}

.dh.dh--skeleton .dh-stat__value {
  display: inline-block;
  min-width: 44px;
  min-height: 26px;
  margin-top: 6px;
}

.dh.dh--skeleton .dh-stat__icon {
  background: var(--loader-shimmer-base) !important;
  opacity: 0.4 !important;
}

.dh.dh--skeleton .dh-stat__icon svg,
.dh.dh--skeleton .dh-avatar svg,
.dh.dh--skeleton .dh-avatar img {
  opacity: 0 !important;
}

.dh.dh--skeleton .dh-avatar {
  background-color: var(--loader-shimmer-base) !important;
  background: linear-gradient(
    90deg,
    var(--loader-shimmer-base) 0%,
    var(--loader-shimmer-wave) 50%,
    var(--loader-shimmer-base) 100%
  ) !important;
  background-size: 200% 100% !important;
  animation: ui-shimmer-wave 1.4s ease-in-out infinite !important;
}

/* ═══════════════════════════════════════════════════════════════
   SKELETON ADICIONALES: NOTIFICACIONES, SERVICIOS, BARBEROS, CIERRES
   ═══════════════════════════════════════════════════════════════ */
.activity-timeline-item[aria-hidden="true"] {
  border-left-color: var(--loader-shimmer-base, #e2e8f0) !important;
  pointer-events: none !important;
  user-select: none !important;
}

.activity-timeline-item[aria-hidden="true"] .activity-timeline-item__icon {
  background: var(--loader-shimmer-base, #e2e8f0) !important;
  color: transparent !important;
  border-color: transparent !important;
}

.br-item[aria-hidden="true"],
.sv-item[aria-hidden="true"],
.hc-closure[aria-hidden="true"] {
  pointer-events: none !important;
  user-select: none !important;
}

.admin-dark-mode .br-item[aria-hidden="true"],
.admin-dark-mode .sv-item[aria-hidden="true"],
.admin-dark-mode .hc-closure[aria-hidden="true"],
.admin-dark-mode .activity-timeline-item[aria-hidden="true"] {
  background: #17181d !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

