/* ================================================
   ui.css — Estilos compartidos (loader, toasts, estados de carga)
   ================================================ */

/* ---- Loader global (overlay) ---- */
.loader-global {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(10,12,16,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.loader-global.oculto { display: none; }
.loader-box {
  background: #161b22; border: 1px solid #2a323d;
  border-radius: 14px; padding: 22px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.loader-box span { color: #cdd6e0; font-size: .9rem; }

/* ---- Spinner ---- */
.spinner {
  width: 38px; height: 38px;
  border: 3px solid rgba(245,166,35,.2);
  border-top-color: #f5a623;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Carga en línea (dentro de secciones) ---- */
.inline-cargando {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 28px 16px; color: #9aa7b4; font-size: .88rem;
}
.inline-vacio {
  text-align: center; padding: 28px 16px; color: #6b7684; font-size: .88rem;
}
.inline-error {
  text-align: center; padding: 24px 16px; color: #e0a0a0; font-size: .88rem;
}

/* ---- Toasts (avisos flotantes) ---- */
.toast-cont {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 10001; display: flex; flex-direction: column; gap: 8px;
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: #1c222c; border: 1px solid #2a323d; color: #e8edf2;
  border-radius: 10px; padding: 12px 16px; font-size: .87rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(12px); transition: all .28s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast-ico { font-size: 1.05rem; flex-shrink: 0; }
.toast-ok    { border-left: 3px solid #2ea043; }
.toast-error { border-left: 3px solid #d29922; }
.toast-warn  { border-left: 3px solid #f5a623; }
.toast-info  { border-left: 3px solid #58a6ff; }

/* ---- Badge de pendientes offline ---- */
.badge-offline {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(245,166,35,.15); color: #f5a623;
  border: 1px solid rgba(245,166,35,.4); border-radius: 20px;
  padding: 4px 10px; font-size: .74rem; font-weight: 600;
}

/* Botón deshabilitado con spinner */
.btn.cargando { position: relative; color: transparent !important; pointer-events: none; }
.btn.cargando::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}

/* ---- Iconos en pestañas ---- */
.tab-ico { margin-right: 5px; font-size: 1.05em; }
@media (max-width: 480px){
  /* En móvil, si el espacio es poco, el icono ayuda a identificar */
  .tab-ico { margin-right: 3px; }
}

/* ---- Botones de la barra superior (home / logout) con SVG ---- */
.btn-icono {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  background: var(--bg-3, #1c222c); border: 1px solid var(--linea, #2a323d);
  border-radius: 10px; color: var(--txt, #e8edf2); cursor: pointer;
  transition: all .12s;
}
.btn-icono:hover { border-color: var(--ambar, #f5a623); color: var(--ambar, #f5a623); }
.btn-icono svg { display: block; }
#btn-logout:hover { border-color: #d0433b; color: #d0433b; }

/* ================================================
   INDICADOR DE SINCRONIZACIÓN
   Discreto: solo aparece si hay algo pendiente.
   ================================================ */
.sync-indicador {
  position: fixed; z-index: 9500;
  bottom: calc(14px + env(safe-area-inset-bottom)); right: 14px;
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(28,34,44,.96); border: 1px solid rgba(245,166,35,.5);
  color: #f5a623; border-radius: 22px; padding: 8px 14px;
  font-size: .8rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  backdrop-filter: blur(6px);
  animation: syncAparece .3s ease;
}
.sync-indicador.oculto { display: none; }
@keyframes syncAparece { from{ opacity:0; transform:translateY(8px);} to{ opacity:1; transform:none;} }
.sync-indicador.subiendo { border-color: rgba(88,166,255,.6); color: #58a6ff; }
.sync-ico { font-size: .95rem; }
.sync-spin {
  width: 13px; height: 13px; border: 2px solid rgba(88,166,255,.25);
  border-top-color: #58a6ff; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}

/* Panel de detalle de pendientes */
.sync-panel {
  position: fixed; inset: 0; z-index: 9600;
  background: rgba(0,0,0,.7); display: none;
  align-items: flex-end; justify-content: center;
}
.sync-panel.visible { display: flex; }
.sync-panel-box {
  background: #161b22; border: 1px solid #2a323d;
  border-radius: 16px 16px 0 0; width: 100%; max-width: 480px;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 80vh; overflow-y: auto; position: relative;
}
.sync-panel-box h3 { font-size: 1.1rem; margin-bottom: 4px; color: #e8edf2; }
.sync-sub { font-size: .85rem; color: #9aa7b4; margin-bottom: 16px; }
.sync-cerrar {
  position: absolute; top: 14px; right: 14px;
  background: #1c222c; border: none; color: #e8edf2;
  width: 32px; height: 32px; border-radius: 8px; font-size: 1rem; cursor: pointer;
}
.sync-lista { margin-bottom: 14px; }
.sync-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.05);
}
.sync-item:last-child { border-bottom: none; }
.sync-item-txt { font-size: .9rem; color: #e8edf2; }
.sync-item-meta { font-size: .76rem; color: #6b7684; margin-top: 2px; }
.sync-item.con-error .sync-item-meta { color: #f85149; }
.sync-item-ico { font-size: 1rem; flex-shrink: 0; }
.sync-aviso {
  background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.3);
  color: #ff9b95; border-radius: 8px; padding: 10px 12px;
  font-size: .82rem; margin-bottom: 12px;
}
@media (min-width: 700px){
  .sync-panel { align-items: center; }
  .sync-panel-box { border-radius: 16px; }
}

/* ================================================
   Par de botones Cámara / Galería
   ================================================ */
.foto-fuente {
  display: flex; gap: 8px; margin-top: 4px;
}
.foto-fuente .btn-fuente {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 10px; border-radius: 10px;
  background: var(--bg-3, #1c222c); border: 1px solid var(--linea, #2a323d);
  color: var(--txt, #e8edf2); font-size: .9rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.foto-fuente .btn-fuente:active { transform: scale(.98); }
.foto-fuente .btn-fuente .ico { font-size: 1.1rem; }
.foto-input-oculto { display: none; }

/* ================================================
   PANTALLA DE CARGA INICIAL
   Evita el destello del login al cambiar de módulo:
   se muestra sola hasta saber si hay sesión activa.
   ================================================ */
#vista-cargando {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--bg, #0e1116);
  display: flex; align-items: center; justify-content: center;
}
#vista-cargando.oculta { display: none !important; }
#vista-cargando .spin-carga {
  width: 34px; height: 34px; border: 3px solid rgba(245,166,35,.25);
  border-top-color: var(--ambar, #f5a623); border-radius: 50%;
  animation: spinCarga .7s linear infinite;
}
@keyframes spinCarga { to { transform: rotate(360deg); } }

/* --- Versión del sistema (para soporte) --- */
.version-app {
  text-align: center; font-size: .7rem; color: var(--txt-3);
  margin-top: 16px; letter-spacing: .02em;
}
