/* ============================================================
   MICROINTERACTIONS — Polish capa final
   ============================================================
   Hover effects sutiles, transitions suaves entre views,
   focus visible accesible, animations sutiles.
   ============================================================ */

/* ============================================================
   PAGE TRANSITIONS: fade-in suave al cambiar de vista
   ============================================================ */
.view {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}
.view.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ============================================================
   HOVER EFFECTS sutiles en cards
   ============================================================ */
.card,
.kpi,
.lg-card.desbloqueado,
.mkt-card,
.cv2-grid-card,
.dir-kpi,
.lb-stat-card {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s,
              border-color 0.2s;
}
.card:hover,
.kpi:hover,
.mkt-card:hover:not([style*="opacity"]),
.cv2-grid-card:hover,
.dir-kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(27, 58, 46, 0.08);
}
.lg-card.desbloqueado:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

/* ============================================================
   FOCUS VISIBLE — accesibilidad keyboard navigation
   ============================================================ */
*:focus-visible {
  outline: 2px solid var(--accent-gold, #C9A063);
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus-visible {
  outline-offset: 3px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-primary, #1B3A2E);
  outline-offset: 0;
}
/* Quitar outline default cuando se usa mouse */
*:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   BOTONES: loading state animado (.is-loading)
   ============================================================ */
button.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  opacity: 0.7;
}
button.is-loading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
  color: #fff;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* Press effect (click feedback) */
button:not(:disabled):active {
  transform: scale(0.97);
}

/* ============================================================
   LINKS y nav: subtle hover
   ============================================================ */
.nav-btn {
  transition: background 0.18s, color 0.18s, transform 0.1s;
}
.nav-btn:hover {
  background: var(--bg-warm, #F5F0E6);
}
.nav-btn:active {
  transform: scale(0.98);
}
.nav-btn.active {
  background: var(--accent-primary-soft, rgba(27,58,46,0.08));
  color: var(--accent-primary, #1B3A2E);
  font-weight: 600;
}

/* ============================================================
   LISTAS: stagger animation al cargar (entrada secuencial)
   ============================================================ */
.lg-galeria .lg-card,
.cv2-grid .cv2-grid-card,
.cf-mis-contratos .cf-contrato-row {
  animation: itemFadeIn 0.4s ease-out backwards;
}
.lg-galeria .lg-card:nth-child(1) { animation-delay: 0.05s; }
.lg-galeria .lg-card:nth-child(2) { animation-delay: 0.08s; }
.lg-galeria .lg-card:nth-child(3) { animation-delay: 0.11s; }
.lg-galeria .lg-card:nth-child(4) { animation-delay: 0.14s; }
.lg-galeria .lg-card:nth-child(5) { animation-delay: 0.17s; }
.lg-galeria .lg-card:nth-child(6) { animation-delay: 0.20s; }
.lg-galeria .lg-card:nth-child(7) { animation-delay: 0.23s; }
.lg-galeria .lg-card:nth-child(8) { animation-delay: 0.26s; }

@keyframes itemFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SCROLL: smooth + thin scrollbar custom
   ============================================================ */
html { scroll-behavior: smooth; }

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-subtle, #F0EDE5);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold-soft, rgba(201,160,99,0.4));
  background-clip: padding-box;
}

/* ============================================================
   PWA INSTALL PROMPT BANNER (custom)
   ============================================================ */
.pwa-install-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent-primary, #1B3A2E), var(--accent-primary-hover, #2D4A3A));
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  z-index: 9997;
  max-width: 420px;
  width: calc(100% - 32px);
  font-family: 'Inter', sans-serif;
  animation: pwaBannerIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pwa-install-banner-icon { font-size: 28px; line-height: 1; }
.pwa-install-banner-info { flex: 1; min-width: 0; }
.pwa-install-banner-title { font-weight: 800; font-size: 13px; }
.pwa-install-banner-sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.pwa-install-banner button {
  background: var(--accent-gold, #C9A063);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-install-banner button.dismiss {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  padding: 7px 8px;
  font-size: 16px;
}
@keyframes pwaBannerIn {
  from { transform: translate(-50%, 80px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

/* ============================================================
   SELECTION COLOR
   ============================================================ */
::selection {
  background: var(--accent-gold-soft, rgba(201, 160, 99, 0.3));
  color: var(--accent-primary-deep, #102218);
}

/* ============================================================
   VERSION BADGE: visible siempre (login + sidebar)
   ============================================================
   Click para copiar info de diagnóstico al clipboard
   (versión, browser, SW status, online status, user agent).
   Útil para soporte: "mándame la info de tu badge" → ya tienes
   todo lo necesario para diagnosticar bugs reportados. */
.version-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.6);
  font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.version-badge:hover {
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.04);
}
.version-badge:active {
  transform: scale(0.96);
}
.version-badge.copied {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
  color: #86efac;
}

/* Variante en login screen (fondo claro/oscuro adaptable) */
#versionBadge {
  position: fixed;
  bottom: 12px;
  right: 14px;
  z-index: 50;
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.45);
}
#versionBadge:hover {
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.7);
}

/* Variante en sidebar — alineada con powered-by */
.version-badge-sidebar {
  margin-top: 6px;
  width: 100%;
  justify-content: center;
}

/* ============================================================
   SPRINT K-2 ADDITIONS — Microinteractions polish
   ============================================================ */

/* RIPPLE EFFECT en botones primarios */
.btn-primary, .sec-btn-primary, .av-btn-primary,
.ux-empty-cta, .cm-submit {
  position: relative;
  overflow: hidden;
}
.btn-primary::after, .sec-btn-primary::after, .av-btn-primary::after,
.ux-empty-cta::after, .cm-submit::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: width 0.4s ease-out, height 0.4s ease-out, opacity 0.6s ease-out;
  opacity: 0;
}
.btn-primary:active::after, .sec-btn-primary:active::after, .av-btn-primary:active::after,
.ux-empty-cta:active::after, .cm-submit:active::after {
  width: 200%; height: 200%; opacity: 1;
  transition: width 0s, height 0s, opacity 0s;
}

/* SHAKE on form validation error */
@keyframes uxShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.ux-shake { animation: uxShake 0.4s ease-in-out; }

/* SUCCESS PULSE */
@keyframes uxSuccessPulse {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  70% { box-shadow: 0 0 0 16px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.ux-success-pulse { animation: uxSuccessPulse 1.2s ease-out; }

/* BUTTON HOVER LIFT */
button.btn-primary, button.sec-btn-primary, button.av-btn-primary,
button.ux-empty-cta, button.cm-submit {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
button.btn-primary:hover, button.sec-btn-primary:hover, button.av-btn-primary:hover,
button.ux-empty-cta:hover, button.cm-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}
button.btn-primary:active, button.sec-btn-primary:active, button.av-btn-primary:active,
button.ux-empty-cta:active, button.cm-submit:active {
  transform: translateY(0);
}

/* INPUT FOCUS GLOW elegante */
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-primary, #1B3A2E) !important;
  box-shadow: 0 0 0 3px rgba(27, 58, 46, 0.08) !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* TOAST slide-in */
@keyframes uxToastSlide {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast, .ux-toast { animation: uxToastSlide 0.3s cubic-bezier(0.32, 0.72, 0, 1); }

/* CHECKBOX smooth */
input[type="checkbox"]:checked, input[type="radio"]:checked {
  transform: scale(1.05);
  transition: transform 0.12s ease;
}

/* ============================================================
   REDUCED MOTION: respetar preferencias del usuario
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .view { opacity: 1; transform: none; }
}

/* ============================================================
   MICROINTERACCIONES PRO (v=172)
   ============================================================ */

/* ── 1) Ripple click en buttons ── */
@keyframes mi-ripple {
  0%   { transform: scale(0); opacity: 0.55; }
  100% { transform: scale(2.6); opacity: 0; }
}
.btn, button.btn-primary, button.btn-secondary, .nav-btn, .ai-btn, .ap-btn, .ec-btn, .sec-btn-primary {
  position: relative;
  overflow: hidden;
}
.mi-ripple-circle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  animation: mi-ripple 0.55s cubic-bezier(0.16,1,0.3,1) forwards;
  z-index: 0;
}

/* ── 2) Badge bounce cuando el counter cambia ── */
@keyframes mi-badge-bounce {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.35); }
  55%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.badge.mi-bumped,
.nav-btn .badge.mi-bumped { animation: mi-badge-bounce 0.45s ease-out; }

/* ── 3) Pulse perpetuo en botón Pendientes admin si hay solicitudes ── */
@keyframes mi-pulse-attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
.nav-btn[data-view="admin-pendientes"] .badge {
  animation: mi-pulse-attention 1.8s ease-out infinite;
}

/* ── 4) Shimmer en cards de loading ── */
@keyframes mi-shimmer {
  0%   { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.mi-shimmer {
  background: linear-gradient(90deg, #F5F0E6 0%, #FFFFFF 50%, #F5F0E6 100%);
  background-size: 2000px 100%;
  animation: mi-shimmer 1.8s ease-in-out infinite;
  color: transparent !important;
  border-radius: 4px;
}

/* ── 5) Check con flash al marcar pago/aprobar ── */
@keyframes mi-check-flash {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  40%  { transform: scale(1.4) rotate(0deg); opacity: 1; }
  60%  { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.1) rotate(0deg); opacity: 0; }
}
.mi-check-overlay {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 110px;
  color: #16A34A;
  text-shadow: 0 4px 20px rgba(22,163,74,0.4);
  z-index: 99999;
  pointer-events: none;
  animation: mi-check-flash 1.1s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

/* ── 6) View transitions más suaves ── */
@keyframes mi-view-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  .view.active {
    animation: mi-view-enter 0.28s cubic-bezier(0.16,1,0.3,1);
  }
}

/* ── 7) Hover lift en cards interactivas ── */
.kpi-card, .ai-card, .ap-card, .ec-card, .sec-stat-card, .c360-kpi {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi-card:hover, .ai-card:hover, .ap-card:hover, .ec-card:hover, .c360-kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

/* ── 8) Kanban drag visual ── */
.kanban-card.dragging {
  transform: rotate(2deg) scale(1.04);
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  opacity: 0.85;
  cursor: grabbing;
}
.kanban-col.drag-over {
  background: linear-gradient(135deg, rgba(22,163,74,0.08), rgba(34,197,94,0.04)) !important;
  outline: 2px dashed #16A34A;
  outline-offset: -8px;
}

/* ── 9) Skeleton pulse mejorado ── */
@keyframes mi-skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ── 10) Respeta accesibilidad ── */
@media (prefers-reduced-motion: reduce) {
  .mi-ripple-circle, .badge.mi-bumped, .mi-check-overlay,
  .kanban-card.dragging { animation: none !important; transform: none !important; }
  .view.active { animation: none !important; }
  .nav-btn[data-view="admin-pendientes"] .badge { animation: none !important; }
}

/* ── 11) SPLASH SCREEN ENTRADA ── */
@keyframes mi-splash-bg {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes mi-splash-logo {
  0%   { transform: scale(0.7) rotate(-8deg); opacity: 0; }
  40%  { transform: scale(1.05) rotate(2deg); opacity: 1; }
  70%  { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.2) rotate(0deg); opacity: 0; }
}
@keyframes mi-splash-text {
  0%   { opacity: 0; transform: translateY(8px); }
  40%  { opacity: 1; transform: translateY(0); }
  85%  { opacity: 1; }
  100% { opacity: 0; }
}
#miSplash {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #2D4A3A 0%, #1B3A2E 70%, #102218 100%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
  animation: mi-splash-bg 0.5s ease-out 2s forwards;
  pointer-events: none;
}
#miSplash .mi-splash-stats {
  margin-top: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.4s ease;
  font-weight: 500;
  color: rgba(255,255,255,0.92);
  text-align: center;
  max-width: 90%;
  letter-spacing: 0.3px;
}
#miSplash .mi-splash-personal strong {
  color: #FBBF24;
  font-weight: 700;
}
#miSplash .mi-splash-logo {
  width: 110px; height: 110px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 60px rgba(0,0,0,0.4), 0 0 80px rgba(201,160,99,0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  animation: mi-splash-logo 1.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
#miSplash .mi-splash-logo img {
  width: 100%; height: 100%; object-fit: contain;
}
#miSplash .mi-splash-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
  animation: mi-splash-text 1.6s ease-out forwards;
}
#miSplash .mi-splash-sub {
  font-size: 13px;
  opacity: 0.85;
  letter-spacing: 0.4px;
  animation: mi-splash-text 1.6s ease-out 0.15s forwards;
  opacity: 0;
}

/* ── 12) Toggle sonidos en sidebar footer ── */
.sound-toggle {
  background: transparent;
  border: 1px solid var(--cvv-border, rgba(0,0,0,0.08));
  border-radius: 999px;
  width: 28px; height: 28px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.18s ease, transform 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.sound-toggle:hover { opacity: 1; transform: scale(1.1); background: rgba(0,0,0,0.04); }
.sound-toggle.muted { opacity: 0.5; }
.sound-toggle.muted:after {
  content: '';
  position: absolute;
  display: block;
  width: 20px;
  height: 2px;
  background: #DC2626;
  transform: rotate(-30deg);
  pointer-events: none;
}
.sound-toggle { position: relative; }
