/* ============================================
   GoodStore POS Dashboard Styles
   ============================================ */

:root {
  --sidebar-bg: #1a1c23;
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #6b7280;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-body: #f3f4f6;
  --bg-card: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-sm: 6px;
  --transition: 200ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
  font-size: 15px;
  color: var(--text-main);
  background: var(--bg-body);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   Utilities
   ============================================ */
.hidden { display: none !important; }

/* ============================================
   Login Overlay
   ============================================ */
.overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.login-card {
  background: var(--bg-card);
  width: 100%; max-width: 400px;
  padding: 40px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  font-size: 1.6rem; font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.login-card h2 {
  font-size: 1.2rem; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group.inline {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 0;
}

.form-group.inline input,
.form-group.inline select {
  width: auto; min-width: 160px;
}

.form-group label {
  display: block;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

input, select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 1.2em;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.95rem; font-weight: 500;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 50ms;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--secondary);
  color: #fff;
}
.btn-secondary:hover { background: #4b5563; }

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
}
.btn-outline:hover { background: rgba(255,255,255,0.1); }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.btn-group {
  display: flex; gap: 10px; flex-wrap: wrap;
}

/* ============================================
   Toast
   ============================================ */
#toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 3000;
  display: flex; flex-direction: column; gap: 10px;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  padding: 14px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  animation: slideIn 250ms ease;
  max-width: 320px;
  font-size: 0.9rem;
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Loading
   ============================================ */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 2500;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   Layout
   ============================================ */
#app {
  display: flex;
  min-height: 100vh;
}

/* Mobile Header */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--sidebar-bg);
  color: #fff;
  align-items: center;
  padding: 0 16px;
  z-index: 1100;
}

.menu-btn {
  background: none; border: none; color: #fff;
  font-size: 1.4rem; cursor: pointer; padding: 4px 8px;
}

.mobile-title {
  flex: 1; text-align: center;
  font-weight: 600; font-size: 1rem;
}

.logout-btn {
  background: none; border: none; color: #fff;
  font-size: 0.85rem; cursor: pointer; opacity: 0.8;
}
.logout-btn:hover { opacity: 1; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 1200;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-logo {
  font-size: 1.3rem; font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 0.8rem; opacity: 0.5; margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 4px;
}

.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.nav-link.active {
  background: var(--primary);
  color: #fff;
}

.nav-icon {
  font-size: 1.1rem;
  width: 24px; text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 28px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem; font-weight: 700;
}

/* ============================================
   Cards
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  background: #eef2ff;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-info { flex: 1; }

.stat-label {
  font-size: 0.8rem; color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.6rem; font-weight: 700;
  color: var(--text-main);
}

.info-card,
.form-card,
.result-card,
.table-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.info-card h3 {
  font-size: 1.05rem; font-weight: 600;
  margin-bottom: 8px;
}

.info-card p {
  color: var(--text-muted); line-height: 1.6;
}

.form-card h3 {
  font-size: 1rem; font-weight: 600;
  margin-bottom: 16px;
}

.result-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.result-card.error {
  background: #fef2f2;
  border-color: #fecaca;
}

/* ============================================
   Tables
   ============================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table thead th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f9fafb;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--transition);
}

.pagination button:hover:not(:disabled) {
  background: #f3f4f6;
}

.pagination button:disabled {
  opacity: 0.4; cursor: not-allowed;
}

.pagination button.active {
  background: var(--primary);
  color: #fff; border-color: var(--primary);
}

/* ============================================
   Filters
   ============================================ */
.filter-bar {
  display: flex; align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-bar .form-group {
  margin-bottom: 0;
}

/* Utilities */
.text-center { text-align: center; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 72px 16px 24px;
  }

  .stats-grid { grid-template-columns: 1fr; }

  .filter-bar {
    flex-direction: column; align-items: stretch;
  }
  .filter-bar .form-group.inline {
    flex-direction: column; align-items: stretch;
  }
  .filter-bar .form-group.inline input,
  .filter-bar .form-group.inline select {
    width: 100%;
  }

  .form-row { grid-template-columns: 1fr; }

  .page-header h1 { font-size: 1.25rem; }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .btn-group { width: 100%; }
  .btn-group .btn { flex: 1; }
}

/* Backdrop for mobile sidebar */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1150;
  display: none;
}
@media (max-width: 768px) {
  .sidebar-backdrop.show { display: block; }
}


/* ============================================
   Guide / Testing Page Styles
   ============================================ */

.guide-flow {
  margin-top: 16px;
}

.flow-step {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  position: relative;
}

.flow-step::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 40px;
  bottom: -20px;
  width: 2px;
  background: var(--border);
}

.flow-step:last-child::before { display: none; }

.flow-num {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  z-index: 1;
}

.flow-body {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  flex: 1;
}

.flow-body strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--text-main);
}

.flow-body p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.test-group {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.test-group:first-of-type {
  border-top: none;
  padding-top: 0;
}

.test-group h4 {
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.success-box {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 0.9rem;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.7;
}

.alert-info code {
  background: rgba(255,255,255,0.7);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}
