/* ==========================================================================
   SISTEMA DE DISEÑO POS PREMIUM (VANILLA CSS)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* Paleta de Colores - Slate & Electric Cyan */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-light: rgba(14, 165, 233, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --success: #10b981;
  --success-hover: #059669;
  --success-light: rgba(16, 185, 129, 0.1);
  
  --warning: #f59e0b;
  --warning-hover: #d97706;
  --warning-light: rgba(245, 158, 11, 0.1);
  
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: rgba(239, 68, 68, 0.1);

  --border-color: #334155;
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.3);
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  
  --sidebar-width: 260px;
}

/* Reset general */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ocultar elementos */
.hidden {
  display: none !important;
}

/* ==========================================================================
   VISTA DE LOGIN
   ========================================================================== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at top right, rgba(14, 165, 233, 0.15), transparent 40%),
              radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent 40%),
              var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background-color: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.login-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.input-wrapper input, .form-control {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.input-wrapper input {
  padding-left: 42px;
}

.input-wrapper input:focus, .form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}

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

.btn-success {
  background-color: var(--success);
  color: white;
}

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

.btn-danger {
  background-color: var(--danger);
  color: white;
}

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

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: #475569;
}

.login-footer {
  margin-top: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   DISEÑO PRINCIPAL (APP LAYOUT)
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar lateral */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: var(--transition-normal);
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  background-color: var(--accent);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: bold;
}

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--text-primary);
}

.sidebar-user {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.shift-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  width: fit-content;
}

.shift-badge.open {
  background-color: var(--success-light);
  color: var(--success);
}

.shift-badge.closed {
  background-color: var(--danger-light);
  color: var(--danger);
}

.sidebar-menu {
  list-style: none;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex-grow: 1;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.sidebar-menu li a:hover, .sidebar-menu li.active a {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-menu li.active a {
  border-left: 4px solid var(--accent);
  background-color: rgba(14, 165, 233, 0.08);
  color: var(--accent);
}

.sidebar-menu li a i {
  font-size: 1.1rem;
}

/* Área de contenido principal */
.main-content {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
  transition: var(--transition-normal);
}

/* Header superior móvil */
.mobile-header {
  display: none;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 99;
}

/* ==========================================================================
   VISTAS Y PANELES DENTRO DE MAIN CONTENT
   ========================================================================== */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.view-title h1 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.75rem;
}

.view-title p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

.view-actions {
  display: flex;
  gap: 12px;
}

/* ==========================================================================
   CARDS Y CONTENEDORES
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--card-shadow);
}

.stat-info h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-info p {
  font-size: 1.8rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-icon.primary { background-color: rgba(14, 165, 233, 0.1); color: var(--accent); }
.stat-icon.success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.warning { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.danger { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ==========================================================================
   DISEÑO DEL PUNTO DE VENTA (POS)
   ========================================================================== */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  align-items: start;
}

.pos-catalog {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100vh - 180px);
}

.catalog-header {
  display: flex;
  gap: 12px;
}

.catalog-search {
  flex-grow: 1;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.category-tab {
  padding: 8px 16px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.category-tab:hover, .category-tab.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: white;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 320px);
  padding-right: 4px;
}

.product-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.product-card-img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
  background-color: var(--bg-secondary);
}

.product-card-no-img {
  width: 100%;
  height: 100px;
  border-radius: 8px;
  margin-bottom: 8px;
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.8rem;
}

.product-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2rem;
  flex-grow: 1;
}

.product-card-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.product-card-stock {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.product-card-stock.low {
  color: var(--danger);
  font-weight: 600;
}

/* POS Cart (Carrito de compras) */
.pos-cart {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 120px);
  position: sticky;
  top: 32px;
}

.cart-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-items {
  overflow-y: auto;
  flex-grow: 1;
  max-height: calc(100vh - 460px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.cart-item {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-item-info {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.cart-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 70%;
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 2px;
}

.cart-item-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.qty-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-secondary);
}

.qty-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-weight: bold;
}

.qty-val {
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.price-level-select {
  padding: 4px 6px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.8rem;
}

.cart-totals {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.total-row.grand-total {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  margin-top: 4px;
}

/* ==========================================================================
   TABLAS Y LISTADOS
   ========================================================================== */
.table-container {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
}

.table-search-bar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: center;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: rgba(15, 23, 42, 0.3);
  padding: 14px 20px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success { background-color: var(--success-light); color: var(--success); }
.badge-warning { background-color: var(--warning-light); color: var(--warning); }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }
.badge-primary { background-color: var(--accent-light); color: var(--accent); }

/* ==========================================================================
   VENTANAS MODALES
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-grow: 1;
  min-height: 0;
}

.modal-content.modal-lg {
  max-width: 800px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   HOJA DE ESTILO DE CONFIGURACIÓN DEL TICKET
   ========================================================================== */
.ticket-config-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

.ticket-preview {
  background-color: white;
  color: black;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 16px;
  font-family: monospace;
  font-size: 0.85rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.ticket-preview-header {
  text-align: center;
  margin-bottom: 16px;
  font-weight: bold;
  white-space: pre-line;
}

.ticket-preview-divider {
  border-top: 1px dashed black;
  margin: 8px 0;
}

.ticket-preview-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.ticket-preview-footer {
  text-align: center;
  margin-top: 16px;
  white-space: pre-line;
}

/* ==========================================================================
   GRAFICOS (Dashboard)
   ========================================================================== */
.charts-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.chart-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--card-shadow);
}

.chart-card h2 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.chart-wrapper {
  position: relative;
  height: 300px;
  width: 100%;
}

/* ==========================================================================
   RESPONSIVIDAD Y DISEÑO DE DISPOSITIVOS MÓVILES
   ========================================================================== */
@media (max-width: 992px) {
  .pos-layout {
    grid-template-columns: 1fr;
  }
  
  .pos-cart {
    position: static;
    max-height: none;
  }
}

@media (max-width: 768px) {
  /* Sidebar responsive */
  .sidebar {
    left: -100%;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .mobile-header {
    display: flex;
  }
  
  .view-header {
    flex-direction: column;
    align-items: start;
    gap: 12px;
  }
  
  .ticket-config-layout {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   VISTA DE IMPRESIÓN DEL TICKET (ESPECIAL MINIPRINTER)
   ========================================================================== */
@media print {
  /* Ocultar toda la interfaz de usuario */
  body * {
    visibility: hidden;
  }
  
  #print-ticket-area, #print-ticket-area * {
    visibility: visible;
  }
  
  #print-ticket-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm; /* Ancho ajustable de miniprinter de 80mm */
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    line-height: 1.3;
    color: #000;
    background-color: #fff;
    padding: 2mm;
    margin: 0;
  }
  
  /* Soporte alternativo de 58mm si se prefiere */
  .printer-58mm #print-ticket-area {
    width: 58mm;
  }
  
  .print-header {
    text-align: center;
    font-weight: bold;
    margin-bottom: 4mm;
    white-space: pre-line;
  }
  
  .print-divider {
    border-top: 1px dashed #000;
    margin: 3mm 0;
    height: 0;
  }
  
  .print-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5mm;
  }
  
  .print-col-desc {
    flex: 1;
    text-align: left;
    padding-right: 2mm;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .print-col-val {
    width: 22mm;
    text-align: right;
  }
  
  .print-total-row {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 2mm;
  }
  
  .print-footer {
    text-align: center;
    margin-top: 5mm;
    white-space: pre-line;
    font-size: 11px;
  }
  
  /* Desactivar cabeceras/pies de página del navegador */
  @page {
    margin: 0;
  }
}
