/* =====================================================
   DISTRIBUIDORA DE LIBROS - Estilos Principales
   ===================================================== */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed: 60px;
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --sidebar-bg: #ffffff;
  --sidebar-text: #374151;
  --sidebar-active: #eff6ff;
  --sidebar-active-text: #2563eb;
  --section-title: #9ca3af;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07);
}

/* ===== LAYOUT ===== */
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 14px; }

.sidebar {
  width: var(--sidebar-width);
  min-height: calc(100vh - 56px);
  transition: width 0.2s ease;
  overflow-x: hidden;
  overflow-y: auto;
  position: sticky;
  top: 56px;
  max-height: calc(100vh - 56px);
  flex-shrink: 0;
  z-index: 100;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-chevron,
.sidebar.collapsed .nav-section-title { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 0.6rem; }
.sidebar.collapsed .nav-icon { margin: 0; }

.main-content { min-height: calc(100vh - 56px); }

/* ===== SIDEBAR NAV ===== */
.sidebar .nav-link {
  color: var(--sidebar-text);
  border-radius: 8px;
  margin: 1px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  transition: all 0.15s;
  text-decoration: none;
}
.sidebar .nav-link:hover { background: #f3f4f6; color: var(--primary); }
.sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
  font-weight: 600;
}
.nav-icon { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }
.nav-chevron { width: 14px; height: 14px; margin-left: auto; opacity: 0.5; }
.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--section-title);
  padding: 14px 16px 4px;
  white-space: nowrap;
}
.sidebar .collapse .nav-link { font-size: 13px; margin-left: 8px; }

/* ===== CARDS ===== */
.card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  border-radius: 12px 12px 0 0 !important;
  padding: 1rem 1.25rem;
}
.stat-card {
  border-radius: 12px;
  border: none;
  color: white;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.25;
  width: 52px;
  height: 52px;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.stat-card .stat-change { font-size: 12px; margin-top: 8px; opacity: 0.9; }

/* ===== TABLAS ===== */
.table { font-size: 13.5px; }
.table thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f9fafb; cursor: pointer; }

/* ===== FORMULARIOS ===== */
.form-label { font-weight: 600; font-size: 13px; color: #374151; margin-bottom: 4px; }
.form-control, .form-select {
  font-size: 13.5px;
  border-color: #d1d5db;
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input-group-text { background: #f9fafb; font-size: 13px; border-color: #d1d5db; }
.required::after { content: ' *'; color: #ef4444; }

/* ===== BOTONES ===== */
.btn { border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.btn-sm { font-size: 12.5px; padding: 4px 10px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* ===== BADGES ===== */
.badge { font-size: 11px; padding: 4px 8px; border-radius: 6px; font-weight: 600; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}
.page-subtitle { font-size: 13px; color: #6b7280; margin-top: 2px; }
.breadcrumb { font-size: 12px; margin-bottom: 0; }
.breadcrumb-item + .breadcrumb-item::before { color: #9ca3af; }

/* ===== ALERTS ===== */
.alert { border-radius: 10px; font-size: 13.5px; border: none; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info    { background: #eff6ff; color: #1e40af; }

/* ===== MODALES ===== */
.modal-content { border-radius: 14px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 1rem 1.5rem; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 0.75rem 1.5rem; }

/* ===== SELECT2 ===== */
.select2-container--bootstrap-5 .select2-selection {
  border-radius: 8px !important;
  font-size: 13.5px !important;
  border-color: #d1d5db !important;
}

/* ===== INVENTARIO CHIPS ===== */
.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.stock-ok     { background: #dcfce7; color: #166534; }
.stock-low    { background: #fef9c3; color: #854d0e; }
.stock-none   { background: #fee2e2; color: #991b1b; }

/* ===== PRECIO CARD ===== */
.precio-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.5rem;
}
.precio-card .precio-valor { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.precio-card .precio-desc  { font-size: 12px; color: #6b7280; }
.precio-tachado { text-decoration: line-through; color: #9ca3af; font-size: 13px; }

/* ===== ITEMS DE VENTA ===== */
.items-table th { font-size: 11px; text-transform: uppercase; color: #6b7280; }
.item-row { transition: background 0.1s; }
.item-row:hover { background: #f9fafb; }
.delete-item { color: #ef4444; cursor: pointer; border: none; background: none; }
.delete-item:hover { color: #b91c1c; }

/* ===== TOTALES ===== */
.totales-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 1.25rem;
}
.total-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13.5px; }
.total-final { font-size: 1.2rem; font-weight: 700; color: var(--primary); border-top: 2px solid #bae6fd; padding-top: 8px; margin-top: 4px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -var(--sidebar-width); top: 56px; z-index: 999; }
  .sidebar.mobile-open { left: 0; }
  .main-content { margin-left: 0 !important; }
  .stat-card { margin-bottom: 0.75rem; }
}

/* ===== SCANNER ===== */
.scanner-input {
  font-family: monospace;
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-align: center;
  border: 2px dashed #2563eb;
  background: #eff6ff;
  padding: 12px;
  border-radius: 10px;
}
.scanner-input:focus { border-style: solid; }

/* ===== LOADING ===== */
.spinner-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ===== HIERARCHY ===== */
.cliente-hijo { padding-left: 24px; border-left: 2px solid #bfdbfe; margin-left: 8px; }
.cliente-padre-label { font-size: 11px; color: #2563eb; font-weight: 600; }

/* ===== PRINT ===== */
@media print {
  .sidebar, .navbar, .btn, .no-print { display: none !important; }
  .main-content { margin: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
