/* ==== Paleta base ==== */
:root{
  --bg: #f6f8fc;
  --nav: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primaryblack: #333333;
  --alert:  #ddf105;
  --green: #05ce7e;
  --border: #e5e7eb;
  --border-alt: #dee2e6;
  --shadow: 6px 6px 1px rgba(15,23,42,.20);
  
  /* Colores adicionales */
  --bg-hover: #f9fafb;
  --bg-light: #f8fafc;
  --bg-pattern: #f2f1dfd3;
  --text-secondary: #334155;
  --text-placeholder: #9aa4b2;
  
  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 12px;
  --radius-pill: 999px;
}

/* ==== Base general ==== */
body{
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

h1,h2,h3,h4,h5{
  color: var(--text);
  font-weight: 600;
}

/* ==== Navbar ==== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1030; /* sobre tarjetas y sidebars */
  background: var(--nav) !important;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.navbar .navbar-brand,
.navbar .btn,
.navbar .ms-2{
  color: var(--text) !important;
}
.navbar .btn-outline-light{
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.navbar .btn-outline-light:hover{
  background: var(--border) !important;
  color: var(--text) !important;
}

/* ==== Cards ==== */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
}

.card-light{
  background: var(--card);
  border: 1px dashed var(--primaryblack);
  color: var(--text);
  border-radius: var(--radius-xl);
}
.card.p-4{
  padding: 1.25rem !important;
}

/* ==== Botones ==== */
.btn-primary{
  background: var(--primary);
  border-color: var(--primary);
}

.btn-alert{
  background: var(--alert);
  border-color: var(--primary);
}

.btn-green{
  background: var(--green);
  border-color: var(--primary);
}

.btn-primary:hover{
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-outline-light{
  color: var(--text);
  border-color: var(--border);
}
.btn-outline-light:hover{
  background: var(--border);
  color: var(--text);
}

/* ==== Formularios (inputs sin clases Bootstrap) ==== */
.card input[type="text"],
.card input[type="password"],
.card input[type="number"],
.card input[type="email"],
.card input[type="file"],
.card select,
.card textarea{
  width: 100%;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .8rem 1rem;
  font-size: 1rem;
  outline: 0;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.card input:focus,
.card select:focus,
.card textarea:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(79, 70, 229, 0.1);
}
.card input::placeholder,
.card textarea::placeholder{
  color: var(--text-placeholder);
}
.card textarea{
  min-height: 120px;
}
.form-label{
  color: var(--text-secondary);
  font-weight: 500;
}

/* ==== Tablas (modo claro aunque usen .table-dark) ==== */
.table-dark{
  background: var(--card);
  color: var(--text);
}
.table-dark thead th{
  border-bottom: 1px solid var(--border);
}
.table-dark tbody td{
  border-top: 1px solid var(--border);
}

/* ==== Resumen (tarjetas de métricas) ==== */
/* Tarjetas */
.resumen {
  background: var(--card);
  color: var(--text);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: 0 3px 6px rgba(0,0,0,0.08);
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), box-shadow 0.35s ease;
}
.resumen:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 18px rgba(0,0,0,0.12);
}
.resumen i { color: var(--primary); display: block; transition: transform .3s ease; }
.resumen:hover i { transform: scale(1.06); }
.resumen span { display:block; font-weight:500; color: var(--muted,#666); }
.resumen h2 { font-weight:700; font-size:1.4rem; color: var(--primary); margin-top:.25rem; }

/* Fade-in al cargar */
.fade-in { opacity: 0; transform: translateY(6px); animation: fadeUp .5s ease forwards; }
.fade-in:nth-child(1) { animation-delay: .05s; }
.fade-in:nth-child(2) { animation-delay: .12s; }
.fade-in:nth-child(3) { animation-delay: .19s; }
.fade-in:nth-child(4) { animation-delay: .26s; }

@keyframes fadeUp {
  to { opacity:1; transform: translateY(0); }
}


/* =========================================================
   LOGIN
   ========================================================= */

/* Responsive */
@media (min-width: 768px){
  .login-container{ max-width: 400px; }
}
@media (min-width: 992px){
  .login-container{ max-width: 440px; }
}
.pattern-dots{
  background-color: var(--bg-pattern);
  background-image: radial-gradient(#cccac9 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Tarjeta moderna tipo index */
.card-modern{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

/* Inputs dentro de la card moderna - heredan estilos de .card */
.card-modern input[type="text"],
.card-modern input[type="password"],
.card-modern input[type="email"]{
  width: 100%;
  border: 1px solid var(--border-alt);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  outline: 0;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.card-modern input:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(79, 70, 229, 0.1);
}

/* =========================================================
   FIN LOGIN
   ========================================================= */

/* ==== General ==== */
.alert{
  border-radius: var(--radius-md);
}
.btn{
  white-space: nowrap;
}


/* ======= FULL-WIDTH PAGE ======= */
.page-full { max-width: 100vw; }

/* ======= GRAIL WIDE GRID ======= */
.grail-wide{
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px; /* izq | contenido | der */
  gap: 1rem;
  align-items: start;
}

/* Columna central (evita overflow y permite tablas fluidas) */
.grail-wide .content{
  min-width: 0; /* importante para que .table-responsive funcione bien */
}

/* Sidebars */
.sidebar{
  border-radius: var(--radius-xl);
}

/* ==== Sidebars fijas ==== */
.sticky-sidebar {
  position: sticky;
  top: 80px; /* altura del navbar */
  align-self: start; /* mantiene la altura natural */
  max-height: calc(100vh - 90px);
  overflow: visible;
}

.left-rail,
.right-sidebar{
  display: block;
}

.no-sidebar .grail-wide{
  grid-template-columns: minmax(0, 1fr);
}
.no-sidebar .left-rail,
.no-sidebar .right-sidebar{
  display: none;
}

/* Pantallas grandes: más aire */
@media (min-width: 1400px){
  .grail-wide{
    grid-template-columns: 320px minmax(0, 1fr) 360px;
    gap: 1.25rem;
  }
}

/* Mobile layout */
@media (max-width: 991.98px){
  .grail-wide{
    grid-template-columns: 1fr;
  }
  .left-rail,
  .right-sidebar{
    display: none;
  }
  .sticky-sidebar{
    position: static;
    max-height: none;
  }
}

/* List group estilo claro */
.list-group-item{
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  padding: .6rem .75rem;
}
.list-group-item:hover{
  background: var(--bg-pattern);
  border-left-color: var(--primary);
  color: var(--text);
}

/* Stepper simple */
.page-stepper {
  display: flex; align-items: center; gap: .75rem;
}
.page-stepper .divider {
  flex: 1; height: 2px; background: var(--bs-border-color);
  opacity: .6;
}
.page-stepper .step {
  display: flex; align-items: center; gap: .5rem; white-space: nowrap;
  color: var(--bs-secondary-color);
}
.page-stepper .step .bullet {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--bs-border-color);
  font-size: .9rem;
  background: var(--bs-body-bg);
}
.page-stepper .step.active .bullet {
  background: var(--bs-primary-bg-subtle);
  color: var(--bs-primary-text);
  border-color: var(--bs-primary);
}
.page-stepper .step.active .label { color: var(--bs-body-color); }

/* Card del formulario */
.form-card { overflow: hidden; }
.form-card .card-section { padding: 1rem 1rem; }
@media (min-width: 992px) {
  .form-card .card-section { padding: 1.25rem 1.25rem; }
}
.card-section + .card-section {
  border-top: 1px solid var(--bs-border-color);
}
.card-section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: .75rem;
}

/* Inputs */
.input-group-text { background: var(--bs-body-bg); }

/* Acciones sticky (queda siempre visible al final de la card) */
.sticky-actions {
  position: sticky; bottom: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0), var(--bs-body-bg) 35%);
  padding: 1rem 1rem .75rem; margin-top: .25rem;
  border-top: 1px solid var(--bs-border-color);
}

/* Lateral */
.check-dot {
  width: .6rem; height: .6rem; border-radius: 50%;
  background: var(--bs-primary); display: inline-block;
}

/* === Busqueda de cliente en cuentas nuevas === */

/* Oculto por defecto */
#cliente-buscando { 
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* HTMX lo muestra cuando hay request */
#cliente-buscando.htmx-request { 
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 1;
  animation: holdVisible 0.6s both;
}

/* Forzar a que se mantenga visible al menos 0.6s */
@keyframes holdVisible {
  from { opacity: 1; }
  to { opacity: 1; }
}

/* ====== Tabla limpia - Dashboard ====== */
.table-clean {
  background: var(--card);
  color: var(--text);
  border-collapse: separate;
  border-spacing: 0;
  
}

.table-clean thead th {
  font-weight: 600;
  color: whitesmoke;
  border-bottom: 1px solid var(--border);
  background: var(--primaryblack)
}

.table-clean tbody td {
  border-top: 1px solid var(--border);
}

.table-compact th,
.table-compact td {
  padding: .35rem .55rem;
}

.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.currency {
  font-variant-numeric: tabular-nums;
}

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* Badge suave para método de pago */
.badge-soft {
  display: inline-block;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: .8rem;
  background: var(--bg-light);
  color: var(--text-secondary);
}

/* Truncar referencias largas sin romper layout */
.truncate-14 {
  max-width: 14rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty state elegante */
.empty-state {
  text-align: center;
  padding: 1.25rem .5rem;
  color: var(--muted);
}
.empty-title {
  font-weight: 600; color: var(--text);
}
.empty-text { font-size: .95rem; }

/* Hover sutil en filas */
.table-clean.table-hover tbody tr:hover td {
  background: var(--bg-hover);
}

.is-invalid {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 .25rem rgba(220,53,69,.25);
}

/* Feedback de error en formularios */
.invalid-feedback {
  display: block;
  font-weight: 500;
  color: #dc3545;
  background-color: #fff5f5;
  border-radius: var(--radius-sm);
  padding: .25rem .5rem;
  margin-top: .25rem;
}

.mobile-quick-card{
  margin-bottom: 1rem;
}
.mobile-quick-card .card{
  border-radius: var(--radius-xl);
}
.mobile-welcome{
  font-weight: 600;
  color: var(--text-secondary);
}
.quick-actions-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}
.quick-action{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding-block: .85rem;
  font-weight: 600;
  text-align: center;
}
.quick-action i{
  font-size: 1.3rem;
}
.quick-action span{
  font-size: .9rem;
  line-height: 1.2;
}
.mobile-links .list-group-item{
  padding: .6rem .75rem;
}
.mobile-links .badge{
  font-size: .75rem;
}
@media (min-width: 576px){
  .quick-actions-grid{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (min-width: 768px){
  .mobile-quick-card{
    display: none;
  }
}

.mobile-client-card{
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 10px rgba(15,23,42,0.08);
  margin-bottom: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
}
.mobile-account-card{
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .6rem .75rem;
  margin-top: .6rem;
  background: var(--card);
}
.mobile-account-card .btn{
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mobile-payment-card{
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--card);
  padding: .85rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 10px rgba(15,23,42,0.08);
}
.payment-tags{
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.payment-tags .badge-soft{
  font-size: .75rem;
}
.payment-actions{
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .4rem;
}
.payment-actions .btn{
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}