/* /styles/components.css */

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn i.feather {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background-color: var(--bg);
  border-color: var(--text);
}

.btn-ghost {
  background-color: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background-color: var(--surface);
  color: var(--text);
}

.btn-full {
  width: 100%;
}

/* Formularios */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.form-input {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus,
.form-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-hover);
}
.form-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* ===== Logo sidebar ===== */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 10rem 1.0rem 0rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.sidebar-logo .logo-icon {
  width: 80px;
  height: 80px;
  flex-shrink: 0;

  /* Verde en tema claro */
  /* Negro → verde azulado (#059669 aprox.) */
  filter:
    invert(41%) sepia(94%) saturate(471%) hue-rotate(114deg)
    brightness(90%) contrast(96%);
  transition: filter var(--transition-fast);
}

.sidebar-logo .logo-text {
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.sidebar.collapsed .logo-text {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

/* Logo en tema oscuro: gris claro */
html[data-theme="dark"] .sidebar-logo .logo-icon,
body[data-theme="dark"] .sidebar-logo .logo-icon {
  /* Negro → gris claro (#e5e7eb aprox.) */
  filter:
    invert(92%) sepia(3%) saturate(315%) hue-rotate(169deg)
    brightness(103%) contrast(90%);
}


.nav-menu {
  list-style: none;
}
.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  overflow: hidden;
}
.nav-item a .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.nav-item a .nav-text {
  opacity: 1;
  transition: opacity var(--transition-fast);
}
.sidebar.collapsed .nav-item a .nav-text {
  opacity: 0;
  width: 0;
}

.nav-item a:hover {
  background-color: var(--bg);
  color: var(--text);
}
.nav-item a.active {
  background-color: var(--primary);
  color: var(--primary-text);
  font-weight: 600;
}
.nav-item a.active:hover {
  background-color: var(--primary-hover);
}

/* Tarjeta KPI (Dashboard) */
.kpi-card {
  border: 1px solid var(--border);
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-medium);
}
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.kpi-card.glass {
  background-color: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
}
.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.kpi-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}
.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.kpi-change {
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 0.5rem;
}
.kpi-change.positive { color: #10B981; }
.kpi-change.negative { color: #EF4444; }

/* =========================================================
   Chat (Vetsa AI) + Historial
   ========================================================= */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  overflow: hidden;
  position: relative;
}

/* Contenedor de mensajes como flex para centrar bienvenida */
.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

/* Burbujas de chat */
.chat-bubble {
  max-width: 75%;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.chat-bubble.user {
  background-color: var(--primary);
  color: var(--primary-text);
  border-bottom-right-radius: var(--radius-sm);
  margin-left: auto;
}
.chat-bubble.ai {
  background-color: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
  margin-right: auto;
}

/* Área de input */
.chat-input-area {
  display: flex;
  padding: 1rem;
  border-top: 1px solid var(--border);
  gap: 0.5rem;
}
.chat-input {
  flex-grow: 1;
  border-radius: var(--radius-full);
}
.chat-send-btn {
  border-radius: var(--radius-full);
  width: 44px;
  height: 44px;
  padding: 0;
}

/* TOP ACTIONS (“Chat actual” / “Ver historial”) */
.ai-top-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.ai-top-btn {
  white-space: nowrap;
}
.ai-top-btn.active {
  background-color: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

/* Bienvenida centrada y acciones dentro del chat */
.ai-welcome-block {
  margin-top: auto;
  margin-bottom: auto;
  text-align: center;
}
.ai-welcome-text {
  max-width: 60ch;
  margin: 0 auto;
  font-size: 1rem;
  opacity: 0.9;
}

/* Acciones rápidas dentro del chat (abajo) */
.ai-quick-actions-inline {
  margin-top: auto;
  margin-bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

/* Fade out bienvenida + acciones */
.ai-fade-out {
  animation: aiFadeOutUp 0.35s ease forwards;
}
@keyframes aiFadeOutUp {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Panel de historial dentro del chat (theme-aware) */
.ai-history-panel {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--bg), var(--surface));
  border-radius: inherit;
  border: 1px solid var(--border);
  box-shadow: 0 18px 45px var(--shadow-color);
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  z-index: 10;
}
.ai-history-hidden {
  display: none;
}

/* Cabecera del historial */
.ai-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.ai-history-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* Lista de conversaciones */
.ai-history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.25rem;
}

/* Item de historial */
.ai-history-item {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-lg);
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.ai-history-item::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: radial-gradient(circle, var(--primary) 0, transparent 60%);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.04);
}
.ai-history-item:hover {
  background: var(--bg);
  border-color: var(--primary);
  box-shadow: 0 10px 30px var(--shadow-color);
  transform: translateY(-1px);
}

/* Contenido del item */
.ai-history-left {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.ai-history-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}
.ai-history-meta {
  font-size: 0.78rem;
  opacity: 0.75;
  color: var(--muted);
}

/* Mensaje de historial vacío */
.ai-history-empty {
  font-size: 0.85rem;
  opacity: 0.8;
  padding: 0.5rem 0.25rem;
  color: var(--muted);
}

/* ────────────────────────────────────────────── */
/* Inventarios – inputs, tabla y configuración   */
/* ────────────────────────────────────────────── */

/* Código de producto autogenerado (solo lectura) */
.inventory-code-input[readonly] {
  background-color: var(--surface);
  cursor: default;
  color: var(--muted);
}

.inventory-code-input::placeholder {
  color: var(--muted);
}

/* Inputs de la fila de productos un poco más compactos */
#product-form .form-input {
  font-size: 0.9rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

/* Tarjeta de configuración de inventario */
.inventory-config-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
}

.inventory-config-title {
  font-size: 0.95rem;
  font-weight: 600;
}

/* Labels un poco más pequeños dentro de la config */
.inventory-config-card .form-label {
  font-size: 0.85rem;
}

/* Botón de eliminar inventario con estilo “danger” */
.btn-ghost.danger {
  color: #ef4444;
  border-color: transparent;
}

.btn-ghost.danger:hover {
  background-color: rgba(239, 68, 68, 0.06);
  border-color: #ef4444;
  color: #ef4444;
}

/* Pequeños textos de ayuda dentro de la config */
.inventory-config-card small,
.inventory-config-card p {
  font-size: 0.8rem;
}

/* En pantallas pequeñas que la fila de productos no explote el layout */
@media (max-width: 768px) {
  #product-form {
    flex-direction: column;
    align-items: stretch;
  }

  #product-form > div {
    flex: 1 1 100% !important;
  }
}

/* ────────────────────────────────────────────── */
/* Inventarios – botón de configuración (...)    */
/* ────────────────────────────────────────────── */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background-color: var(--surface);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition-fast);
}

.btn-icon i.feather,
.btn-icon i[data-feather] {
  width: 18px;
  height: 18px;
}

.btn-icon:hover {
  background-color: var(--bg);
  border-color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Estado activo cuando el panel de configuración está abierto */
.inventory-config-toggle.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.inventory-config-toggle.active i.feather,
.inventory-config-toggle.active i[data-feather] {
  color: inherit;
}

/* Tarjeta de configuración de inventario (por si no la tenías) */
.inventory-config-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
}

.inventory-config-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.inventory-config-card .form-label {
  font-size: 0.85rem;
}

/* Botón de eliminar inventario con estilo “danger” */
.btn-ghost.danger {
  color: #ef4444;
  border-color: transparent;
}

.btn-ghost.danger:hover {
  background-color: rgba(239, 68, 68, 0.06);
  border-color: #ef4444;
  color: #ef4444;
}

/* Código de producto autogenerado (solo lectura) */
.inventory-code-input[readonly] {
  background-color: var(--surface);
  cursor: default;
  color: var(--muted);
}

.inventory-code-input::placeholder {
  color: var(--muted);
}

/* Inputs de la fila de productos un poco más compactos */
#product-form .form-input {
  font-size: 0.9rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

/* Responsive fila de productos */
@media (max-width: 768px) {
  #product-form {
    flex-direction: column;
    align-items: stretch;
  }

  #product-form > div {
    flex: 1 1 100% !important;
  }
}


.ai-history-item {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:0.5rem;
}
.ai-history-main {
  flex:1;
  text-align:left;
  background:none;
  border:none;
  padding:0;
  cursor:pointer;
}
.ai-history-menu-btn {
  border:none;
  background:transparent;
  padding:0.25rem;
  cursor:pointer;
}
.ai-history-menu {
  position:relative;
}
.ai-history-menu.ai-history-menu-hidden {
  display:none;
}
.ai-history-menu {
  position:absolute;
  right:0;
  margin-top:0.25rem;
  background:white;
  border:1px solid var(--border);
  border-radius:0.375rem;
  box-shadow:var(--shadow-md);
  z-index:10;
}
.ai-history-menu-item {
  display:block;
  width:100%;
  padding:0.35rem 0.75rem;
  background:none;
  border:none;
  text-align:left;
  font-size:0.85rem;
  cursor:pointer;
}
.ai-history-menu-item.danger {
  color:#b91c1c;
}
.ai-history-menu-item:hover {
  background:#f3f4f6;
}

/* ────────────────────────────────────────────── */
/* Modal de confirmación Vetsa AI                */
/* ────────────────────────────────────────────── */
.ai-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55); /* sombra oscura */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.ai-modal-dialog {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 45px var(--shadow-color);
  padding: 1.5rem 1.75rem;
  animation: aiModalIn 0.18s ease-out;
}

.ai-modal-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.ai-modal-message {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.ai-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* pequeña animación de entrada */
@keyframes aiModalIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Acciones de la tabla de facturas (tema claro) */
.invoices-page table td button.btn-ghost {
  color: #0f172a;              /* o el color que uses para texto principal */
}

/* Asegurar que el ícono de Feather use ese color */
.invoices-page table td button.btn-ghost svg {
  stroke: currentColor;
}

/* ───────────────────────────────
   LOGIN / AUTH LAYOUT
   ─────────────────────────────── */

.public-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: radial-gradient(circle at top, #e0f4ff 0, #f5f7fb 40%, #f0f2f7 100%);
}

/* Tarjeta principal */
.public-layout .auth-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 1.25rem;
  padding: 2.5rem 2.25rem 2.25rem;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(148, 163, 184, 0.08);
  box-sizing: border-box;
}

/* Animación sutil de entrada */
.fade-in-up {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeInUp 0.5s ease-out forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Títulos */
.auth-title {
  font-size: 1.7rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 0.25rem;
}

.auth-subtitle {
  margin: 0 0 1.75rem;
  font-size: 0.95rem;
  color: #6b7280;
}

/* Formulario */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Grupos de campos */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4b5563;
}

/* Inputs */
.form-input {
  border-radius: 0.75rem;
  border: 1px solid #e5e7eb;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
  background-color: #f9fafb;
}

.form-input::placeholder {
  color: #9ca3af;
}

.form-input:focus {
  border-color: #0e7680;
  background-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(14, 118, 128, 0.18);
}

/* Recordarme + Olvidé contraseña */
.auth-extras-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #4b5563;
  cursor: pointer;
}

.checkbox-inline input[type="checkbox"] {
  width: 14px;
  height: 14px;
  border-radius: 0.3rem;
  border: 1px solid #d1d5db;
  accent-color: #0e7680;
}

/* Botón tipo link (Olvidé contraseña / Crear cuenta) */
.link-button {
  border: none;
  padding: 0;
  margin: 0;
  background: none;
  font-size: 0.82rem;
  font-weight: 500;
  color: #0e7680;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.link-button:hover {
  color: #075861;
}

.link-button:focus-visible {
  outline: 2px solid rgba(14, 118, 128, 0.4);
  outline-offset: 2px;
}

/* Botones principales */
.auth-card .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease,
    box-shadow 0.15s ease;
}

.auth-card .btn-full {
  width: 100%;
}

/* Botón primario (Iniciar sesión) */
.auth-card .btn-primary {
  background: linear-gradient(135deg, #0e7680, #0591a0);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(14, 118, 128, 0.25);
}

.auth-card .btn-primary:hover {
  background: linear-gradient(135deg, #0c5f66, #047482);
  box-shadow: 0 14px 26px rgba(14, 118, 128, 0.32);
  transform: translateY(-1px);
}

.auth-card .btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 8px 16px rgba(14, 118, 128, 0.25);
}

/* Botón Google */
.auth-card .btn-outline {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #374151;
}

.auth-card .btn-outline:hover {
  background: #ffffff;
  border-color: #d1d5db;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

/* Icono Google */
.auth-google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Sección botones + divisor */
.auth-actions {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Divider "o" */
.auth-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: lowercase;
  gap: 0.75rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, #e5e7eb);
}

.auth-divider::after {
  background: linear-gradient(to left, transparent, #e5e7eb);
}

/* Footer registro */
.auth-footer {
  margin-top: 1.8rem;
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
}

/* Estados deshabilitado */
.auth-card .btn:disabled,
.auth-card .btn[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Responsive pequeño */
@media (max-width: 480px) {
  .public-layout .auth-card {
    padding: 2rem 1.5rem 1.75rem;
    border-radius: 1rem;
  }

  .auth-title {
    font-size: 1.45rem;
  }

  .auth-extras-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Vetsa Admin – estilos de tabla de usuarios */
.data-table .user-uid-cell code {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #f3f4f6;
}

.data-table .user-name-cell,
.data-table .user-email-cell {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table .user-select {
  font-size: 0.85rem;
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
}

/* Colores suaves según estado de acceso */
.data-table .user-row--active {
  background: rgba(34, 197, 94, 0.04);
}

.data-table .user-row--pending {
  background: rgba(234, 179, 8, 0.05);
}

.data-table .user-row--blocked {
  background: rgba(248, 113, 113, 0.06);
}

