/* ─── Paleta de colores Sensitive ERP ─── */
:root {
  --brand-primary:   #2563EB;   /* azul corporativo */
  --brand-secondary: #1E40AF;   /* azul oscuro */
  --brand-accent:    #3B82F6;   /* azul claro */
  --sidebar-bg:      #0F172A;   /* slate-900 */
  --sidebar-text:    #CBD5E1;   /* slate-300 */
  --sidebar-active:  #2563EB;
  --topbar-bg:       #FFFFFF;
  --topbar-border:   #E2E8F0;
  --body-bg:         #F8FAFC;
}

body {
  background-color: var(--body-bg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ─── Sidebar ─── */
#sidebar {
  width: 240px;
  min-height: 100vh;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  transition: width 0.25s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  color: #FFFFFF;
  text-decoration: none;
}

.sidebar-brand:hover { color: var(--brand-accent); }

.sidebar-divider {
  border-color: rgba(255,255,255,0.1);
}

#sidebar .nav-link {
  color: var(--sidebar-text);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
}

#sidebar .nav-link:hover {
  background-color: rgba(255,255,255,0.08);
  color: #FFFFFF;
}

#sidebar .nav-link.active {
  background-color: var(--sidebar-active);
  color: #FFFFFF;
}

/* label de sección de administración en sidebar */
.sidebar-section-label {
  color: #64748b;   /* slate-500 */
  font-size: .68rem;
  letter-spacing: .06em;
}

/* sub-items (Timbrados, Clasificación) — override Bootstrap .text-muted */
#sidebar .nav-link.text-muted {
  color: #94a3b8 !important;   /* slate-400 — visible sobre fondo oscuro */
}

#sidebar .nav-link.text-muted:hover {
  color: #e2e8f0 !important;
  background-color: rgba(255,255,255,0.06);
}

#sidebar .nav-link.text-muted.active {
  color: #FFFFFF !important;
  background-color: var(--sidebar-active);
}

.sidebar-footer {
  color: var(--sidebar-text);
  font-size: 0.8rem;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .02em;
}

.sidebar-footer-info {
  line-height: 1.2;
}

.sidebar-footer-name {
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
}

.sidebar-footer-role {
  color: var(--sidebar-text);
  font-size: .72rem;
  opacity: .75;
}

.sidebar-footer-action {
  color: var(--sidebar-text);
  font-size: 1.35rem;
  opacity: .7;
  transition: opacity .15s, color .15s;
  text-decoration: none;
  padding: .25rem;
}

.sidebar-footer-action:hover {
  opacity: 1;
  color: #f87171;
}

/* ─── Botón colapsar/expandir junto al logo ─── */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--sidebar-text-muted, #94a3b8);
  border-radius: 6px;
  font-size: .85rem;
  transition: background-color .15s, color .15s;
}
.sidebar-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
@media (max-width: 767.98px) {
  .sidebar-collapse-btn { display: none; }
}

/* ─── Sidebar collapsed ─── */
#app-wrapper.sidebar-collapsed #sidebar {
  width: 64px;
}

/* Ocultar todos los textos de nav */
#app-wrapper.sidebar-collapsed #sidebar .nav-link-text,
#app-wrapper.sidebar-collapsed .sidebar-brand-text,
#app-wrapper.sidebar-collapsed .sidebar-footer-info,
#app-wrapper.sidebar-collapsed .sidebar-footer-action {
  display: none !important;
}

/* Brand: centrar logo, fila pasa a columna para acomodar el botón debajo */
#app-wrapper.sidebar-collapsed .sidebar-brand-row {
  flex-direction: column;
  gap: .35rem;
}

#app-wrapper.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 0;
  flex-grow: 0;
}

#app-wrapper.sidebar-collapsed .sidebar-collapse-btn i::before {
  content: "\f285"; /* bi-chevron-right */
}

#app-wrapper.sidebar-collapsed .sidebar-logo {
  width: 34px;
  height: 34px;
  margin: 0 !important;
}

/* Nav links: centrar íconos */
#app-wrapper.sidebar-collapsed #sidebar .nav-link {
  justify-content: center;
  padding: 0.6rem;
}

#app-wrapper.sidebar-collapsed #sidebar .nav-link i {
  margin: 0 !important;
  font-size: 1.2rem;
}

/* Anular el sangrado de sub-items (Clasificación, Depósitos, Cotizaciones)
   para que sus íconos queden centrados igual que el resto */
#app-wrapper.sidebar-collapsed #sidebar .nav-item {
  padding-left: 0 !important;
}

/* Footer: solo avatar */
#app-wrapper.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding: 0;
}

#app-wrapper.sidebar-collapsed .sidebar-avatar {
  width: 34px;
  height: 34px;
}

/* ─── Topbar ─── */
.topbar {
  background-color: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ─── Cards ─── */
.card {
  border-radius: 12px;
}

/* ─── Spinner animación ─── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin .7s linear infinite; }

/* ─── Toast notifications ─── */
#s-toast-container {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  min-width: 320px;
  max-width: 480px;
  width: max-content;
}

.s-toast {
  background: #fff;
  border-radius: .6rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.14);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
  width: 100%;
}

/* ─── Mobile (< 768px) ─── */
@media (max-width: 767.98px) {

  /* Sidebar: overlay deslizante en mobile */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 240px !important;
  }

  #sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* Backdrop semitransparente al abrir sidebar */
  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
  }
  #sidebar-backdrop.show { display: block; }

  /* El contenido principal ocupa todo el ancho */
  #app-wrapper {
    flex-direction: column;
  }
  .flex-grow-1 { width: 100%; }

  /* Topbar: más compacta */
  .topbar { height: 48px; padding: 0 .75rem !important; }
  .topbar-center { display: none !important; }

  /* Contenido: menos padding lateral */
  .main-content, main { padding: .75rem !important; }
}

.s-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.s-toast-body {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem 1rem;
}

.s-toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.s-toast-msg {
  flex: 1;
  font-size: .875rem;
  line-height: 1.4;
  color: #1e293b;
}

.s-toast-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #94a3b8;
  padding: 0;
  line-height: 1;
}

.s-toast-close:hover { color: #475569; }

.s-toast-progress {
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: .35;
  transform-origin: left;
  animation: s-toast-shrink linear forwards;
}

@keyframes s-toast-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* colores por tipo */
.s-toast--success .s-toast-icon { color: #16a34a; }
.s-toast--success .s-toast-progress { color: #16a34a; }
.s-toast--danger  .s-toast-icon { color: #dc2626; }
.s-toast--danger  .s-toast-progress { color: #dc2626; }
.s-toast--warning .s-toast-icon { color: #d97706; }
.s-toast--warning .s-toast-progress { color: #d97706; }
.s-toast--info    .s-toast-icon { color: #2563eb; }
.s-toast--info    .s-toast-progress { color: #2563eb; }

/* ─── Login ─── */
.login-bg {
  background: linear-gradient(135deg, #0F172A 0%, #1E3A5F 50%, #2563EB 100%);
}

.login-card {
  border-radius: 16px;
}

.login-brand-panel {
  max-width: 380px;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  opacity: 0.88;
  flex-shrink: 0;
}

.login-logo {
  max-height: 64px;
  width: auto;
}

.login-logo-panel {
  max-height: 120px;
  width: auto;
  border-radius: 50%;
  opacity: 0.92;
}

.login-logo-mobile {
  max-height: 90px;
  width: auto;
  border-radius: 50%;
}

/* Input groups sin borde doble */
.input-group .form-control:focus {
  box-shadow: none;
  border-color: var(--brand-primary);
}

.input-group:focus-within .input-group-text,
.input-group:focus-within .form-control,
.input-group:focus-within .btn {
  border-color: var(--brand-primary);
}

/* Input-group unificado: contenedor con borde único */
.input-group {
  border: 1px solid #dee2e6;
  border-radius: .375rem;
  overflow: hidden;
}

.input-group .input-group-text,
.input-group .form-control,
.input-group .btn {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

/* Foco: contorno azul en el contenedor */
.input-group:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* Error: contorno rojo en el contenedor */
.input-group:has(.is-invalid) {
  border-color: #dc3545;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, .15);
}

/* ─── Alerts estilizados ─── */
.alert {
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
}

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

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

/* ─── Tab content wrapper ─── */
.tab-content-wrapper {
  border: 1px solid #dee2e6;
}

/* ─── Breadcrumb en topbar ─── */
.topbar .breadcrumb-item a {
  color: var(--bs-secondary-color);
}
.topbar .breadcrumb-item a:hover {
  color: var(--brand-primary);
}
.topbar .breadcrumb-item + .breadcrumb-item::before {
  color: var(--bs-secondary-color);
}
.topbar .breadcrumb-item.active {
  color: var(--brand-primary);
  font-weight: 600;
}

/* ─── Topbar: centro empresa ─── */
.topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

/* ─── Topbar: avatar con dropdown ─── */
.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
}
.topbar-avatar:hover { opacity: .85; }
.topbar-avatar::after { display: none; }

/* ─── Tabla: header gris oscuro suavizado ─── */
.table-header-dark th {
  background-color: #3a3f4b;
  color: #e9ecef;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  border-bottom: none;
  padding-top: .65rem;
  padding-bottom: .65rem;
}

/* ─── Tabla productos: filas ─── */
.prod-row td { vertical-align: middle; }
.prod-row-inactive td { opacity: .55; }

/* Código badge suave */
.badge-codigo {
  display: inline-block;
  background: #e8f0fe;
  color: #1a56db;
  font-size: .72rem;
  font-weight: 700;
  padding: .2em .55em;
  border-radius: 4px;
  letter-spacing: .02em;
}

/* Impuesto badge atenuado */
.badge-impuesto {
  display: inline-block;
  background: #e9f5fb;
  color: #0077a8;
  font-size: .72rem;
  font-weight: 600;
  padding: .2em .55em;
  border-radius: 4px;
}

/* Estado badge pill pequeño */
.badge-estado {
  display: inline-block;
  font-size: .7rem;
  font-weight: 600;
  padding: .25em .65em;
  border-radius: 20px;
  letter-spacing: .03em;
}
.badge-estado-activo  { background: #d1fae5; color: #065f46; }
.badge-estado-inactivo { background: #f1f5f9; color: #64748b; }

/* Íconos de acción sin caja */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}
.row-action-btn {
  background: none;
  border: none;
  padding: .25rem .3rem;
  font-size: 1rem;
  border-radius: 5px;
  opacity: .45;
  transition: opacity .15s, background .15s;
  cursor: pointer;
  line-height: 1;
  text-decoration: none;
}
.prod-row:hover .row-action-btn { opacity: 1; }
.row-action-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,.06);
}

/* ─── Personas: badges de roles ─── */
.persona-row td { vertical-align: middle; }
.persona-row-inactive td { opacity: .55; }

.badge-rol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 0;
}
.badge-rol-cliente   { background: #dbeafe; color: #1d4ed8; }
.badge-rol-proveedor { background: #d1fae5; color: #065f46; }
.badge-rol-vendedor  { background: #ede9fe; color: #5b21b6; }
.badge-rol-cobrador  { background: #fef3c7; color: #92400e; }
.badge-rol-empleado  { background: #f1f5f9; color: #475569; }
