/* ============ Botones ============ */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 999px;
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: transform .18s var(--ease), background .2s, box-shadow .25s, border-color .2s, color .2s;
}
.btn svg { flex: none; transition: transform .25s var(--ease); }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.96); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { box-shadow: 0 10px 24px -10px var(--primary); }
.btn--ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn--ghost:hover { background: rgba(var(--ink), .1); }
.btn--icon { width: 44px; padding: 0; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn--lg { min-height: 54px; font-size: 16px; border-radius: 16px; }
.btn--block { width: 100%; }
.btn--link { min-height: 32px; padding: 0; background: none; color: var(--link); }

/* Microanimaciones de icono al pasar el ratón */
.btn:hover .i-r { transform: translateX(3px); }
.btn:hover .i-l { transform: translateX(-3px); }
.btn:hover .i-rot { transform: rotate(90deg); }
.btn:hover .i-pop { transform: scale(1.15); }
.btn:hover .i-ring { animation: ring .6s ease-in-out; }

/* Efecto Collision (botones de contorno): dos bolitas chocan en el centro y rellenan el botón */
@keyframes collideL { 0% { left: -14px; width: 14px; } 50% { left: 50%; width: 14px; } 100% { left: 50%; width: 300%; } }
@keyframes collideR { 0% { right: -14px; width: 14px; } 50% { right: 50%; width: 14px; } 100% { right: 50%; width: 300%; } }
.fx-collide {
  overflow: hidden; isolation: isolate;
  background: transparent; color: var(--fx, var(--primary));
  border: 1.5px solid var(--fx, var(--primary));
  transition: color .25s ease .38s, transform .18s var(--ease), box-shadow .3s;
}
.fx-collide::before, .fx-collide::after {
  content: ""; position: absolute; top: 50%; width: 14px; aspect-ratio: 1;
  border-radius: 50%; background: var(--fx, var(--primary)); z-index: -1; pointer-events: none;
}
.fx-collide::before { left: -14px; transform: translate(-50%, -50%); }
.fx-collide::after { right: -14px; transform: translate(50%, -50%); }
.fx-collide:hover::before { animation: collideL .8s cubic-bezier(.6, 0, .3, 1) both; }
.fx-collide:hover::after { animation: collideR .8s cubic-bezier(.6, 0, .3, 1) both; }
.fx-collide:hover { color: var(--fx-on); box-shadow: 0 12px 30px -14px var(--fx, var(--primary)); }

/* Efecto Position aware (botones rellenos): el círculo nace donde entra el cursor (ver fx.js) */
.fx-aware { overflow: hidden; isolation: isolate; }
.fx-aware::before {
  content: ""; position: absolute; left: var(--x, 50%); top: var(--y, 50%);
  width: 0; aspect-ratio: 1; border-radius: 50%;
  background: var(--fx2, #F5F7FA); transform: translate(-50%, -50%);
  transition: width .5s ease-in-out; z-index: -1; pointer-events: none;
}
.fx-aware:hover::before { width: 260%; }

/* ============ Selector segmentado con gota líquida (ver goo.js) ============ */
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.seg::-webkit-scrollbar { display: none; }
.seg__track { position: relative; display: flex; gap: 4px; }
.seg__goo { position: absolute; inset: 0; filter: url(#goo); pointer-events: none; }
.seg__pill { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--seg-color, var(--primary)); }
.seg__drop { position: absolute; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--seg-color, var(--primary)); }
.seg__btn {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: color .35s ease .12s;
}
.seg__btn svg { flex: none; transition: transform .3s var(--ease-bounce); }
.seg__btn:hover svg { transform: translateY(-2px) scale(1.12); }
.seg__btn:hover { color: var(--text); }
.seg__btn[aria-pressed="true"], .seg__btn[aria-selected="true"], .seg__btn[aria-current="page"] { color: var(--seg-on, var(--on-primary)); }
.seg__btn:focus-visible { outline: 2px solid rgba(var(--ink), .5); outline-offset: -3px; }
.seg--nav .seg__btn { height: 40px; padding: 0 18px; font-size: 14px; }
.seg--plain { background: transparent; padding: 0; }

/* ============ Marca y selector de idioma ============ */
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--text); }
.brand:hover { color: var(--text); }
.logo { display: block; width: auto; flex: none; }
[data-theme="dark"] .logo--light, [data-theme="light"] .logo--dark { display: none; }
.brand__mark { flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--primary); display: grid; place-items: center; color: #0E121B; }
.brand__name { font-size: 18px; font-weight: 700; white-space: nowrap; }
.lang-group { flex: none; display: flex; align-items: center; gap: 8px; padding: 5px 5px 5px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.lang-group__globe { display: grid; }
.lang-group .seg__btn { width: 52px; height: 34px; padding: 0; font-size: 13px; font-weight: 700; letter-spacing: .04em; }

/* ============ Interruptor de tema ============ */
.theme-toggle {
  position: relative; flex: none; width: 78px; height: 44px; padding: 0;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; overflow: hidden; transition: transform .18s var(--ease), border-color .3s;
}
.theme-toggle:hover { transform: translateY(-2px); border-color: var(--primary); }
.theme-toggle:active { transform: scale(.96); }
.theme-toggle__ghost { position: absolute; top: 50%; margin-top: -8px; color: var(--muted); transition: opacity .4s; }
.theme-toggle__ghost--moon { left: 12px; }
.theme-toggle__ghost--sun { right: 12px; }
.theme-toggle__knob {
  position: absolute; top: 4px; left: 4px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: #2B303B; color: #BFE9FE;
  box-shadow: 0 6px 14px -6px var(--shadow);
  transition: transform .6s cubic-bezier(.5, 1.6, .4, 1), background .4s, color .4s;
}
.theme-toggle__knob .sun { display: none; }
[data-theme="light"] .theme-toggle__knob { transform: translateX(34px) rotate(360deg); background: #F7B832; color: #0E121B; }
[data-theme="light"] .theme-toggle__knob .moon { display: none; }
[data-theme="light"] .theme-toggle__knob .sun { display: block; }
[data-theme="dark"] .theme-toggle__ghost--moon, [data-theme="light"] .theme-toggle__ghost--sun { opacity: 0; }

/* ============ Interruptor genérico ============ */
.switch {
  position: relative; flex: none; width: 52px; height: 30px; padding: 3px;
  border: 0; border-radius: 999px; background: var(--surface-3); cursor: pointer;
  transition: background .25s;
}
.switch::after {
  content: ""; display: block; width: 24px; height: 24px; border-radius: 50%; background: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .3s var(--ease-bounce);
}
.switch[aria-checked="true"] { background: var(--switch-on, var(--act-g)); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* ============ Tarjetas, campos y piezas ============ */
.card { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); padding: 24px; }
.card--enter { animation: fadeUp .6s var(--ease) both; }
.field {
  display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
}
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(67, 191, 253, .16); }
.field input, .field select, .field textarea { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 15px; }
.field svg { flex: none; color: var(--muted); }
.field--area { height: auto; padding: 12px 14px; }
.field--area textarea { resize: vertical; line-height: 1.5; }
.field-label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.pref { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); font-size: 14px; font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.avatar {
  flex: none; display: grid; place-items: center; overflow: hidden;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { width: 28px; height: 28px; margin-left: -8px; border: 2px solid var(--surface); color: #0E121B; font-size: 10px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.badge-count {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #FFFFFF; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg); animation: pulse 2s infinite;
}
.tile-icon { flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.alert--error { background: rgba(255, 61, 76, .1); border: 1px solid rgba(255, 61, 76, .35); color: var(--red-ink); }
.alert--warn { background: rgba(247, 184, 50, .1); border: 1px solid rgba(247, 184, 50, .35); color: var(--text-2); }
.alert--info { background: rgba(67, 191, 253, .08); border: 1px solid rgba(67, 191, 253, .25); color: var(--text-2); }

/* ============ Popover, panel lateral y toast ============ */
.backdrop { position: fixed; inset: 0; z-index: 30; border: 0; background: transparent; cursor: default; }
.backdrop--dim { background: rgba(5, 8, 14, .55); backdrop-filter: blur(4px); animation: fadeIn .3s ease both; }
.popover {
  position: absolute; top: calc(100% + 14px); right: 0; z-index: 31;
  width: min(400px, calc(100vw - 32px)); border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 30px 60px -24px var(--shadow); overflow: hidden;
  transform-origin: top right; animation: popIn .32s cubic-bezier(.3, 1.3, .5, 1) both;
}
.drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: 31;
  width: min(420px, calc(100vw - 24px)); overflow-y: auto;
  border-radius: 26px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6);
  animation: drawerIn .45s cubic-bezier(.2, .8, .2, 1) both;
}
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid rgba(0, 194, 110, .4);
  box-shadow: 0 20px 50px -20px var(--shadow); font-size: 14px;
  animation: popIn .35s var(--ease) both;
}

/* ============ Tablas ============ */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .2s; }
.table tbody tr:hover { background: rgba(var(--ink), .03); }
