/* ============================================================================
   SliceHub POS — Dark Mode Theme
   Pure CSS, no frameworks. Optimized for touch POS screens.
   ============================================================================ */

:root {
  --bg-primary:    #0a0e17;
  --bg-secondary:  #111827;
  --bg-card:       #1a2035;
  --bg-elevated:   #1f2a40;
  --bg-input:      #0d1321;

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #475569;

  --accent:        #3b82f6;
  --accent-hover:  #2563eb;
  --success:       #22c55e;
  --success-hover: #16a34a;
  --danger:        #ef4444;
  --danger-hover:  #dc2626;
  --warning:       #f59e0b;

  --border:        rgba(255, 255, 255, 0.06);
  --border-active: rgba(59, 130, 246, 0.4);
  --shadow:        0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg:     0 8px 40px rgba(0, 0, 0, 0.6);

  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition:    150ms ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================================
   LOGIN VIEW
   ============================================================================ */

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 50%),
    var(--bg-primary);
}

.login-container {
  width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -1px;
  color: #fff;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -4px;
}

/* PIN display */
.pin-display-wrapper {
  width: 100%;
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 20px 0;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: transparent;
  transition: all var(--transition);
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

.pin-dot.error {
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Error message */
.pin-error {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  min-height: 20px;
  opacity: 0;
  transition: opacity var(--transition);
}

.pin-error.visible {
  opacity: 1;
}

/* PIN Pad */
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.pin-btn {
  height: 68px;
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 600;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.pin-btn:hover {
  background: var(--bg-elevated);
  border-color: rgba(255, 255, 255, 0.1);
}

.pin-btn:active {
  transform: scale(0.95);
  background: var(--accent);
  border-color: var(--accent);
}

.pin-btn.action-clear {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.pin-btn.action-clear:active {
  background: var(--danger);
  color: #fff;
}

.pin-btn.action-enter {
  font-size: 14px;
  font-weight: 700;
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.pin-btn.action-enter:hover {
  background: var(--success-hover);
}

.pin-btn.action-enter:active {
  transform: scale(0.95);
}

.pin-btn.action-enter:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Loading spinner on login */
.pin-btn.loading {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.pin-btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* User greeting after login */
.login-user-info {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}

/* ============================================================================
   POS VIEW — Main Layout
   ============================================================================ */

#pos-view {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 380px;
  grid-template-areas:
    "topbar  topbar"
    "menu    cart";
  background: var(--bg-primary);
}

/* ─── Top Bar ─────────────────────────────────────────────────────────────── */

.pos-topbar {
  grid-area: topbar;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
}

.topbar-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.topbar-order-type {
  display: flex;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.order-type-btn {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: transparent;
  transition: all var(--transition);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.order-type-btn:last-child {
  border-right: none;
}

.order-type-btn.active {
  background: var(--accent);
  color: #fff;
}

.order-type-btn:hover:not(.active) {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
}

.topbar-spacer {
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.topbar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.topbar-user-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.topbar-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.topbar-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* ─── Menu Panel (Left) ──────────────────────────────────────────────────── */

.menu-panel {
  grid-area: menu;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.categories-bar {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}

.categories-bar::-webkit-scrollbar {
  height: 0;
}

.cat-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--transition);
  flex-shrink: 0;
}

.cat-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.cat-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.25);
}

.items-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  align-content: start;
}

.items-grid::-webkit-scrollbar {
  width: 4px;
}

.items-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition);
  min-height: 100px;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.item-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.item-card:hover {
  background: var(--bg-elevated);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.item-card:hover::before {
  opacity: 1;
}

.item-card:active {
  transform: scale(0.97);
}

.item-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.item-price {
  font-size: 16px;
  font-weight: 800;
  color: var(--success);
}

.item-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ─── Cart Panel (Right) ─────────────────────────────────────────────────── */

.cart-panel {
  grid-area: cart;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow: hidden;
}

.cart-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cart-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.cart-count {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 20px;
  min-width: 28px;
  text-align: center;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.cart-items::-webkit-scrollbar {
  width: 3px;
}

.cart-items::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
}

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}

.cart-empty-icon {
  font-size: 48px;
  opacity: 0.3;
}

.cart-empty-text {
  font-size: 13px;
  font-weight: 600;
}

/* Cart line item */
.cart-line {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.cart-line:hover {
  background: rgba(255,255,255,0.02);
}

.cart-line-qty {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent);
}

.cart-line-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cart-line-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-line-mods {
  font-size: 10px;
  color: var(--text-muted);
}

.cart-line-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.cart-line-actions {
  display: flex;
  gap: 4px;
}

.cart-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.cart-action-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.cart-action-btn.remove:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Cart Footer / Summary */
.cart-summary {
  border-top: 1px solid var(--border);
  padding: 16px;
  flex-shrink: 0;
  background: var(--bg-primary);
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.cart-summary-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.cart-summary-value {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.cart-summary-row.total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.cart-summary-row.total .cart-summary-label {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.cart-summary-row.total .cart-summary-value {
  font-size: 22px;
  font-weight: 900;
  color: var(--success);
}

.cart-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 16px;
  flex-shrink: 0;
}

.cart-btn {
  height: 52px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.cart-btn.secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.cart-btn.secondary:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.cart-btn.primary {
  background: var(--success);
  color: #fff;
  border: none;
  grid-column: span 2;
}

.cart-btn.primary:hover {
  background: var(--success-hover);
}

.cart-btn.primary:active {
  transform: scale(0.98);
}

.cart-btn.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Responsive: tablets in portrait */
@media (max-width: 900px) {
  #pos-view {
    grid-template-columns: 1fr 320px;
  }
  .items-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

@media (max-width: 700px) {
  #pos-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "topbar"
      "menu"
      "cart";
  }
  .cart-panel {
    max-height: 45vh;
  }
}
