/**
 * Picato POS — Stylesheet
 * تصميم نقطة البيع
 * Picato Tech © 2026
 */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

/* ===== Reset & Variables ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #6366f1;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Cairo', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== Login Screen ===== */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
}

.login-box {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 350px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box .logo-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-box h2 {
  font-size: 22px;
  margin-bottom: 4px;
  color: var(--primary);
}

.login-box p {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}

.pin-display {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.2s;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 240px;
  margin: 0 auto;
}

.pin-btn {
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: white;
  font-size: 22px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.pin-btn:hover { background: var(--primary-light); }
.pin-btn:active { transform: scale(0.95); background: var(--primary); color: white; }
.pin-btn.clear { font-size: 14px; color: var(--danger); border-color: var(--danger-light); }
.pin-btn.clear:hover { background: var(--danger-light); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

.login-employees {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-light);
}

/* ===== POS Layout ===== */
.pos-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.pos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.employee-name {
  font-size: 13px;
  color: var(--text-light);
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: 20px;
}

.header-center {
  flex: 1;
  max-width: 400px;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

[dir="rtl"] .search-box input {
  padding: 8px 12px 8px 36px;
}

.search-box input:focus { border-color: var(--primary); }

.search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
}

[dir="rtl"] .search-icon { right: auto; left: 10px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  transition: all 0.15s;
}

.btn-icon:hover { background: var(--primary-light); border-color: var(--primary); }

.sync-count {
  font-size: 12px;
  color: var(--warning);
}

.status-online { color: var(--success); font-size: 12px; }
.status-offline { color: var(--danger); font-size: 12px; }
.status-syncing { color: var(--warning); font-size: 12px; }

/* ===== Body (Products + Cart) ===== */
.pos-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Products Section */
.products-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.categories-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.categories-bar::-webkit-scrollbar { height: 4px; }
.categories-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cat-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.cat-btn:hover { border-color: var(--primary); color: var(--primary); }
.cat-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.products-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 12px 16px;
  overflow-y: auto;
  align-content: start;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.product-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-card:active { transform: scale(0.97); }
.product-card.out-of-stock { opacity: 0.4; pointer-events: none; }
.product-card.pulse { animation: pulse 0.3s ease; }

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 4px var(--primary-light); }
  100% { transform: scale(1); }
}

.product-img { font-size: 32px; margin-bottom: 4px; }
.product-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.product-price { font-size: 14px; color: var(--primary); font-weight: 700; }
.product-stock { font-size: 11px; color: var(--text-light); }

.no-products {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 16px;
}

/* ===== Cart Section ===== */
.cart-section {
  width: 360px;
  min-width: 360px;
  background: var(--bg-card);
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 8px rgba(0,0,0,0.04);
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.cart-header h3 { font-size: 16px; }

.cart-actions {
  display: flex;
  gap: 6px;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.cart-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 14px;
}

.cart-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cart-item-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-item-name { font-weight: 600; font-size: 13px; }
.cart-item-price { font-size: 12px; color: var(--text-light); }

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-qty {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: var(--font);
}

.btn-qty:hover { background: var(--primary-light); border-color: var(--primary); }

.cart-item-qty {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.cart-item-total {
  margin-inline-start: auto;
  font-weight: 700;
  color: var(--primary);
  font-size: 13px;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  font-weight: 700;
}

.btn-remove:hover { color: #dc2626; }

/* Cart Summary */
.cart-summary {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}

.summary-row.total {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  padding-top: 6px;
  margin-top: 4px;
  border-top: 2px solid var(--primary);
}

.summary-row.discount { color: var(--danger); }
.summary-row.items-count { font-size: 12px; color: var(--text-light); }

.cart-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.btn-checkout {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.btn-checkout:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Buttons ===== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-info { background: var(--info); color: white; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}

.modal-box {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Payment Modal ===== */
.payment-methods {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.pay-method {
  flex: 1;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  background: white;
}

.pay-method:hover { border-color: var(--primary); }
.pay-method.active { border-color: var(--primary); background: var(--primary-light); }
.pay-method .icon { font-size: 24px; }
.pay-method .label { font-size: 13px; margin-top: 4px; }

.quick-amounts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.quick-btn {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-btn:hover { background: var(--primary-light); border-color: var(--primary); }

.payment-input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  outline: none;
  margin-top: 12px;
}

.payment-input:focus { border-color: var(--primary); }

.change-display {
  text-align: center;
  padding: 12px;
  margin-top: 12px;
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 700;
}

.change-display.positive { background: var(--success-light); color: var(--success); }
.change-display.negative { background: var(--danger-light); color: var(--danger); }

/* ===== Receipt ===== */
.receipt-display {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 12px;
  text-align: center;
}

.receipt-display h4 {
  color: var(--success);
  font-size: 18px;
  margin-bottom: 8px;
}

/* ===== Held Orders ===== */
.held-order-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.held-order-item div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.held-order-item small { color: var(--text-light); font-size: 11px; }

/* ===== Settings ===== */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-panel {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.settings-section {
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

.form-group input:focus,
.form-group select:focus { border-color: var(--primary); }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  cursor: pointer;
}

.settings-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.settings-footer .btn { width: 100%; padding: 12px; font-size: 16px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  transition: all 0.3s;
  box-shadow: var(--shadow-md);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: white; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .pos-body { flex-direction: column; }
  
  .cart-section {
    width: 100%;
    min-width: 100%;
    max-height: 45vh;
    border-inline-start: none;
    border-top: 2px solid var(--border);
  }
  
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    padding: 8px;
  }
  
  .product-card { padding: 8px; }
  .product-img { font-size: 24px; }
  .product-name { font-size: 11px; }
  .product-price { font-size: 12px; }
  
  .header-center { max-width: 200px; }
  .employee-name { display: none; }
}

@media (max-width: 480px) {
  .pos-header { padding: 6px 8px; }
  .logo { font-size: 14px; }
  .header-center { display: none; }
  
  .cart-section { max-height: 50vh; }
  
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}

/* ===== Print ===== */
@media print {
  .pos-header,
  .categories-bar,
  .cart-footer,
  .cart-header { display: none; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }
