/* ═══════════════════════════════════════════════════════════════
 * ui-enhancements.css — Mejoras visuales sobre clases existentes
 * v1.0 · 2026-05-23
 *
 * NO reemplaza, MEJORA. Se carga DESPUÉS del CSS inline del index.html
 * para sobreescribir solo lo necesario sin romper layouts existentes.
 *
 * Foco: microinteractions, shadows graduales, focus rings, transitions
 * más fluidas, modernización sutil sin cambiar la estructura.
 * ═══════════════════════════════════════════════════════════════ */

/* ─── BUTTONS · gradiente sutil + hover lift ─────────────── */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 180ms cubic-bezier(0.0, 0.0, 0.2, 1) !important;
  letter-spacing: 0.3px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%) !important;
  color: #fff !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.15);
  font-weight: 700;
}
.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(240,165,0,.30), 0 2px 4px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.18) !important;
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-ghost { transition: all 150ms ease !important; }
.btn-ghost:hover { transform: translateY(-1px); border-color: var(--accent) !important; }
.btn-danger:hover { box-shadow: 0 4px 12px rgba(248,81,73,.25); transform: translateY(-1px); }

/* Ripple efecto en click */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,.4) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: transform 600ms ease-out, opacity 600ms ease-out;
  pointer-events: none;
}
.btn:active::after {
  opacity: 1;
  transform: scale(2);
  transition: 0s;
}

/* ─── INPUTS · focus rings dorados ───────────────────────── */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select,
textarea {
  transition: all 150ms ease !important;
}

/* ─── QUITAR FLECHAS DE INPUTS NUMBER (2026-05-25) ──────── */
/* Las flechitas de spinner tapan el valor en inputs angostos.
 * Los usuarios prefieren escribir el número directo, no clickear.
 * Funciona en Chrome, Edge, Safari + Firefox. */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  margin: 0 !important;
}
input[type="number"] {
  -moz-appearance: textfield !important;  /* Firefox */
  appearance: textfield !important;
}

/* Inputs numéricos: alineación derecha + más cómodos visualmente */
input[type="number"] {
  text-align: right !important;
  padding-right: 10px !important;
  font-variant-numeric: tabular-nums;  /* dígitos del mismo ancho */
  letter-spacing: 0.2px;
}

/* Si el input está en una tabla densa, asegurar ancho mínimo razonable */
table input[type="number"],
.budget-table input[type="number"],
.aiu-table input[type="number"] {
  min-width: 70px;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(240,165,0,.18), 0 1px 2px rgba(0,0,0,.05) !important;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) { border-color: var(--text3) !important; }

/* Placeholders más sutiles */
input::placeholder, textarea::placeholder { color: var(--text3); opacity: 0.7; }

/* ─── PROJECT CARDS · hover lift gradual ─────────────────── */
.project-card {
  transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 250ms ease,
              border-color 200ms ease !important;
}
.project-card:hover {
  transform: translateY(-4px) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,.22), 0 4px 12px rgba(0,0,0,.12), 0 0 0 1px var(--accent) !important;
}

/* ─── MODAL · backdrop blur + spring entrance ────────────── */
.modal-bg {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(13,17,23,.55) !important;
}
.modal {
  animation: modalSlideUp 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 24px 64px rgba(0,0,0,.40), 0 12px 24px rgba(0,0,0,.20);
  border: 1px solid var(--border2);
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ─── SIDEBAR · transitions más suaves ───────────────────── */
.nav-item {
  transition: all 180ms cubic-bezier(0.0, 0.0, 0.2, 1) !important;
  position: relative;
}
.nav-item:hover {
  transform: translateX(2px);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(240,165,0,.5);
}

/* ─── TOPBAR · 2 filas (2026-05-25 v2) ───────────────────────
 *  Fila 1: marca, idioma, auth-bar (cuenta, salir, invitar, etc.)
 *  Fila 2 (sub-topbar): nombre del proyecto + botones de acción
 *  Esto evita truncar el nombre del proyecto y los botones quedan accesibles
 * ─────────────────────────────────────────────────────────── */

.topbar {
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  position: relative;
  z-index: 50;
  flex-wrap: wrap !important;
  overflow: visible;
  gap: 8px !important;
  padding: 8px 24px !important;
  min-height: 54px;
  height: auto !important;
}

/* Hamburger SOLO en mobile */
.topbar-ham,
#topbar-ham {
  display: none !important;
}
@media (max-width: 900px) {
  .topbar-ham,
  #topbar-ham {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 6px;
  }
  .topbar-ham span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text2);
    border-radius: 2px;
  }
}

/* #496-D · Título del topbar · COMPORTAMIENTO NORMAL (no segunda fila)
   Bug histórico: la regla anterior usaba flex:1 1 100% + order:100 + border-top
   para crear una "segunda fila" tipo card. Pero combinado con flex-wrap:wrap
   del topbar y overflow:hidden, esto cortaba TODOS los demás hijos del topbar
   (auth-bar, theme-toggle, role-badge, fs-switcher, i18n-switcher) que quedaban
   invisibles en la 2da fila. Diagnóstico hecho 2026-06-05. */
.topbar-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex: 0 1 auto;
  max-width: 280px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Si el título dice "Mis Proyectos" (sin proyecto activo), va en línea 1 normal */
.topbar-title.simple {
  flex: 0 1 auto;
  order: 1;
  border-top: none;
  padding-top: 0;
  margin-top: 0;
  font-size: 17px !important;
}

/* Botones de acción del proyecto · van junto al título en segunda fila */
#topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-left: auto;
  order: 101;             /* segunda fila junto al título */
  flex: 0 0 auto;
  max-width: 100%;
}
#topbar-actions::-webkit-scrollbar { display: none; }
#topbar-actions:empty { display: none !important; }
#topbar-actions .btn,
#topbar-actions button,
#topbar-actions a {
  padding: 5px 12px !important;
  font-size: 12px !important;
  white-space: nowrap !important;
  flex-shrink: 0;
}

/* Auth bar (ADMIN | email | Salir | Invitar | ⚙ | 🔔) · fila 1 derecha */
#auth-bar {
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: auto;
  order: 50;
}
#auth-bar .badge,
#auth-bar span[class*="role"],
#auth-bar .topbar-email {
  font-size: 11px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#team-selector-slot { order: 49; flex-shrink: 0; }
#theme-toggle-btn   { order: 48; flex-shrink: 0; }
#i18n-switcher      { order: 47; flex-shrink: 0; }
#i18n-switcher button { padding: 3px 7px !important; font-size: 10px !important; }

/* En pantallas medianas (≤1100px), ocultar el email del admin (queda solo "ADMIN") */
@media (max-width: 1100px) {
  #auth-bar .topbar-email,
  #auth-bar [class*="email"]:not(button) {
    display: none !important;
  }
}

/* En tabletas (≤900px) los botones de acción más compactos */
@media (max-width: 900px) {
  #topbar-actions .btn,
  #topbar-actions button { padding: 4px 9px !important; font-size: 11px !important; }
  .topbar { padding: 8px 14px !important; }
  .topbar-title { font-size: 15px !important; }
}

/* ─── NAV COUNT · pill más bonita ─────────────────────────── */
.nav-count {
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  font-size: 10px !important;
}

/* ─── ICON BUTTONS · hover scale ─────────────────────────── */
.icon-btn {
  transition: all 150ms ease !important;
  border-radius: 6px;
}
.icon-btn:hover { transform: scale(1.08); }
.icon-btn:active { transform: scale(0.95); }

/* ─── INFO BARS (KPIs dashboards) ─────────────────────────── */
.info-bar {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: all 200ms ease;
}
.info-bar:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.info-block {
  transition: transform 150ms ease;
}
.info-block:hover { transform: translateY(-1px); }
.info-val {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace !important;
  font-weight: 700 !important;
}

/* ─── TABLAS · hover rows + zebra stripping ──────────────── */
.data-table tbody tr,
.budget-table tbody tr,
.aiu-table tbody tr {
  transition: background 120ms ease;
}
.data-table tbody tr:hover td,
.budget-table tbody tr:hover td,
.aiu-table tbody tr:hover td {
  background: rgba(240,165,0,.04) !important;
}

/* ─── CARDS GENÉRICAS · soft shadow + hover ──────────────── */
.card, .sk-card, [class*="card"] {
  border-radius: 12px;
}

/* ─── BOTÓN UPGRADE TOPBAR · pulse sutil cuando es free ──── */
@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,165,0,.45); }
  50%      { box-shadow: 0 0 0 8px rgba(240,165,0,0); }
}
.btn-upgrade {
  animation: pulseGold 2.4s ease-in-out infinite;
}

/* ─── FAB botones flotantes (qa, ai copilot) ─────────────── */
[id$="-floating-btn"],
[id="qa-fab"],
.qa-fab {
  transition: all 200ms cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  box-shadow: 0 4px 14px rgba(240,165,0,.35), 0 2px 4px rgba(0,0,0,.10) !important;
}
[id$="-floating-btn"]:hover,
[id="qa-fab"]:hover,
.qa-fab:hover {
  transform: scale(1.08) translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(240,165,0,.45), 0 4px 8px rgba(0,0,0,.12) !important;
}

/* ─── TOAST notifications mejoradas ──────────────────────── */
.toast,
[class*="toast"] {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(22,27,34,.92) !important;
  border: 1px solid var(--border2) !important;
  box-shadow: 0 12px 32px rgba(0,0,0,.30) !important;
  border-radius: 10px !important;
}

/* ─── BADGES más profesionales ───────────────────────────── */
.badge, .pill {
  font-weight: 600;
  letter-spacing: 0.2px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ─── SCROLLBARS sutiles ─────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 10px;
  border: 2px solid var(--bg);
  transition: background 150ms ease;
}
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ─── SELECTION dorada ───────────────────────────────────── */
::selection { background: rgba(240,165,0,.30); color: var(--text); }

/* ─── FOCUS VISIBLE accesible ────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ─── EMPTY STATES más bonitos ───────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border: 1px dashed var(--border2);
  border-radius: 14px;
  animation: emptyFadeIn 400ms ease;
}
.empty-state .empty-icon {
  font-size: 56px !important;
  opacity: 0.35;
  margin-bottom: 12px;
  display: block;
  filter: grayscale(0.4);
}
.empty-state .empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-state .empty-desc {
  font-size: 13px;
  color: var(--text3);
  max-width: 380px;
  margin: 0 auto 16px;
  line-height: 1.55;
}
@keyframes emptyFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ─── LOADING SKELETONS más graduales ────────────────────── */
.sk, .skeleton {
  background: linear-gradient(90deg,
    var(--surface) 0%,
    var(--surface2) 50%,
    var(--surface) 100%) !important;
  background-size: 200% 100% !important;
  animation: skShimmer 1.6s cubic-bezier(0.4, 0.0, 0.6, 1) infinite !important;
}
@keyframes skShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── REDUCED MOTION (accesibilidad) ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── DARK MODE refinement ───────────────────────────────── */
[data-theme="light"] .modal-bg { background: rgba(0,0,0,.45) !important; }
[data-theme="light"] .modal {
  box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 12px 24px rgba(0,0,0,.10);
  border-color: var(--border);
}
[data-theme="light"] .toast {
  background: rgba(255,255,255,.96) !important;
  color: var(--text);
  border-color: var(--border) !important;
}
[data-theme="light"] .btn-primary { color: #000 !important; }
[data-theme="light"] .info-bar {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%) !important;
}

/* ─── MOBILE RESPONSIVE refinement ───────────────────────── */
@media (max-width: 640px) {
  .modal {
    border-radius: 16px 16px 0 0 !important;
    margin-top: auto !important;
    align-self: flex-end;
    animation: modalSlideUpMobile 300ms cubic-bezier(0.0, 0.0, 0.2, 1);
  }
  .btn { padding: 9px 16px !important; min-height: 38px; }
  .topbar { padding: 0 14px !important; }
  .project-card:hover { transform: none !important; }
}
@keyframes modalSlideUpMobile {
  from { transform: translateY(100%); opacity: 0.5; }
  to   { transform: translateY(0);    opacity: 1;   }
}
