/* =============================================
   DESIGN SYSTEM - COTIZACIONES LABSUPERFOOD
   ============================================= */

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --secondary:     #64748b;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --info:          #0891b2;
  --surface:       #ffffff;
  --bg:            #f1f5f9;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:        0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition:    all .18s ease;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --primary:       #3b82f6;
  --primary-dark:  #2563eb;
  --primary-light: #1e293b;
  --surface:       #1e293b;
  --bg:            #0f172a;
  --border:        #334155;
  --text:          #e2e8f0;
  --text-muted:    #94a3b8;
  --text-light:    #64748b;
}

[data-theme="dark"] .table thead th { background: #1e293b; }
[data-theme="dark"] .table-hover tbody tr:hover td { background: #334155; }
[data-theme="dark"] .table tbody td { border-bottom-color: #334155; }
[data-theme="dark"] .input-group-text { background: #334155; border-color: #475569; color: #94a3b8; }
[data-theme="dark"] .btn-secondary { background: #334155; border-color: #475569; color: #e2e8f0; }
[data-theme="dark"] .btn-warning { background: #78350f; border-color: #92400e; color: #fef3c7; }
[data-theme="dark"] .btn-danger { background: #7f1d1d; border-color: #991b1b; color: #fee2e2; }
[data-theme="dark"] .btn-info { background: #0c4a6e; border-color: #075985; color: #e0f2fe; }
[data-theme="dark"] .modal-content { background: var(--surface); }
[data-theme="dark"] .modal-header { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .modal-footer { background: #0f172a; border-color: var(--border); }
[data-theme="dark"] .btn-close { filter: invert(1); }
[data-theme="dark"] .cliente-info { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .form-control[readonly] { background: #334155; color: #e2e8f0; border-color: #475569; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fef3c7; }
[data-theme="dark"] .alert-danger { background: #7f1d1d; color: #fee2e2; }
[data-theme="dark"] .btn-outline-secondary:hover { background: #334155; color: #e2e8f0; }

/* Fix centrado botón guardar cotización */
.btn-lg.touch-friendly { justify-content: center; }
.btn-lg.touch-friendly i { color: white !important; }

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== TOPBAR ===== */
.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  text-decoration: none;
}

.app-topbar .brand-icon {
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
}

/* ===== NAVIGATION TABS ===== */
.nav-tabs {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 16px;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tabs .nav-item { flex-shrink: 0; }

.nav-tabs .nav-link {
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tabs .nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-bottom-color: transparent;
}

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

.nav-tabs .nav-link i {
  font-size: 14px;
  opacity: .8;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header i {
  color: var(--primary);
  margin-right: 8px;
}

/* Excluir íconos dentro de botones */
.btn i { color: inherit !important; }
.btn-success i { color: white !important; }
.btn-primary i { color: white !important; }

.card-body { padding: 20px; }

/* ===== BUTTONS ===== */
.btn {
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.btn-success:hover {
  background: #15803d;
  border-color: #15803d;
  color: white;
  transform: translateY(-1px);
}

.btn-warning {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}
.btn-warning:hover {
  background: #fde68a;
  border-color: #fcd34d;
  color: #78350f;
}

.btn-danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}
.btn-danger:hover {
  background: #fecaca;
  border-color: #fca5a5;
  color: #7f1d1d;
}

.btn-info {
  background: #e0f2fe;
  border-color: #bae6fd;
  color: #075985;
}
.btn-info:hover {
  background: #bae6fd;
  border-color: #7dd3fc;
  color: #0c4a6e;
}

.btn-secondary {
  background: #f1f5f9;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: var(--text);
}

.btn-light {
  background: var(--primary-light);
  border-color: #bfdbfe;
  color: var(--primary);
  font-weight: 600;
}
.btn-light:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: var(--primary-dark);
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-outline-secondary:hover {
  background: #f1f5f9;
  color: var(--text);
}

/* ===== FORMS ===== */
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  transition: var(--transition);
  background: var(--surface);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 6px;
}

.input-group-text {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== TABLES ===== */
.table {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 0;
}

.table thead th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  border-top: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 10px 12px;
  white-space: nowrap;
}

.table tbody td {
  border-bottom: 1px solid #f1f5f9;
  padding: 11px 12px;
  vertical-align: middle;
  color: var(--text);
}

.table tbody tr:last-child td { border-bottom: none; }

.table-hover tbody tr:hover td {
  background: #f8fafc;
}

.table-sm thead th { padding: 8px 10px; }
.table-sm tbody td { padding: 8px 10px; }

/* ===== BADGES ===== */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: .2px;
}

.bg-success { background: #dcfce7 !important; color: #15803d !important; }
.bg-warning { background: #fef9c3 !important; color: #a16207 !important; }
.bg-danger  { background: #fee2e2 !important; color: #dc2626 !important; }
.bg-info    { background: #e0f2fe !important; color: #0369a1 !important; }
.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.bg-primary { background: var(--primary-light) !important; color: var(--primary) !important; }
.bg-light   { background: #f8fafc !important; color: var(--text-muted) !important; }

/* ===== MODALS ===== */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title i { color: var(--primary); }

.modal-body { padding: 24px; }

.modal-footer {
  background: #f8fafc;
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  gap: 8px;
}

/* ===== COTIZACIÓN - SECCIÓN CLIENTE ===== */
.cliente-info {
  background: var(--primary-light);
  border: 1.5px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 14px 16px;
}

.cliente-info h6 {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}

.cliente-info p, .cliente-info div {
  font-size: 13px;
  color: var(--text);
  margin: 0;
}

/* ===== TOTALES CARD ===== */
.totales-mobile {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
}

.totales-mobile .card-body { padding: 20px; }

.totales-mobile .row.mb-2 .col-7 {
  color: #94a3b8;
  font-size: 13px;
}

.totales-mobile .col-5.text-end strong {
  color: white;
  font-size: 14px;
}

.totales-mobile hr {
  border-color: rgba(255,255,255,.15);
  margin: 12px 0;
}

.totales-mobile #saldo {
  color: #4ade80;
  font-size: 18px;
}

.totales-mobile .form-control {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
  color: white;
  font-size: 13px;
}

.totales-mobile .form-control::placeholder { color: rgba(255,255,255,.4); }
.totales-mobile .form-control:focus {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.4);
  box-shadow: none;
  color: white;
}

/* ===== ITEMS TABLE ===== */
.item-row td { font-size: 13px; }

/* ===== SELECT DROPDOWNS ===== */
#selectCliente, #selectProducto {
  max-height: 160px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(37,99,235,.15);
  font-size: 13px;
}

/* ===== PAGINACIÓN ===== */
.btn-group-sm .btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm) !important;
}

/* ===== MOBILE LIST ===== */
.mobile-list-container {
  max-height: 220px;
  overflow-y: auto;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-top: 4px;
  box-shadow: 0 4px 12px rgba(37,99,235,.15);
}

.mobile-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.mobile-list-item:hover, .mobile-list-item:active {
  background: var(--primary-light);
  color: var(--primary);
}

.mobile-list-item:last-child { border-bottom: none; }

/* ===== ALERTS ===== */
.alert {
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  padding: 12px 16px;
  margin-top: 12px;
}

.alert-success { background: #dcfce7; color: #15803d; }
.alert-danger  { background: #fee2e2; color: #dc2626; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
}

.empty-state i {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
  opacity: .4;
}

.empty-state p { font-size: 14px; margin: 0; }
.empty-state small { font-size: 12px; }

/* ===== SCROLL ===== */
.mobile-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-scroll::-webkit-scrollbar { height: 4px; }
.mobile-scroll::-webkit-scrollbar-track { background: #f1f5f9; }
.mobile-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ===== TOUCH ===== */
.touch-friendly { min-height: 44px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
  .card-body { padding: 16px; }
}

@media (max-width: 768px) {
  .app-topbar { padding: 0 16px; }

  .nav-tabs { padding: 0 8px; }
  .nav-tabs .nav-link { padding: 12px 10px; font-size: 12px; }

  .card-header { padding: 14px 16px; font-size: 13px; }
  .card-body { padding: 14px; }

  .modal-dialog { margin: 12px; max-width: calc(100% - 24px); }
  .modal-lg { max-width: calc(100% - 24px); }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  .table thead th { font-size: 10px; padding: 8px 8px; }
  .table tbody td { font-size: 12px; padding: 9px 8px; }

  .btn { font-size: 13px; }
  .btn-sm { font-size: 11px; padding: 4px 8px; }

  .form-label { font-size: 11px; }

  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  select, textarea {
    font-size: 16px !important;
  }

  .btn, .form-control, .form-select { min-height: 42px; }
  .btn-sm { min-height: 32px; }

  .mobile-select {
    font-size: 16px !important;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-sm);
  }
}

@media (max-width: 576px) {
  .nav-tabs .nav-link { padding: 10px 8px; font-size: 11px; }
  .table thead th, .table tbody td { font-size: 10px; padding: 7px 6px; }
}

/* ===== MODAL RESPONSIVE ===== */
@media (max-width: 768px) {
  .modal-xl { max-width: calc(100% - 24px); }
}

/* ===== BOTTOM NAVIGATION (móvil) ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 62px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  box-shadow: 0 -4px 16px rgba(0,0,0,.1);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 2px;
  transition: var(--transition);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.bottom-nav-item i {
  font-size: 19px;
  transition: var(--transition);
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active i {
  transform: translateY(-2px);
}

.bottom-nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

.bottom-nav-item:active {
  background: var(--primary-light);
}

/* ===== TOPBAR MOBILE ===== */
@media (max-width: 767px) {
  .app-topbar {
    height: 52px;
    padding: 0 14px;
    justify-content: flex-start;
    gap: 10px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  /* Ocultar nav-tabs en móvil (se usa bottom-nav) */
  .nav-tabs { display: none !important; }
}

/* ===== MOBILE LAYOUT IMPROVEMENTS ===== */
@media (max-width: 767px) {
  /* Padding inferior para no tapar contenido con bottom-nav */
  .container-fluid { padding-bottom: 72px !important; }

  /* Cards sin margen excesivo */
  .tab-pane .row { margin-top: 8px !important; }
  .card { margin-bottom: 10px; border-radius: var(--radius); }
  .card-header { padding: 12px 14px; font-size: 13px; }
  .card-body { padding: 12px 14px; }

  /* Modales full-screen en móvil */
  .modal-dialog {
    margin: 0;
    max-width: 100%;
    min-height: 100%;
    display: flex;
    align-items: flex-end;
  }

  .modal-content {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
    overflow-y: auto;
  }

  .modal-lg, .modal-xl {
    max-width: 100%;
  }

  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Tablas */
  .table thead th { font-size: 10px; padding: 8px 6px; }
  .table tbody td { font-size: 12px; padding: 9px 6px; }

  /* Botones */
  .btn { font-size: 13px; }
  .btn-sm { font-size: 11px; padding: 5px 8px; min-height: 32px; }
  .btn, .form-control, .form-select { min-height: 44px; }

  /* Labels */
  .form-label { font-size: 11px; }

  /* Evitar zoom en iOS */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  select, textarea {
    font-size: 16px !important;
  }

  /* Paginación en columna */
  #paginacionProductos,
  #paginacionClientes,
  #paginacionBancos,
  #paginacionCompany {
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
  }

  /* Filtros cotizaciones */
  #buscarCotizacion { margin-bottom: 8px; }

  /* Totales más compactos */
  .totales-mobile .card-body { padding: 16px; }

  /* Ocultar columnas menos importantes en tabla items */
  .table th:nth-child(6),
  .table td:nth-child(6) { display: none; }

  /* Botones de acción más grandes */
  .btn-group-sm .btn {
    padding: 6px 10px;
    font-size: 13px;
  }

  /* Select móvil */
  .mobile-select {
    font-size: 16px !important;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-sm);
  }

  /* Empty state más compacto */
  .empty-state { padding: 32px 16px; }
  .empty-state i { font-size: 32px; }
}

@media (max-width: 576px) {
  .table thead th, .table tbody td { font-size: 10px; padding: 7px 5px; }
  .btn-group-sm .btn { padding: 5px 7px; font-size: 12px; }
}

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 16px;
  position: relative;
}

.login-page .login-theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 32px 28px;
}

.login-card .alert {
  margin-top: 0;
  margin-bottom: 16px;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand .brand-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.login-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--primary);
}

.login-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.session-modal .modal-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.session-modal #sesionCountdown {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
}
