/* ============================================
   PORTAL BODEGA - ESTILOS GLOBALES
   Colores: Blanco y Rojo
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --primary-light: #ef4444;
  --primary-50: #fef2f2;
  --primary-100: #fee2e2;
  --primary-200: #fecaca;
  --secondary: #1e293b;
  --secondary-light: #334155;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #2563eb;
  --info-light: #dbeafe;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --sidebar-width: 260px;
  --header-height: 65px;
  --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, var(--secondary) 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
  animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.login-container {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo { text-align: center; margin-bottom: 32px; }

.login-logo .logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.3);
}

.login-logo .logo-icon i { font-size: 32px; color: var(--white); }
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.login-logo p { color: var(--gray-500); font-size: 14px; margin-top: 4px; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--gray-700); margin-bottom: 6px;
}

.form-group .input-wrapper { position: relative; }
.form-group .input-wrapper i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 16px; transition: var(--transition);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px; font-family: inherit;
  color: var(--gray-800); background: var(--white);
  transition: var(--transition); outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.form-group select,
.form-group textarea { padding-left: 14px; }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group .input-no-icon { padding-left: 14px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.login-error {
  background: var(--danger-light); color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 16px;
  display: none; align-items: center; gap: 8px;
}
.login-error.show { display: flex; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--transition); outline: none; white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: var(--primary-dark); }

.btn-outline { background: transparent; border: 2px solid var(--gray-200); color: var(--gray-600); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }

.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* ============================================
   LAYOUT - SIDEBAR + MAIN
   ============================================ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 12px;
}

.sidebar-header .logo-sm {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-header .logo-sm i { font-size: 18px; color: var(--white); }
.sidebar-header .logo-text h2 { font-size: 16px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.sidebar-header .logo-text span { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav .nav-section { margin-bottom: 24px; }
.sidebar-nav .nav-section-title {
  font-size: 11px; font-weight: 600; color: var(--gray-400);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 0 12px; margin-bottom: 8px;
}

.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--gray-600); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: var(--transition); margin-bottom: 2px;
}
.sidebar-nav .nav-item:hover { background: var(--gray-50); color: var(--gray-900); }
.sidebar-nav .nav-item.active { background: var(--primary-50); color: var(--primary); }
.sidebar-nav .nav-item.active i { color: var(--primary); }
.sidebar-nav .nav-item i { width: 20px; text-align: center; font-size: 16px; color: var(--gray-400); transition: var(--transition); }
.sidebar-nav .nav-item .badge {
  margin-left: auto; background: var(--danger); color: var(--white);
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; min-width: 20px; text-align: center;
}

.sidebar-footer { padding: 16px; border-top: 1px solid var(--gray-100); }

.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius); background: var(--gray-50);
}
.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-info .user-name {
  font-size: 13px; font-weight: 600; color: var(--gray-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-info .user-role { font-size: 11px; color: var(--gray-500); text-transform: capitalize; }
.sidebar-user .logout-btn {
  background: none; border: none; color: var(--gray-400);
  cursor: pointer; padding: 4px; border-radius: 6px; transition: var(--transition);
}
.sidebar-user .logout-btn:hover { color: var(--danger); background: var(--danger-light); }

/* Main Content */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }

.main-header {
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  padding: 0 32px; height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.main-header .header-left { display: flex; align-items: center; gap: 16px; }
.main-header .menu-toggle {
  display: none; background: none; border: none;
  font-size: 20px; color: var(--gray-600); cursor: pointer;
  padding: 8px; border-radius: var(--radius);
}
.main-header .menu-toggle:hover { background: var(--gray-100); }
.main-header .page-title { font-size: 20px; font-weight: 700; color: var(--gray-900); }
.main-header .page-subtitle { font-size: 13px; color: var(--gray-500); }
.main-header .header-right { display: flex; align-items: center; gap: 12px; }

.main-body { padding: 32px; }

/* ============================================
   DASHBOARD CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px; margin-bottom: 32px;
}

.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 24px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100); transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card .stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-card .stat-icon.red { background: var(--primary-100); color: var(--primary); }
.stat-card .stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-card .stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-card .stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-card .stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ============================================
   CARDS & PANELS
   ============================================ */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--gray-100); overflow: hidden;
}
.card-header {
  padding: 20px 24px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.card-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.card-body { padding: 24px; }
.card-body.no-padding { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ============================================
   TABLES
   ============================================ */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
table thead th {
  background: var(--gray-50); padding: 12px 16px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
table tbody td {
  padding: 14px 16px; font-size: 14px; color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100); vertical-align: middle;
}
table tbody tr { transition: var(--transition); }
table tbody tr:hover { background: var(--gray-50); }
table tbody tr:last-child td { border-bottom: none; }

.table-actions { display: flex; gap: 6px; }
.table-actions .btn-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; cursor: pointer;
  transition: var(--transition); font-size: 14px;
  background: var(--gray-100); color: var(--gray-600);
}
.table-actions .btn-icon:hover { background: var(--primary-100); color: var(--primary); }
.table-actions .btn-icon.delete:hover { background: var(--danger-light); color: var(--danger); }
.table-actions .btn-icon.edit:hover { background: var(--info-light); color: var(--info); }

/* Badges */
.stock-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.stock-badge.ok { background: var(--success-light); color: var(--success); }
.stock-badge.low { background: var(--warning-light); color: var(--warning); }
.stock-badge.critical { background: var(--danger-light); color: var(--danger); }

.category-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: var(--gray-100); color: var(--gray-700);
}
.category-badge .dot { width: 8px; height: 8px; border-radius: 50%; }

.status-badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.status-badge.active { background: var(--success-light); color: var(--success); }
.status-badge.inactive { background: var(--gray-100); color: var(--gray-500); }

.movement-badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.movement-badge.entrada { background: var(--success-light); color: var(--success); }
.movement-badge.salida { background: var(--danger-light); color: var(--danger); }
.movement-badge.ajuste { background: var(--warning-light); color: var(--warning); }
.movement-badge.venta { background: var(--info-light); color: var(--info); }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; visibility: hidden;
  transition: all 0.3s ease; padding: 20px;
}
.modal-overlay.show { opacity: 1; visibility: visible; }

.modal {
  background: var(--white); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column;
  transform: scale(0.9) translateY(20px); transition: all 0.3s ease;
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 24px 24px 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--gray-900); }

.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--gray-100); border-radius: 8px;
  cursor: pointer; color: var(--gray-500); transition: var(--transition);
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-footer {
  padding: 16px 24px; display: flex; gap: 12px; justify-content: flex-end;
  flex-shrink: 0; border-top: 1px solid var(--gray-100);
}

/* ============================================
   POS (Point of Sale)
   ============================================ */
.pos-layout {
  display: grid; grid-template-columns: 1fr 380px;
  gap: 24px; height: calc(100vh - var(--header-height) - 64px);
}

.pos-products { display: flex; flex-direction: column; overflow: hidden; }

.pos-search { margin-bottom: 16px; }
.pos-search .search-input {
  width: 100%; padding: 12px 16px 12px 44px;
  border: 2px solid var(--gray-200); border-radius: var(--radius-lg);
  font-size: 15px; font-family: inherit; outline: none;
  transition: var(--transition); background: var(--white);
}
.pos-search .search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.pos-search .search-wrapper { position: relative; }
.pos-search .search-wrapper i {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--gray-400);
}

.pos-categories {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
}
.pos-categories .cat-btn {
  padding: 8px 16px; border: 2px solid var(--gray-200); border-radius: 20px;
  background: var(--white); font-size: 13px; font-weight: 500;
  color: var(--gray-600); cursor: pointer; transition: var(--transition);
  white-space: nowrap; font-family: inherit;
}
.pos-categories .cat-btn:hover { border-color: var(--primary); color: var(--primary); }
.pos-categories .cat-btn.active { background: var(--primary); border-color: var(--primary); color: var(--white); }

.pos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; overflow-y: auto; flex: 1; padding: 4px;
}

.pos-product-card {
  background: var(--white); border: 2px solid var(--gray-100);
  border-radius: var(--radius-lg); padding: 16px;
  cursor: pointer; transition: var(--transition); text-align: center;
}
.pos-product-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.pos-product-card .product-img {
  width: 64px; height: 64px; margin: 0 auto 8px;
  border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-50);
}
.pos-product-card .product-img img {
  width: 100%; height: 100%; object-fit: cover;
}
.pos-product-card .product-emoji { font-size: 32px; margin-bottom: 8px; }
.pos-product-card .product-name {
  font-size: 13px; font-weight: 600; color: var(--gray-800);
  margin-bottom: 4px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pos-product-card .product-price { font-size: 16px; font-weight: 800; color: var(--primary); }
.pos-product-card .product-stock { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.pos-product-card.out-of-stock { opacity: 0.5; cursor: not-allowed; }

/* Cart */
.pos-cart {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  display: flex; flex-direction: column; overflow: hidden;
}
.cart-header {
  padding: 20px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.cart-header h3 {
  font-size: 16px; font-weight: 700; color: var(--gray-900);
  display: flex; align-items: center; gap: 8px;
}
.cart-header .cart-count {
  background: var(--primary); color: var(--white);
  font-size: 12px; padding: 2px 8px; border-radius: 10px;
}
.cart-header .clear-cart {
  background: none; border: none; color: var(--gray-400);
  cursor: pointer; font-size: 13px; transition: var(--transition);
  font-family: inherit;
}
.cart-header .clear-cart:hover { color: var(--danger); }

.cart-items { flex: 1; overflow-y: auto; padding: 12px; }

.cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--gray-100); margin-bottom: 8px;
  transition: var(--transition);
}
.cart-item:hover { border-color: var(--gray-200); }
.cart-item .item-info { flex: 1; min-width: 0; }
.cart-item .item-name {
  font-size: 13px; font-weight: 600; color: var(--gray-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cart-item .item-price { font-size: 12px; color: var(--gray-500); }

.cart-item .item-qty {
  display: flex; align-items: center; gap: 8px;
}
.cart-item .item-qty button {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--gray-200); border-radius: 6px;
  background: var(--white); cursor: pointer; font-size: 14px;
  color: var(--gray-600); transition: var(--transition);
}
.cart-item .item-qty button:hover { border-color: var(--primary); color: var(--primary); }
.cart-item .item-qty span { font-size: 14px; font-weight: 600; min-width: 20px; text-align: center; }

.cart-item .item-subtotal { font-size: 14px; font-weight: 700; color: var(--gray-900); min-width: 60px; text-align: right; }

.cart-item .item-remove {
  background: none; border: none; color: var(--gray-300);
  cursor: pointer; font-size: 14px; padding: 4px;
  transition: var(--transition);
}
.cart-item .item-remove:hover { color: var(--danger); }

.cart-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--gray-400); padding: 40px;
}
.cart-empty i { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.cart-empty p { font-size: 14px; }

.cart-footer {
  padding: 16px; border-top: 1px solid var(--gray-100);
}
.cart-total {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding: 12px; background: var(--gray-50);
  border-radius: var(--radius);
}
.cart-total .total-label { font-size: 14px; color: var(--gray-600); }
.cart-total .total-value { font-size: 24px; font-weight: 800; color: var(--primary); }

.payment-methods {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.payment-methods .pay-btn {
  flex: 1; padding: 10px; border: 2px solid var(--gray-200);
  border-radius: var(--radius); background: var(--white);
  cursor: pointer; text-align: center; transition: var(--transition);
  font-family: inherit; font-size: 12px; font-weight: 500; color: var(--gray-600);
}
.payment-methods .pay-btn:hover { border-color: var(--primary); color: var(--primary); }
.payment-methods .pay-btn.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.payment-methods .pay-btn i { display: block; font-size: 18px; margin-bottom: 4px; }

/* ============================================
   PRODUCT IMAGES IN TABLES
   ============================================ */
.table-product-img {
  width: 44px; height: 44px; border-radius: 8px;
  object-fit: cover; display: block;
  border: 1px solid var(--gray-200);
}
.table-product-img-placeholder {
  width: 44px; height: 44px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  font-size: 20px;
}

/* ============================================
   IMAGE UPLOAD / PREVIEW IN MODAL
   ============================================ */
.image-upload-area {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  background: var(--gray-50);
}

.image-preview-container,
.image-preview {
  position: relative;
  width: 140px; height: 140px;
  margin: 0 auto 12px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--gray-200);
}
.image-preview-container img,
.image-preview img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.image-preview-container .image-placeholder,
.image-preview .image-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--gray-400); font-size: 13px;
}
.image-preview-container .image-placeholder i,
.image-preview .image-placeholder i {
  font-size: 32px; margin-bottom: 6px; opacity: 0.5;
}
.image-preview-container .image-remove-btn,
.image-preview .image-remove-btn {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px;
  background: var(--danger); color: var(--white);
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 11px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  z-index: 2;
}
.image-preview-container .image-remove-btn:hover,
.image-preview .image-remove-btn:hover {
  background: var(--primary-dark); transform: scale(1.1);
}

.image-input-row {
  display: flex; gap: 8px; margin-bottom: 8px;
}
.image-input-row input {
  flex: 1; padding: 8px 12px;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; outline: none;
  transition: var(--transition);
}
.image-input-row input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-100);
}
.image-input-row .btn {
  padding: 8px 12px; font-size: 12px; white-space: nowrap;
}

.image-actions-row {
  display: flex; gap: 8px; justify-content: center;
}
.image-actions-row .btn {
  padding: 6px 12px; font-size: 12px;
}

/* Image Search Results */
.image-search-results {
  margin-top: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}
.image-search-results .image-search-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  max-height: 240px;
  overflow-y: auto;
}
.image-search-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--gray-200);
  transition: var(--transition);
}
.image-search-item:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}
.image-search-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.image-search-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(220, 38, 38, 0.6);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: var(--transition);
}
.image-search-overlay i {
  color: var(--white); font-size: 24px;
}
.image-search-item:hover .image-search-overlay {
  opacity: 1;
}
.image-search-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; gap: 10px; color: var(--gray-500); font-size: 13px;
}

/* ============================================
   SEARCH BAR (general)
   ============================================ */
.search-bar {
  position: relative; max-width: 320px;
}
.search-bar input {
  width: 100%; padding: 10px 14px 10px 38px;
  border: 2px solid var(--gray-200); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; outline: none;
  transition: var(--transition); background: var(--gray-50);
}
.search-bar input:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px var(--primary-100); }
.search-bar i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 14px;
}

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}
.toolbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }

.filter-select {
  padding: 10px 14px; border: 2px solid var(--gray-200);
  border-radius: var(--radius); font-size: 14px; font-family: inherit;
  outline: none; background: var(--gray-50); color: var(--gray-700);
  transition: var(--transition); cursor: pointer;
}
.filter-select:focus { border-color: var(--primary); background: var(--white); }

/* ============================================
   TICKET / RECEIPT
   ============================================ */
.ticket-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100; opacity: 0; visibility: hidden;
  transition: all 0.3s ease; padding: 20px;
}
.ticket-overlay.show { opacity: 1; visibility: visible; }

.ticket {
  background: var(--white); width: 320px; padding: 32px 24px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
  font-size: 13px;
}
.ticket-header { text-align: center; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 2px dashed var(--gray-200); }
.ticket-header h3 { font-size: 18px; font-weight: 800; color: var(--primary); }
.ticket-header p { font-size: 12px; color: var(--gray-500); }

.ticket-items { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 2px dashed var(--gray-200); }
.ticket-item {
  display: flex; justify-content: space-between; padding: 4px 0;
  font-size: 13px; color: var(--gray-700);
}
.ticket-item .qty { color: var(--gray-400); margin-right: 4px; }

.ticket-total {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 18px; font-weight: 800; color: var(--gray-900);
  margin-bottom: 16px; padding-bottom: 16px; border-bottom: 2px dashed var(--gray-200);
}

.ticket-footer { text-align: center; color: var(--gray-400); font-size: 12px; }
.ticket-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: center; }

/* ============================================
   CHART PLACEHOLDER
   ============================================ */
.chart-container {
  width: 100%; height: 300px; position: relative;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 20px 0;
}
.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.chart-bar {
  width: 100%; max-width: 60px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  transition: all 0.5s ease; min-height: 4px;
}
.chart-bar:hover { opacity: 0.8; }
.chart-label { font-size: 11px; color: var(--gray-500); white-space: nowrap; }
.chart-value { font-size: 11px; font-weight: 600; color: var(--gray-700); }

/* ============================================
   ALERTS LIST
   ============================================ */
.alert-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}
.alert-item:hover { background: var(--gray-50); }
.alert-item:last-child { border-bottom: none; }
.alert-item .alert-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--warning-light); color: var(--warning); font-size: 16px;
  flex-shrink: 0;
}
.alert-item .alert-icon.critical { background: var(--danger-light); color: var(--danger); }
.alert-item .alert-info { flex: 1; }
.alert-item .alert-info .alert-name { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.alert-item .alert-info .alert-detail { font-size: 12px; color: var(--gray-500); }

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--gray-400);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h4 { font-size: 16px; color: var(--gray-600); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
  min-width: 300px; max-width: 420px;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--gray-400);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--info); }
.toast .toast-message { flex: 1; font-size: 14px; color: var(--gray-700); }
.toast .toast-close {
  background: none; border: none; color: var(--gray-400);
  cursor: pointer; font-size: 14px; padding: 2px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; border-radius: inherit;
}

/* ============================================
   SECTION PAGES
   ============================================ */
.section-page { display: none; }
.section-page.active { display: block; }

/* ============================================
   BARCODE SCANNER BUTTON
   ============================================ */
.barcode-scan-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white); border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
  transition: var(--transition);
  z-index: 2;
}
.barcode-scan-btn:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.pos-search .search-wrapper {
  display: flex; align-items: center;
}
.pos-search .search-input {
  padding-right: 52px;
}

/* Barcode field scan button (in product modal) */
.barcode-field-row {
  display: flex; gap: 8px; align-items: center;
}
.barcode-field-row input { flex: 1; }
.barcode-field-row .btn {
  padding: 10px 14px; flex-shrink: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
.sidebar-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 99;
}

/* Large tablets / small desktops */
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart { max-height: 500px; }
  .grid-2 { grid-template-columns: 1fr; }
  .main-body { padding: 20px; }
}

/* Tablets */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .main-header { padding: 0 16px; }
  .main-header .menu-toggle { display: flex; }
  .main-header .page-title { font-size: 16px; }
  .main-header .page-subtitle { font-size: 11px; }
  .main-body { padding: 16px; }

  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 22px; }
  .stat-card .stat-icon { width: 40px; height: 40px; font-size: 16px; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left { flex-direction: column; }
  .search-bar { max-width: 100%; }
  .filter-select { width: 100%; }

  .form-row { grid-template-columns: 1fr; }

  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .pos-product-card { padding: 12px; }
  .pos-product-card .product-emoji { font-size: 28px; }
  .pos-product-card .product-name { font-size: 12px; }
  .pos-product-card .product-price { font-size: 14px; }
  .pos-product-card .product-img { width: 52px; height: 52px; }

  .pos-categories { gap: 6px; }
  .pos-categories .cat-btn { padding: 6px 12px; font-size: 12px; }

  /* Cart on mobile */
  .cart-item { padding: 10px; gap: 8px; }
  .cart-item .item-name { font-size: 12px; }
  .cart-item .item-subtotal { font-size: 13px; min-width: 50px; }
  .cart-total .total-value { font-size: 20px; }

  .payment-methods { flex-wrap: wrap; }
  .payment-methods .pay-btn { padding: 8px; font-size: 11px; }
  .payment-methods .pay-btn i { font-size: 16px; }

  /* Modal full-width on mobile */
  .modal-overlay { padding: 10px; }
  .modal { max-width: 100%; max-height: 95vh; border-radius: var(--radius-lg); }
  .modal-header { padding: 16px 16px 12px; }
  .modal-header h3 { font-size: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Tables scroll */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  table thead th { padding: 10px 12px; font-size: 11px; }
  table tbody td { padding: 10px 12px; font-size: 13px; }

  /* Ticket */
  .ticket { width: 100%; max-width: 320px; padding: 24px 16px; }

  /* Toast */
  .toast-container { top: 10px; right: 10px; left: 10px; }
  .toast { min-width: auto; max-width: 100%; }

  /* Chart */
  .chart-container { height: 200px; }
}

/* Small phones */
@media (max-width: 480px) {
  .main-body { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 18px; }
  .stat-card .stat-label { font-size: 11px; }
  .stat-card .stat-icon { width: 36px; height: 36px; font-size: 14px; border-radius: 8px; }

  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
  .pos-product-card { padding: 10px; }
  .pos-product-card .product-emoji { font-size: 24px; margin-bottom: 4px; }
  .pos-product-card .product-name { font-size: 11px; -webkit-line-clamp: 1; }
  .pos-product-card .product-price { font-size: 13px; }
  .pos-product-card .product-stock { font-size: 10px; }
  .pos-product-card .product-img { width: 44px; height: 44px; }

  .pos-search .search-input { font-size: 14px; padding: 10px 48px 10px 38px; }
  .barcode-scan-btn { width: 36px; height: 36px; font-size: 16px; }

  .cart-footer { padding: 12px; }
  .cart-total { padding: 10px; margin-bottom: 12px; }
  .cart-total .total-value { font-size: 18px; }

  .card-header { padding: 14px 16px; }
  .card-header h3 { font-size: 14px; }
  .card-body { padding: 16px; }

  .login-container { padding: 32px 24px; }
  .login-logo .logo-icon { width: 60px; height: 60px; }
  .login-logo h1 { font-size: 20px; }

  /* Image upload area compact */
  .image-upload-area { padding: 12px; }
  .image-preview-container,
  .image-preview { width: 100px; height: 100px; }
  .image-input-row { flex-direction: column; }
  .image-actions-row { flex-direction: column; }
  .image-search-results .image-search-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-500); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
