/* POS Design System & CSS Variables */
:root {
  --pos-bg: #0b0f19;
  --pos-card-bg: rgba(22, 30, 46, 0.85);
  --pos-card-border: rgba(255, 255, 255, 0.12);
  --pos-input-bg: #111827;

  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-indigo: #6366f1;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-main: 'Noto Sans KR', 'Outfit', sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background-color: var(--pos-bg);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.4;
}

.pos-app {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background-color: var(--pos-bg);
}

/* Screens System */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* POS Top Bar */
.pos-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(22, 30, 46, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--pos-card-border);
}

.pos-topbar.compact {
  padding: 10px 14px;
}

.brand {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  color: var(--accent-cyan);
  font-size: 1.3rem;
}

.accent-cyan {
  color: var(--accent-cyan);
}

.history-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--pos-card-border);
  color: var(--accent-cyan);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-btn:active {
  transform: scale(0.95);
  background: rgba(6, 182, 212, 0.2);
}

.workspace-date-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #000;
  border: 1.5px solid var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.workspace-date-picker select {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 800;
  outline: none;
}

.workspace-title {
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pos-dot.online {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-emerald);
}

/* Screen 1: Store Selection */
.store-select-main {
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

.welcome-banner h2 {
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.welcome-banner p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.store-card-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.store-pos-card {
  background: linear-gradient(135deg, rgba(30, 41, 64, 0.9), rgba(15, 23, 42, 0.9));
  border: 2px solid var(--accent-cyan);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: left;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.store-pos-card.alt-theme {
  border-color: var(--accent-indigo);
  background: linear-gradient(135deg, rgba(49, 46, 129, 0.4), rgba(15, 23, 42, 0.9));
}

.store-pos-card:active {
  transform: scale(0.97);
}

.store-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.store-badge {
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.store-icon {
  font-size: 1.8rem;
  color: var(--accent-cyan);
}

.store-title {
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.store-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.store-card-footer {
  display: flex;
  justify-content: flex-end;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

/* 📱 PWA Install Helper Button */
.pwa-install-section {
  margin-top: 10px;
}

.pwa-install-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px dashed var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.pwa-install-btn:active {
  background: rgba(6, 182, 212, 0.15);
  transform: scale(0.98);
}

/* Screen 2: Fixed Sticky Search Bar & Content */
.sticky-top-container {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--pos-bg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.pos-search-wrapper {
  padding: 10px 14px;
  background: rgba(17, 24, 39, 0.95);
  border-bottom: 1px solid var(--pos-card-border);
}

/* Search Row: Search input + Add Product Button */
.pos-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.pos-search-box.compact-input {
  flex: 1;
  position: relative;
  margin-bottom: 0;
}

.pos-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-cyan);
  font-size: 1rem;
}

.pos-search-box input {
  width: 100%;
  padding: 12px 34px 12px 38px;
  background: #000;
  border: 2px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 700;
  outline: none;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.25);
}

.pos-search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.add-product-btn {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #000;
  border: none;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.add-product-btn:active {
  transform: scale(0.94);
}

.add-product-btn.inline {
  margin-top: 14px;
}

.choseong-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.choseong-bar::-webkit-scrollbar {
  display: none;
}

.cs-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cs-btn:active, .cs-btn.active {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
}

/* Product Results List */
.pos-content {
  padding: 12px 14px 40px 14px;
  flex: 1;
}

.pos-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pos-prod-card {
  background: var(--pos-card-bg);
  border: 1px solid var(--pos-card-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
}

.pos-prod-card:active {
  transform: scale(0.98);
  background: rgba(6, 182, 212, 0.15);
  border-color: var(--accent-cyan);
}

.pos-prod-info {
  display: flex;
  flex-direction: column;
}

.pos-prod-name {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-main);
  margin-bottom: 2px;
}

.pos-prod-choseong {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
}

.pos-prod-colors-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.color-count-tag {
  background: rgba(6, 182, 212, 0.2);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent-cyan);
}

.pos-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* POS Drawer: Left Colors & Right Keypad */
.pos-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pos-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.pos-drawer {
  width: 100%;
  max-width: 600px;
  background: #0d1322;
  border-top: 3px solid var(--accent-cyan);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom)) 16px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.9);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--pos-card-border);
  margin-bottom: 14px;
}

.drawer-title-group h3 {
  font-size: 1.35rem;
  font-weight: 900;
}

.drawer-choseong {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.close-drawer-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  padding: 6px;
  cursor: pointer;
}

/* POS Entry Layout Grid */
.pos-entry-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.color-options-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.color-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--pos-card-border);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-btn.active {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
  color: #fff;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.color-btn.has-qty {
  border-left: 4px solid var(--accent-emerald);
}

.quantity-display-box {
  background: #000;
  border: 2px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

.active-color-badge {
  background: var(--accent-cyan);
  color: #000;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 6px;
}

.qty-val-wrapper {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.qty-val {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent-cyan);
  font-family: 'Outfit', sans-serif;
}

.qty-unit {
  font-size: 1rem;
  color: var(--text-muted);
}

/* POS Touch Keypad Matrix */
.pos-keypad-matrix {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pos-kp-btn {
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pos-kp-btn:active {
  transform: scale(0.93);
}

.pos-kp-btn.num {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.pos-kp-btn.quick {
  background: rgba(99, 102, 241, 0.25);
  color: var(--accent-cyan);
  border-color: rgba(99, 102, 241, 0.4);
  font-size: 1rem;
}

.pos-kp-btn.action {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

.pos-kp-btn.submit {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 900;
  font-size: 1.05rem;
  border: none;
}

.pos-kp-btn.next {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #fff;
  grid-column: span 3;
}

.pos-kp-btn.zero {
  grid-column: span 1;
}

/* Form Modals (Add Product & Install Guide) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.form-modal-card, .install-guide-card {
  background: #0f172a;
  border: 1.5px solid var(--accent-cyan);
  border-radius: var(--radius-lg);
  width: 92%;
  max-width: 460px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--pos-card-border);
}

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

.form-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

.text-rose { color: var(--accent-rose); }
.text-emerald { color: var(--accent-emerald); }

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: #000;
  border: 1.5px solid var(--pos-card-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-cyan);
}

/* Color Tags Input */
.color-input-row {
  display: flex;
  gap: 8px;
}

.add-color-tag-btn {
  background: rgba(99, 102, 241, 0.3);
  border: 1px solid var(--accent-indigo);
  color: #fff;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.color-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.color-tag-chip {
  background: rgba(6, 182, 212, 0.2);
  border: 1px solid var(--accent-cyan);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-tag-chip i {
  cursor: pointer;
  opacity: 0.7;
}

.color-tag-chip i:hover {
  opacity: 1;
  color: var(--accent-rose);
}

/* Size Multi Selector Grid */
.size-selector-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.size-toggle-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--pos-card-border);
  color: var(--text-muted);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.size-toggle-btn.active {
  background: var(--accent-emerald);
  color: #000;
  border-color: var(--accent-emerald);
}

.form-footer {
  margin-top: 8px;
}

.submit-form-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.submit-form-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

/* Install Guide Modal Styling */
.guide-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.guide-section {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--pos-card-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.guide-os-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-steps {
  padding-left: 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* History View Modal */
.history-modal-card {
  background: #0f172a;
  border: 1px solid var(--pos-card-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.history-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.history-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.history-date-row select {
  flex: 1;
  background: #000;
  border: 1.5px solid var(--accent-cyan);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 800;
  outline: none;
}

.history-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hist-tab {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--pos-card-border);
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hist-tab.active {
  background: var(--accent-amber);
  color: #000;
  border-color: var(--accent-amber);
}

.history-summary-bar {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--pos-card-border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.history-table-header {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  border-bottom: 1px solid var(--pos-card-border);
  margin-bottom: 8px;
}

.history-list-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 45vh;
}

.history-record-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--pos-card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-record-card.has-discrepancy {
  border-left: 4px solid var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
}

.hist-prod-name {
  font-weight: 900;
  font-size: 1.05rem;
}

.hist-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.hist-meta-tag {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
}

.hist-right-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hist-qty-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.hist-gap-badge {
  font-size: 0.8rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 2px;
}

.badge-gap-minus {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
  border: 1px solid var(--accent-rose);
}

.badge-gap-plus {
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
}

.badge-gap-zero {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
}
