/* =====================================================
   Café Aroma POS — Estilos
   Paleta: café oscuro, crema, beige, dorado
   ===================================================== */

:root {
  --coffee-dark: #3b2418;
  --coffee: #5c3a28;
  --coffee-mid: #8a5a3d;
  --gold: #c9962c;
  --gold-light: #e0b563;
  --cream: #fbf3e7;
  --beige: #f0e2cc;
  --beige-dark: #e3d0ac;
  --text-dark: #3b2418;
  --text-light: #fbf3e7;
  --danger: #b3402a;
  --success: #4b7a51;
  --radius: 14px;
  --shadow: 0 4px 14px rgba(59, 36, 24, 0.15);
}

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

body {
  font-family: "Segoe UI", Tahoma, Verdana, sans-serif;
  background: var(--beige);
  color: var(--text-dark);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; }
input { font-family: inherit; }

/* ===================== HEADER ===================== */
.app-header {
  background: linear-gradient(135deg, var(--coffee-dark), var(--coffee));
  color: var(--text-light);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 2rem; }
.brand h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: 0.5px; }
.brand h1 small { font-weight: 400; font-size: 0.9rem; color: var(--gold-light); margin-left: 6px; }

.stats-bar { display: flex; gap: 18px; flex-wrap: wrap; }
.stat {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(224,181,99,0.35);
  border-radius: var(--radius);
  padding: 6px 16px;
  text-align: center;
  min-width: 100px;
}
.stat-value { display: block; font-size: 1.2rem; font-weight: 700; color: var(--gold-light); }
.stat-label { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.85; }

/* ===================== LAYOUT ===================== */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  padding: 18px;
  align-items: start;
}

@media (max-width: 900px) {
  .pos-layout { grid-template-columns: 1fr; }
}

/* ===================== PRODUCTS PANEL ===================== */
.products-panel {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.products-toolbar { margin-bottom: 14px; }

.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border: 2px solid var(--beige-dark);
  border-radius: 999px;
  padding: 8px 16px;
  margin-bottom: 12px;
}
.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 1rem;
  background: transparent;
  color: var(--text-dark);
}
.search-icon { margin-right: 8px; opacity: 0.6; }

.category-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-btn {
  background: var(--beige);
  color: var(--coffee-dark);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}
.cat-btn:hover { background: var(--gold-light); }
.cat-btn.active { background: var(--coffee); color: var(--text-light); }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.product-card {
  background: #fff;
  border: 2px solid var(--beige-dark);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  min-height: 120px;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(59,36,24,0.18);
  border-color: var(--gold);
}
.product-card:active { transform: translateY(0); }

.product-icon { font-size: 1.8rem; }
.product-name { font-weight: 700; font-size: 0.92rem; color: var(--coffee-dark); }
.product-price { font-weight: 700; color: var(--gold); font-size: 1rem; }

.no-results { grid-column: 1 / -1; text-align: center; color: var(--coffee-mid); padding: 30px; font-style: italic; }

/* ===================== SALE PANEL ===================== */
.sale-panel {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
}

.sale-header { display: flex; align-items: center; justify-content: space-between; }
.sale-header h2 { color: var(--coffee-dark); font-size: 1.2rem; }

.btn-icon {
  background: var(--beige);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--gold-light); }

.cart-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}

.cart-empty { text-align: center; color: var(--coffee-mid); font-style: italic; padding: 30px 10px; }

.cart-item {
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--beige-dark);
}

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 700; font-size: 0.92rem; color: var(--coffee-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 0.8rem; color: var(--coffee-mid); }

.qty-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--beige);
  font-weight: 700;
  font-size: 1rem;
  color: var(--coffee-dark);
}
.qty-btn:hover { background: var(--gold-light); }
.qty-value { min-width: 20px; text-align: center; font-weight: 700; }

.cart-item-subtotal { font-weight: 700; color: var(--gold); min-width: 60px; text-align: right; }

.remove-btn {
  background: transparent;
  color: var(--danger);
  font-size: 1.1rem;
  padding: 2px 6px;
}
.remove-btn:hover { opacity: 0.7; }

.sale-summary { border-top: 2px dashed var(--beige-dark); padding-top: 10px; }
.summary-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.95rem; color: var(--coffee); }
.total-row { font-size: 1.3rem; font-weight: 800; color: var(--coffee-dark); border-top: 1px solid var(--beige-dark); margin-top: 6px; padding-top: 8px; }

.sale-actions { display: flex; gap: 10px; }

.btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--coffee-dark); }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-secondary { background: var(--beige); color: var(--coffee-dark); }
.btn-secondary:hover { background: var(--beige-dark); }

/* ===================== MODALS ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(59,36,24,0.55);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--cream);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 2px solid var(--beige-dark);
}
.modal-header h2 { color: var(--coffee-dark); font-size: 1.15rem; }

.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; gap: 10px; padding: 16px 18px; border-top: 2px solid var(--beige-dark); }

.modal-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--coffee-dark);
  color: var(--text-light);
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 1.05rem;
}
.modal-total strong { color: var(--gold-light); font-size: 1.4rem; }

.payment-methods { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.method-btn {
  flex: 1;
  min-width: 100px;
  background: #fff;
  border: 2px solid var(--beige-dark);
  border-radius: var(--radius);
  padding: 12px 8px;
  font-weight: 700;
  color: var(--coffee-dark);
  font-size: 0.9rem;
}
.method-btn.active { border-color: var(--gold); background: var(--beige); }

.cash-fields { display: none; flex-direction: column; gap: 8px; }
.cash-fields.visible { display: flex; }
.cash-fields label { font-weight: 700; color: var(--coffee-dark); font-size: 0.9rem; }
.cash-fields input {
  padding: 12px 14px;
  font-size: 1.1rem;
  border: 2px solid var(--beige-dark);
  border-radius: 10px;
  outline: none;
}
.cash-fields input:focus { border-color: var(--gold); }

.change-row {
  display: flex;
  justify-content: space-between;
  background: var(--beige);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 1rem;
}
.change-row strong { color: var(--success); font-size: 1.2rem; }
.change-row.negative strong { color: var(--danger); }

.cash-warning { display: none; color: var(--danger); font-size: 0.85rem; font-weight: 600; }
.cash-warning.visible { display: block; }

/* ===================== TICKET ===================== */
.ticket-modal { max-width: 380px; }
.ticket {
  background: #fff;
  border: 1px dashed var(--coffee-mid);
  border-radius: 8px;
  padding: 18px;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  color: var(--text-dark);
}
.ticket-center { text-align: center; }
.ticket-title { font-size: 1.1rem; font-weight: 800; color: var(--coffee-dark); }
.ticket-divider { border-top: 1px dashed var(--coffee-mid); margin: 8px 0; }
.ticket-row { display: flex; justify-content: space-between; padding: 2px 0; }
.ticket-item-line { padding: 2px 0; }
.ticket-total { font-weight: 800; font-size: 1rem; }
.ticket-thanks { text-align: center; margin-top: 10px; font-weight: 700; color: var(--gold); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 640px) {
  .app-header { padding: 10px 14px; }
  .brand h1 { font-size: 1.1rem; }
  .stats-bar { width: 100%; justify-content: space-between; }
  .stat { min-width: unset; flex: 1; padding: 6px 8px; }
  .pos-layout { padding: 10px; gap: 10px; }
  .sale-panel { position: static; max-height: none; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

@media print {
  body * { visibility: hidden; }
  .ticket, .ticket * { visibility: visible; }
  .ticket { position: absolute; top: 0; left: 0; width: 100%; border: none; }
}
