@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:     #0b0f1a;
  --bg-surface:  #111827;
  --bg-card:     #1a2235;
  --bg-input:    #0d1424;
  --border:      rgba(99, 131, 255, 0.15);
  --border-glow: rgba(99, 131, 255, 0.45);

  --accent:      #6366f1;
  --accent-2:    #8b5cf6;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);

  --text-primary:   #e8ecf4;
  --text-secondary: #8892a4;
  --text-muted:     #4b5563;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.45), 0 1px 4px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 30px var(--accent-glow);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Background mesh ──────────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(99,102,241,.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 110%, rgba(139,92,246,.14) 0%, transparent 55%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(16,185,129,.06) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.wrapper { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 0 24px 60px; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}
.app-logo { display: flex; align-items: center; gap: 14px; }
.logo-icon {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.logo-text h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.logo-text p  { font-size: .8rem; color: var(--text-secondary); }
.badge {
  font-size: .7rem; font-weight: 600; letter-spacing: .06em;
  padding: 4px 12px; border-radius: 999px; text-transform: uppercase;
  background: linear-gradient(90deg, rgba(99,102,241,.2), rgba(139,92,246,.2));
  border: 1px solid var(--border-glow);
  color: #a5b4fc;
}

/* ── Two-col grid ─────────────────────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .main-grid { grid-template-columns: 1fr; } }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-glow); }

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(99,102,241,.06) 0%, transparent 100%);
}
.card-header .icon { font-size: 1.1rem; }
.card-header h2 { font-size: .95rem; font-weight: 700; letter-spacing: -0.01em; }
.card-header p  { font-size: .75rem; color: var(--text-secondary); margin-top: 1px; }
.card-body { padding: 22px; }

/* ── Connection type toggle ───────────────────────────────────────────────── */
.conn-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 20px;
}
.conn-btn {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 6px; padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input); cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary); font-size: .8rem; font-weight: 500;
}
.conn-btn .conn-icon { font-size: 1.5rem; }
.conn-btn input[type=radio] { position: absolute; opacity: 0; width: 0; }
.conn-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.conn-btn.active {
  border-color: var(--accent);
  background: rgba(99,102,241,.12);
  color: var(--text-primary);
  box-shadow: 0 0 18px var(--accent-glow);
}
.conn-btn.active::after {
  content: '✓';
  position: absolute; top: 8px; right: 10px;
  font-size: .7rem; color: var(--accent); font-weight: 700;
}

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label {
  display: block; font-size: .75rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .05em;
}
input[type=text], input[type=number], input[type=email], select, textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: inherit; font-size: .88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%238892a4' viewBox='0 0 20 20'%3E%3Cpath d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px; }
textarea { resize: vertical; min-height: 72px; }

/* ── Connection panels ────────────────────────────────────────────────────── */
.conn-panel { display: none; animation: fadeSlide .25s ease; }
.conn-panel.active { display: block; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 22px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-success { background: linear-gradient(135deg, #059669, var(--success)); color: #fff; box-shadow: 0 4px 16px rgba(16,185,129,.3); }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,185,129,.4); }
.btn-danger  { background: linear-gradient(135deg, #dc2626, var(--danger)); color: #fff; }
.btn-ghost   { background: rgba(255,255,255,.06); color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: rgba(99,102,241,.12); border-color: var(--accent); color: var(--text-primary); }
.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Action buttons row ───────────────────────────────────────────────────── */
.action-bar { display: flex; gap: 10px; margin-top: 8px; }
.action-bar .btn { flex: 1; }

/* ── Status indicator ─────────────────────────────────────────────────────── */
.status-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 500;
  margin-top: 14px; transition: all var(--transition);
  border: 1px solid transparent;
  min-height: 46px;
}
.status-bar.idle    { background: rgba(255,255,255,.04); color: var(--text-secondary); border-color: var(--border); }
.status-bar.loading { background: rgba(99,102,241,.1);  color: #a5b4fc;  border-color: var(--accent); }
.status-bar.success { background: rgba(16,185,129,.1);  color: #34d399;  border-color: var(--success); }
.status-bar.error   { background: rgba(239,68,68,.1);   color: #f87171;  border-color: var(--danger); }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-muted);
}
.status-bar.loading .status-dot { background: var(--accent); animation: pulse 1s infinite; }
.status-bar.success .status-dot { background: var(--success); }
.status-bar.error   .status-dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Items table ──────────────────────────────────────────────────────────── */
.items-section { margin-bottom: 20px; }
.items-header {
  display: grid; grid-template-columns: 1fr 90px 70px 40px;
  gap: 8px; padding: 0 0 8px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.items-header span { font-size: .72rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; }
.item-row {
  display: grid; grid-template-columns: 1fr 90px 70px 40px;
  gap: 8px; margin-bottom: 8px; animation: fadeSlide .2s ease;
}
.item-row input { padding: 8px 10px; font-size: .82rem; }
.remove-item-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  color: #f87171; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 1rem;
  transition: all var(--transition); flex-shrink: 0;
}
.remove-item-btn:hover { background: rgba(239,68,68,.25); }

/* ── Receipt preview ──────────────────────────────────────────────────────── */
.receipt-preview-wrap {
  position: sticky; top: 24px;
}
.receipt-paper {
  background: #fff; color: #111; border-radius: 6px;
  padding: 24px 20px; font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  max-height: 70vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  position: relative;
}
.receipt-paper::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 40px; height: 4px; background: #ddd; border-radius: 0 0 4px 4px;
}
.receipt-paper::after {
  content: '';
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 70%; height: 8px;
  background: linear-gradient(180deg, #fff, transparent);
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex; gap: 4px; padding: 5px;
  background: var(--bg-input); border-radius: var(--radius-sm);
  margin-bottom: 20px; border: 1px solid var(--border);
}
.tab-btn {
  flex: 1; padding: 8px 14px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-secondary);
  font-family: inherit; font-size: .8rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.tab-btn.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeSlide .2s ease; }

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row label { margin: 0; text-transform: none; font-size: .84rem; color: var(--text-primary); font-weight: 500; }
.toggle-row small { display: block; font-size: .72rem; color: var(--text-secondary); font-weight: 400; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; inset: 0; background: var(--bg-input);
  border: 1.5px solid var(--border); border-radius: 999px;
  cursor: pointer; transition: all var(--transition);
}
.switch-slider::before {
  content: ''; position: absolute; width: 14px; height: 14px;
  left: 3px; top: 2px; background: var(--text-secondary);
  border-radius: 50%; transition: all var(--transition);
}
.switch input:checked + .switch-slider { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); background: #fff; }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.section-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 20px 0 14px;
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-radius: var(--radius);
  font-size: .84rem; font-weight: 500; min-width: 260px; max-width: 360px;
  pointer-events: all; box-shadow: 0 8px 32px rgba(0,0,0,.5);
  animation: slideIn .3s ease;
}
.toast.success { background: #065f46; border: 1px solid var(--success); color: #a7f3d0; }
.toast.error   { background: #7f1d1d; border: 1px solid var(--danger);  color: #fca5a5; }
.toast.info    { background: #1e1b4b; border: 1px solid var(--accent);  color: #a5b4fc; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ── Log panel ────────────────────────────────────────────────────────────── */
.log-panel {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace; font-size: .75rem;
  color: var(--text-secondary); max-height: 160px; overflow-y: auto;
  margin-top: 14px; line-height: 1.8;
}
.log-entry { border-bottom: 1px solid rgba(255,255,255,.04); padding: 2px 0; }
.log-entry.ok  { color: #34d399; }
.log-entry.err { color: #f87171; }
.log-entry.info{ color: #60a5fa; }
.log-timestamp { color: var(--text-muted); margin-right: 6px; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Print Media Styles ────────────────────────────────────────────────────── */
@media print {
  body * {
    visibility: hidden;
  }
  #print-area-wrapper, #print-area-wrapper * {
    visibility: visible;
  }
  #print-area-wrapper {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm; /* standard POS receipt width */
    background: #fff;
    color: #000;
    padding: 10px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
  }
  /* Remove page margin headers/footers in modern browsers */
  @page {
    size: auto;
    margin: 0mm;
  }
}

/* Hidden container for print layout */
#print-area-wrapper {
  display: none;
}
@media print {
  #print-area-wrapper {
    display: block;
  }
}

