/* ==========================================================================
   AutoFacturas Theme — Adaptación Stitch / Next.js a FacturaScripts nativo
   Stack: PHP + Twig + Bootstrap 5
   Palette: Sky/Cyan (#0ea5e9), Dark Navy (#0f172a), Fiscal Mint (#10b981)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. VARIABLES DE DISEÑO & OVERRIDES BOOTSTRAP 5
   -------------------------------------------------------------------------- */
:root {
  /* Tokens de Marca & Superficies */
  --af-navy: #0f172a;
  --af-navy-dark: #090d16;
  --af-navy-card: #1e293b;
  --af-cyan: #0ea5e9;
  --af-cyan-hover: #0284c7;
  --af-cyan-active: #0369a1;
  --af-cyan-light: #f0f9ff;
  --af-cyan-border: #bae6fd;
  --af-emerald: #10b981;
  --af-emerald-light: #ecfdf5;
  --af-slate-bg: #f8fafc;
  --af-slate-surface: #ffffff;
  --af-slate-border: #e2e8f0;
  --af-slate-border-light: #f1f5f9;
  --af-slate-muted: #64748b;
  --af-slate-dark: #334155;

  /* Bootstrap 5 Tokens */
  --bs-primary: #0ea5e9;
  --bs-primary-rgb: 14, 165, 233;
  --bs-link-color: #0284c7;
  --bs-link-color-rgb: 2, 132, 199;
  --bs-link-hover-color: #0369a1;
  --bs-link-hover-color-rgb: 3, 105, 161;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-bg: #f8fafc;
  --bs-body-color: #0f172a;
  --bs-secondary-color: #64748b;
  --bs-border-color: #e2e8f0;
  --bs-border-radius: 8px;
  --bs-border-radius-sm: 6px;
  --bs-border-radius-lg: 12px;
  --bs-card-border-radius: 12px;
}

/* --------------------------------------------------------------------------
   2. TIPOGRAFÍA & RENDERIZADO GLOBAL
   -------------------------------------------------------------------------- */
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
}

body {
  background-color: var(--af-slate-bg);
  color: var(--af-navy);
  font-family: var(--bs-body-font-family);
  font-size: 0.875rem;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--af-navy);
  letter-spacing: -0.022em;
  font-weight: 600;
}

/* Alineación monoespaciada para datos contables y tablas */
.tabular-nums,
.table td.text-end,
.table th.text-end,
.text-end {
  font-variant-numeric: tabular-nums;
}

/* Scrollbar moderno ultra-fino */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* --------------------------------------------------------------------------
   3. BARRA DE NAVEGACIÓN SUPERIOR (DARK NAVY - ESTILO NEXT.JS)
   -------------------------------------------------------------------------- */
.navbar.autofact-navbar,
.navbar.bg-primary,
.navbar.navbar-dark {
  background-color: var(--af-navy) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.2);
  min-height: 60px;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.autofact-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background-color: transparent !important;
  box-shadow: none !important;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.autofact-logo-mark:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

.autofact-brand-name {
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 1.1;
}

.autofact-brand-subtitle {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 1px;
}

.navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.navbar .nav-link {
  color: rgba(255, 255, 255, 0.85) !important;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  transition: all 0.15s ease-in-out;
}

.navbar .nav-link:hover {
  color: #ffffff !important;
  background-color: rgba(255, 255, 255, 0.08);
}

.navbar .nav-link.active {
  color: #38bdf8 !important;
  background-color: rgba(14, 165, 233, 0.15);
  font-weight: 600;
}

/* Micro-Badges de Icono en el Navbar Principal */
.af-nav-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.navbar .nav-link:hover .af-nav-pill-icon {
  transform: translateY(-1px) scale(1.08);
  filter: brightness(1.2);
}

.af-nav-badge-cyan {
  background-color: rgba(14, 165, 233, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.35);
}

.af-nav-badge-rose {
  background-color: rgba(244, 63, 94, 0.18);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.af-nav-badge-emerald {
  background-color: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.af-nav-badge-amber {
  background-color: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.af-nav-badge-purple {
  background-color: rgba(139, 92, 246, 0.18);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.af-nav-badge-indigo {
  background-color: rgba(99, 102, 241, 0.18);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.af-nav-badge-slate {
  background-color: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Botones de acción derecha de la Navbar (Búsqueda, Dashboard, Usuario) */
.nav-icon-pill {
  width: 34px;
  height: 34px;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 8px !important;
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1 !important;
  font-size: 0.875rem;
}

.nav-icon-pill:hover,
.nav-icon-pill.active {
  background-color: rgba(14, 165, 233, 0.18) !important;
  color: #38bdf8 !important;
  border-color: rgba(14, 165, 233, 0.35) !important;
}

.navbar .dropdown-menu {
  background-color: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.45);
  padding: 0.45rem;
  min-width: 230px;
}

.af-submenu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 0.825rem;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.af-submenu-title {
  font-size: 0.825rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.navbar .dropdown-item {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.825rem;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transition: all 0.12s ease;
  margin-bottom: 2px;
}

.navbar .dropdown-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.navbar .dropdown-item:hover .af-submenu-icon {
  transform: scale(1.08);
  filter: brightness(1.2);
}

.navbar .dropdown-item.active {
  background-color: rgba(14, 165, 233, 0.18);
  color: #38bdf8;
  font-weight: 600;
}

.navbar .dropdown-divider {
  border-top-color: rgba(255, 255, 255, 0.1);
  margin: 0.35rem 0.5rem;
}

/* --------------------------------------------------------------------------
   4. SUBNAV HORIZONTAL (Pestañas Rápidas estilo SubNav.tsx)
   -------------------------------------------------------------------------- */
.autofact-subnav {
  background-color: #ffffff;
  border-bottom: 1px solid var(--af-slate-border);
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
  position: relative;
  z-index: 30;
}

.autofact-subnav-scroll {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.45rem 0;
  scrollbar-width: none;
}

.autofact-subnav-scroll::-webkit-scrollbar {
  display: none;
}

.autofact-subnav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.815rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.15s ease-in-out;
}

.autofact-subnav-link:hover {
  color: var(--af-navy);
  background-color: #f1f5f9;
}

.autofact-subnav-link.active {
  color: var(--af-cyan-hover);
  background-color: var(--af-cyan-light);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--af-cyan);
  border-radius: 8px 8px 0 0;
}

/* Micro-cajita de icono para pestañas de SubNav */
.af-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.autofact-subnav-link:hover .af-tab-icon {
  transform: translateY(-1px) scale(1.08);
}

/* --------------------------------------------------------------------------
   4.1 SISTEMA DE ICONOGRAFÍA Y CONTENEDORES (Icon-Boxes & Badges)
   -------------------------------------------------------------------------- */
.af-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  font-size: 1.15rem;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.af-icon-box-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.af-icon-box-lg {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 1.45rem;
}

/* Variantes Semánticas de Icon-Boxes */
.af-icon-cyan {
  background-color: #f0f9ff;
  color: #0ea5e9;
  border: 1px solid #bae6fd;
}

.af-icon-emerald {
  background-color: #ecfdf5;
  color: #10b981;
  border: 1px solid #a7f3d0;
}

.af-icon-rose {
  background-color: #fff1f2;
  color: #f43f5e;
  border: 1px solid #fecdd3;
}

.af-icon-amber {
  background-color: #fffbeb;
  color: #f59e0b;
  border: 1px solid #fde68a;
}

.af-icon-indigo {
  background-color: #eef2ff;
  color: #6366f1;
  border: 1px solid #c7d2fe;
}

.af-icon-purple {
  background-color: #f5f3ff;
  color: #8b5cf6;
  border: 1px solid #ddd6fe;
}

.af-icon-slate {
  background-color: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.af-icon-dark {
  background-color: #1e293b;
  color: #38bdf8;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Hover interactivo para icon-boxes dentro de tarjetas */
.card:hover .af-icon-box {
  transform: scale(1.04);
}

/* Iconos dentro de botones */
.btn i, .btn svg {
  margin-right: 0.35rem;
  font-size: 0.9em;
  vertical-align: -0.05em;
}

.btn-sm i, .btn-sm svg {
  margin-right: 0.25rem;
}

/* Iconos en inputs / formularios */
.input-group:focus-within .input-group-text i {
  color: var(--af-cyan);
  transition: color 0.15s ease;
}

.input-group-text i {
  color: #94a3b8;
  font-size: 0.9rem;
}

/* Iconos en tablas */
.table td i {
  color: #64748b;
  font-size: 0.875rem;
}

.table td a:hover i {
  color: var(--af-cyan);
}

/* --------------------------------------------------------------------------
   5. BOTONES Y ACCIONES (Rounded-Astryx 8px)
   -------------------------------------------------------------------------- */
.btn {
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 500;
  padding: 0.42rem 0.85rem;
  transition: all 0.15s ease-in-out;
}

.btn-primary {
  --bs-btn-bg: #0ea5e9;
  --bs-btn-border-color: #0ea5e9;
  --bs-btn-hover-bg: #0284c7;
  --bs-btn-hover-border-color: #0284c7;
  --bs-btn-active-bg: #0369a1;
  --bs-btn-active-border-color: #0369a1;
  font-weight: 600;
  box-shadow: 0 1px 2px 0 rgba(14, 165, 233, 0.25);
}

.btn-outline-primary {
  --bs-btn-color: #0284c7;
  --bs-btn-border-color: #bae6fd;
  --bs-btn-hover-bg: #0ea5e9;
  --bs-btn-hover-border-color: #0ea5e9;
}

.btn-success {
  --bs-btn-bg: #10b981;
  --bs-btn-border-color: #10b981;
  --bs-btn-hover-bg: #059669;
  --bs-btn-hover-border-color: #059669;
}

.btn-light {
  --bs-btn-bg: #ffffff;
  --bs-btn-border-color: #e2e8f0;
  --bs-btn-hover-bg: #f8fafc;
  --bs-btn-hover-border-color: #cbd5e1;
  color: #334155;
}

/* --------------------------------------------------------------------------
   6. TARJETAS Y PANELES (Rounded 12px & Micro-Borders)
   -------------------------------------------------------------------------- */
.card {
  border: 1px solid var(--af-slate-border);
  border-radius: 12px;
  background-color: #ffffff;
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card.shadow,
.card.shadow-sm {
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04) !important;
}

.card-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--af-slate-border-light);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--af-navy);
  padding: 0.85rem 1.15rem;
  border-top-left-radius: 12px !important;
  border-top-right-radius: 12px !important;
}

.card-footer {
  background-color: var(--af-slate-bg);
  border-top: 1px solid var(--af-slate-border-light);
  padding: 0.75rem 1.15rem;
  border-bottom-left-radius: 12px !important;
  border-bottom-right-radius: 12px !important;
}

/* --------------------------------------------------------------------------
   7. TABLAS MAESTRAS & LISTADOS (ListView / EditListView)
   -------------------------------------------------------------------------- */
.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
  vertical-align: middle;
}

.table thead th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--af-slate-muted);
  background-color: var(--af-slate-bg);
  border-bottom: 1px solid var(--af-slate-border);
  font-weight: 700;
  padding: 0.65rem 0.85rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--af-slate-border-light);
  font-size: 0.835rem;
  color: #1e293b;
}

.table-hover tbody tr:hover {
  background-color: #f8fafc !important;
}

.clickableRow,
.clickableListRow {
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   8. FORMULARIOS & BUSCADORES (Inputs con Focus Ring Cyan)
   -------------------------------------------------------------------------- */
.form-control,
.form-select {
  border-radius: 8px;
  border: 1px solid var(--af-slate-border);
  font-size: 0.835rem;
  padding: 0.45rem 0.75rem;
  color: #0f172a;
  background-color: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--af-cyan);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
  outline: none;
}

.input-group-text {
  border-radius: 8px;
  border-color: var(--af-slate-border);
  background-color: var(--af-slate-bg);
  color: var(--af-slate-muted);
  font-size: 0.835rem;
}

.form-label,
label {
  font-size: 0.765rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.3rem;
}

/* --------------------------------------------------------------------------
   9. BADGES & STATUS PILLS (9999px)
   -------------------------------------------------------------------------- */
.badge {
  border-radius: 9999px;
  padding: 0.35em 0.75em;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge.bg-primary {
  background-color: var(--af-cyan) !important;
}

.badge.bg-success {
  background-color: #10b981 !important;
}

.badge.bg-light {
  background-color: #f1f5f9 !important;
  color: #475569 !important;
  border: 1px solid var(--af-slate-border);
}

/* --------------------------------------------------------------------------
   10. PESTAÑAS (Nav-Tabs & Nav-Pills de FacturaScripts)
   -------------------------------------------------------------------------- */
.nav-tabs {
  border-bottom: 1px solid var(--af-slate-border);
}

.nav-tabs .nav-link {
  font-size: 0.835rem;
  font-weight: 500;
  color: #64748b;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1rem;
  transition: all 0.15s ease;
}

.nav-tabs .nav-link:hover {
  color: var(--af-navy);
  border-bottom-color: #cbd5e1;
}

.nav-tabs .nav-link.active {
  color: var(--af-cyan-hover);
  border-bottom: 2px solid var(--af-cyan);
  font-weight: 600;
  background-color: transparent;
}

.nav-pills .nav-link.active {
  background-color: var(--af-cyan);
}

/* --------------------------------------------------------------------------
   11. MODALES Y DIÁLOGOS
   -------------------------------------------------------------------------- */
.modal-content {
  border-radius: 12px;
  border: 1px solid var(--af-slate-border);
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.15);
}

.modal-header {
  border-bottom: 1px solid var(--af-slate-border-light);
  padding: 1rem 1.25rem;
}

.modal-footer {
  border-top: 1px solid var(--af-slate-border-light);
  padding: 0.85rem 1.25rem;
}

/* --------------------------------------------------------------------------
   12. PÁGINA DE LOGIN & ONBOARDING
   -------------------------------------------------------------------------- */
.autofact-onboarding-hero {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
}

.autofact-login-page {
  min-height: 100vh;
  background-color: #0f172a;
  background-image: radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.18), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(14, 165, 233, 0.12), transparent 45%);
}

.autofact-auth-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.autofact-logo-mark-lg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 48px;
  padding: 6px;
  border-radius: 12px;
  background-color: #ffffff;
  color: var(--af-cyan);
  font-size: 1.4rem;
}
