/* ============================================================
   LICORES VIRTUAL - ESTILOS GLOBALES
   ============================================================ */

:root {
  --primary: #1a1a2e;
  --secondary: #16213e;
  --accent: #e94560;
  --accent2: #f5a623;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --info: #17a2b8;
  --light: #f8f9fa;
  --dark: #212529;
  --sidebar-width: 250px;
  --header-height: 60px;
  --border-radius: 10px;
  --shadow: 0 2px 15px rgba(0,0,0,0.1);
  --transition: all 0.3s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--primary);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

.sidebar-brand h2 {
  font-size: 1.2rem;
  color: var(--accent2);
  font-weight: 700;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.sidebar-menu {
  flex: 1;
  padding: 15px 0;
  list-style: none;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: var(--transition);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
  color: white;
  background: rgba(255,255,255,0.1);
  border-left-color: var(--accent2);
}

.sidebar-menu li a i { width: 20px; text-align: center; }

.sidebar-menu .badge-count {
  margin-left: auto;
  background: var(--accent);
  color: white;
  border-radius: 50px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 25px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar h1 {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-icon {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  color: #666;
  position: relative;
  transition: var(--transition);
}

.btn-icon:hover { background: #f0f0f0; color: var(--primary); }

.sidebar-toggle { display: none; }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.notification-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.page-content {
  flex: 1;
  padding: 25px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: none;
  margin-bottom: 20px;
}

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

.card-body { padding: 20px; }

/* Stats Cards */
.stat-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 15px;
  border-left: 4px solid var(--accent);
  transition: var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(0,0,0,0.15); }
.stat-card.blue { border-left-color: #007bff; }
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--accent2); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.purple { border-left-color: #6f42c1; }

.stat-icon {
  width: 55px; height: 55px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: #e3f2fd; color: #007bff; }
.stat-icon.green { background: #e8f5e9; color: var(--success); }
.stat-icon.orange { background: #fff3e0; color: var(--accent2); }
.stat-icon.red { background: #ffebee; color: var(--danger); }
.stat-icon.purple { background: #f3e5f5; color: #6f42c1; }

.stat-info h3 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-info p { font-size: 0.8rem; color: #888; margin-top: 4px; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-responsive { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background: #f8f9fa;
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
}

.table td {
  padding: 12px 15px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

/* ============================================================
   TABLA PEDIDOS — clases de celda
   ============================================================ */
.tabla-pedidos { table-layout: fixed; }

.td-nombre {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-sub {
  font-size: 0.76rem;
  color: #888;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-truncate {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-bono {
  font-size: 0.73rem;
  color: #e67e22;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-tiempos {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.72rem;
  color: #999;
  margin-top: 3px;
}

/* Opciones de selección de bono en modal */
.bono-opcion {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid #e0e4ea;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.bono-opcion:hover { border-color: #e67e22; background: #fff8f0; }
.bono-opcion input[type="radio"] { margin-top: 3px; accent-color: #e67e22; }
.bono-opcion input[type="radio"]:checked + div { color: #e67e22; }
.bono-opcion-disabled { opacity: 0.5; cursor: not-allowed; }
.bono-opcion-disabled:hover { border-color: #e0e4ea; background: none; }

/* Chips de bono y tiempos en la tabla */
.btn-info-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.btn-info-chip:hover { opacity: 0.8; }
.btn-chip-bono { background: #fff3e0; color: #e67e22; }
.btn-chip-sin-bono { background: #f0f0f0; color: #999; }
.btn-chip-sin-bono:hover { background: #e8e8e8; color: #666; }
.btn-chip-tiempo { background: #e8f4fd; color: #2980b9; }

/* Contenido modal tiempos */
.tiempo-detalle { display: flex; flex-direction: column; gap: 10px; }
.tiempo-detalle div { display: flex; align-items: center; gap: 6px; }
.chip-diff {
  background: #e8f4fd;
  color: #2980b9;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Botones de acción en fila */
.acciones-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.acciones-btns .btn-sm {
  padding: 5px 8px;
  font-size: 0.78rem;
  line-height: 1;
}

/* Compactar en pantallas medianas */
@media (max-width: 1280px) {
  .tabla-pedidos th,
  .tabla-pedidos td { padding: 9px 10px; }
}

@media (max-width: 1100px) {
  .tabla-pedidos th,
  .tabla-pedidos td { padding: 8px 8px; font-size: 0.79rem; }
  .td-sub { font-size: 0.72rem; }
  .acciones-btns .btn-sm { padding: 4px 7px; }
}

.table tbody tr:hover { background: #f8f9fa; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES / ESTADOS
   ============================================================ */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-pendiente { background: #fff3cd; color: #856404; }
.badge-recibido { background: #cff4fc; color: #0c5460; }
.badge-pendiente_validacion { background: #ffe8e8; color: #a00; }
.badge-resolver_problema { background: #ff6b00; color: #fff; font-weight: 700; }
.badge-validado { background: #d4edda; color: #155724; }
.badge-en_camino { background: #e2d9f3; color: #4b2e83; }
.badge-entregado { background: #d4edda; color: #155724; }
.badge-cancelado { background: #f8d7da; color: #721c24; }
.badge-disponible { background: #d4edda; color: #155724; }
.badge-ocupada { background: #fff3cd; color: #856404; }
.badge-pendiente_recoleccion { background: #cff4fc; color: #0c5460; }
.badge-activo { background: #d4edda; color: #155724; }
.badge-inactivo { background: #f8d7da; color: #721c24; }
.badge-en_ruta { background: #e2d9f3; color: #4b2e83; }
.badge-pedido { background: #fff3cd; color: #856404; }
.badge-acumulado { background: #d4edda; color: #155724; }
.badge-ninguno { background: #e9ecef; color: #666; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #212529; }
.btn-info { background: var(--info); color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-outline { background: white; border: 1px solid #dee2e6; color: #333; }
.btn-accent { background: var(--accent); color: white; }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group { margin-bottom: 15px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: #444; margin-bottom: 6px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #dee2e6;
  border-radius: 8px;
  font-size: 0.875rem;
  transition: var(--transition);
  background: white;
  color: #333;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,26,46,0.1);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================
   MODALES
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transform: translateY(-20px);
  transition: var(--transition);
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1.1rem; color: var(--primary); }

.modal-body { padding: 20px; }

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

/* ============================================================
   ALERTAS Y NOTIFICACIONES
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-danger { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }
.alert-info { background: #cff4fc; color: #0c5460; border-left: 4px solid var(--info); }

/* Toast */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: white;
  border-radius: 10px;
  box-shadow: 0 5px 25px rgba(0,0,0,0.15);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--success);
}

.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   STOCK CRÍTICO
   ============================================================ */
.stock-critico { color: var(--danger) !important; font-weight: 700; }
.stock-bajo { color: var(--warning) !important; font-weight: 600; }
.row-critico { background: #fff5f5 !important; }

/* ============================================================
   BONO INFO
   ============================================================ */
.bono-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.78rem;
}

.bono-pedido { color: #856404; }
.bono-acumulado { color: #155724; font-weight: 700; }
.bono-ninguno { color: #999; }

/* ============================================================
   TIEMPO
   ============================================================ */
.tiempo-info {
  font-size: 0.78rem;
  color: #666;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ============================================================
   LOADING
   ============================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #888;
  gap: 10px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid #dee2e6;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   GRID
   ============================================================ */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ============================================================
   FILTROS
   ============================================================ */
.filtros-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 15px;
}

.filtros-bar .form-control { width: auto; min-width: 0; flex-shrink: 1; }

@media (max-width: 1100px) {
  .filtros-bar .form-control { font-size: 0.82rem; padding: 6px 8px; }
}

@media (max-width: 768px) {
  .filtros-bar { flex-direction: column; align-items: stretch; }
  .filtros-bar .form-control { width: 100%; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  :root { --sidebar-width: 200px; }
  .sidebar-brand h2 { font-size: 1rem; }
  .sidebar-menu li a { padding: 10px 14px; font-size: 0.82rem; gap: 9px; }
  .page-content { padding: 18px; }
}

@media (max-width: 1050px) {
  :root { --sidebar-width: 180px; }
  .sidebar-menu li a { padding: 9px 12px; font-size: 0.8rem; }
  .sidebar-brand { padding: 14px 10px; }
  .topbar h1 { font-size: 1.1rem; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 250px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .sidebar-toggle { display: inline-flex; }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .page-content { padding: 15px; }
}

/* ============================================================
   TABLA → CARDS EN MÓVIL
   ============================================================ */
@media (max-width: 768px) {
  .table-responsive { overflow-x: visible; }

  .table thead { display: none; }

  .table tbody tr {
    display: block;
    background: #fff;
    margin-bottom: 14px;
    border-radius: 10px;
    border: 1px solid #e0e4ea;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    overflow: hidden;
  }

  .table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 9px 14px;
    border-bottom: 1px solid #f2f4f7;
    font-size: 0.83rem;
    min-height: 36px;
  }

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

  .table td[data-label]::before {
    content: attr(data-label);
    font-weight: 700;
    color: #444;
    min-width: 90px;
    flex-shrink: 0;
    margin-right: 10px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 1px;
  }

  .table tbody tr:hover { background: #fff; }

  /* Acciones apiladas en columna */
  .table td[data-label="Acciones"] { flex-direction: column; gap: 6px; }
  .table td[data-label="Acciones"]::before { min-width: unset; }
  .table td[data-label="Acciones"] > div { width: 100%; }
  .table td[data-label="Acciones"] .btn { width: 100%; justify-content: center; }
}

/* Badge alerta inventario en sidebar */
.badge-alerta-inv {
  background: #e74c3c;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 8px;
  margin-left: 5px;
  vertical-align: middle;
}

/* ============================================================
   ALERTA SONIDO PEDIDO
   ============================================================ */
.pedido-alert-overlay {
  position: fixed;
  top: 80px; right: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  padding: 20px;
  z-index: 5000;
  min-width: 300px;
  border-left: 5px solid var(--accent);
  animation: bounceIn 0.5s ease;
  display: none;
}

.pedido-alert-overlay.show { display: block; }

@keyframes bounceIn {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   DOMICILIARIO STYLES
   ============================================================ */
.dom-header {
  background: var(--primary);
  color: white;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.dom-tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid #dee2e6;
}

.dom-tab {
  flex: 1;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  font-weight: 500;
  color: #666;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
}

.dom-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.pedido-card {
  background: white;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--accent2);
}

.pedido-card.entregado { border-left-color: var(--success); opacity: 0.8; }

/* ============================================================
   CONTABILIDAD
   ============================================================ */
.ingreso-row { background: #f0fff4 !important; }
.egreso-row { background: #fff5f5 !important; }

.total-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.total-card .amount {
  font-size: 1.8rem;
  font-weight: 700;
}

.total-card.ingresos .amount { color: var(--success); }
.total-card.egresos .amount { color: var(--danger); }
.total-card.neto .amount { color: var(--primary); }
