/* ============================================
   HardStore PWA - Complete Stylesheet
   Dark theme, mobile-first, responsive
   ============================================ */

* { margin:0; padding:0; box-sizing:border-box; }

:root {
  --bg: #0f0f1a;
  --card: #16213e;
  --border: #0f3460;
  --primary: #e94560;
  --primary-dark: #c23152;
  --text: #e0e0e0;
  --muted: #a0a0b0;
  --success: #4ecca3;
  --warning: #f0a500;
  --info: #4ea8de;
  --radius: 12px;
  --header-height: 56px;
  --bottom-nav-height: 60px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== HEADER ===== */
.app-header {
  background: #1a1a2e;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.app-header .logo {
  color: var(--primary);
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 1px;
  text-decoration: none;
}
.app-header .back-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  margin-right: 12px;
  cursor: pointer;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.app-header .back-btn:active { background: var(--border); }
.header-title { font-size: 17px; font-weight: 600; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: #1a1a2e;
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.3);
}
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.2s;
}
.bottom-nav .nav-item .nav-icon { font-size: 20px; margin-bottom: 2px; }
.bottom-nav .nav-item.active { color: var(--primary); }
.bottom-nav .nav-item:active { background: rgba(233,69,96,0.1); }

/* ===== SCREENS ===== */
.screen { display: none; padding-bottom: calc(var(--bottom-nav-height) + 16px); }
.screen.active { display: block; }
.screen.splash-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1a1a2e;
}
.screen.splash-screen.active { display: flex; }

.splash-icon { font-size: 80px; margin-bottom: 16px; }
.splash-title { font-size: 36px; font-weight: bold; color: var(--primary); letter-spacing: 2px; }
.splash-sub { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* ===== FORMS ===== */
.form-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 24px 20px;
}
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--primary); }
.form-input::placeholder { color: #555; }

.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.1s;
  color: #fff;
}
.btn:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); color: #000; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-sm { padding: 10px 18px; font-size: 13px; width: auto; display: inline-block; }
.btn-block { margin-top: 12px; }

.link-text {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}
.link-text a { color: var(--primary); text-decoration: none; font-weight: 600; }

.test-credentials {
  margin-top: 20px;
  padding: 14px;
  background: var(--card);
  border: 2px solid var(--warning);
  border-radius: var(--radius);
}
.test-credentials .test-title {
  color: var(--warning);
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 8px;
}
.test-credentials .test-line {
  color: var(--muted);
  font-size: 12px;
  font-family: monospace;
  margin-bottom: 3px;
}

/* ===== HOME / PRODUCTS ===== */
.search-bar {
  display: flex;
  padding: 12px 16px;
  gap: 8px;
}
.search-bar input {
  flex: 1;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search-bar input:focus { border-color: var(--primary); }
.search-bar button {
  background: var(--primary);
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.categories-scroll {
  display: flex;
  overflow-x: auto;
  padding: 0 16px 12px;
  gap: 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.categories-scroll::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0;
  padding: 10px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.section-title {
  font-size: 18px;
  font-weight: bold;
  padding: 8px 16px 12px;
  color: #fff;
}

.products-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
}
.product-card:active { transform: scale(0.97); }
.product-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.product-img-fallback {
  height: 120px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.product-info { padding: 10px; }
.product-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}
.product-cat { font-size: 11px; color: #666; margin-bottom: 4px; }
.product-price { font-size: 16px; font-weight: bold; color: var(--primary); }
.product-stock { font-size: 11px; color: var(--success); margin-top: 4px; }

/* ===== PRODUCT DETAIL ===== */
.detail-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}
.detail-img-fallback {
  width: 100%;
  height: 220px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
}
.detail-body { padding: 20px; }
.detail-cat { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.detail-name { font-size: 22px; font-weight: bold; margin: 6px 0; }
.detail-price { font-size: 28px; font-weight: bold; color: var(--primary); margin-bottom: 12px; }
.detail-stock { font-size: 14px; margin-bottom: 16px; }
.detail-stock.in-stock { color: var(--success); }
.detail-stock.out-stock { color: var(--primary); }
.detail-desc { color: var(--muted); font-size: 14px; line-height: 1.6; }
.qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
}
.qty-btn {
  width: 40px; height: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-val { font-size: 18px; font-weight: bold; }
.add-cart-btn { width: 100%; }
.add-cart-btn:disabled { background: #555; cursor: not-allowed; }

/* ===== CART ===== */
.cart-empty {
  text-align: center;
  padding: 60px 20px;
}
.cart-empty .empty-icon { font-size: 64px; margin-bottom: 16px; }
.cart-empty .empty-text { font-size: 18px; color: var(--muted); margin-bottom: 20px; }

.cart-list { padding: 16px; }
.cart-item {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  gap: 12px;
}
.cart-item-img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
}
.cart-item-img-fallback {
  width: 64px; height: 64px;
  background: var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.cart-item-price { font-size: 14px; font-weight: bold; color: var(--primary); margin-bottom: 8px; }
.cart-item-actions { display: flex; align-items: center; gap: 12px; }
.cart-qty { display: flex; align-items: center; background: var(--border); border-radius: 8px; overflow: hidden; }
.cart-qty button {
  padding: 6px 12px;
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.cart-qty span { padding: 0 10px; font-size: 13px; font-weight: bold; }
.cart-remove { background: none; border: none; font-size: 18px; cursor: pointer; }

.cart-summary {
  background: var(--card);
  padding: 20px;
  border-top: 1px solid var(--border);
  margin: 0 16px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.summary-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.summary-row .label { color: var(--muted); }
.summary-divider { border-top: 1px solid var(--border); margin: 10px 0; }
.summary-total { font-size: 18px; font-weight: bold; }
.summary-total .val { color: var(--primary); font-size: 20px; }

/* ===== CHECKOUT ===== */
.checkout-form { padding: 16px; }
.checkout-form textarea {
  resize: vertical;
  min-height: 80px;
}
.order-summary {
  background: var(--card);
  margin: 16px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ===== PAYMENT ===== */
.amount-banner {
  background: var(--card);
  margin: 16px;
  padding: 24px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}
.amount-label { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.amount-value { font-size: 36px; font-weight: bold; color: var(--primary); }

.payment-form { padding: 0 16px; }
.status-banner {
  margin: 0 16px 12px;
  padding: 12px;
  border-radius: 10px;
  text-align: center;
  font-weight: bold;
  font-size: 15px;
}
.status-banner.success { background: #1a3a2a; color: var(--success); border: 1px solid var(--success); }
.status-banner.failed { background: #3a1a1a; color: var(--primary); border: 1px solid var(--primary); }

.test-pay-card {
  background: var(--card);
  margin: 16px;
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid var(--warning);
}
.test-pay-card .pay-title { color: var(--warning); font-size: 14px; font-weight: bold; margin-bottom: 8px; }
.test-pay-card .pay-desc { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.test-pay-card .pay-row { display: flex; margin-bottom: 4px; font-size: 13px; }
.test-pay-card .pay-label { color: #888; width: 45px; font-weight: 600; }
.test-pay-card .pay-val { color: var(--warning); font-family: monospace; font-weight: bold; }

/* ===== SUCCESS ===== */
.success-container {
  text-align: center;
  padding: 40px 20px;
}
.success-icon { font-size: 64px; margin-bottom: 16px; }
.success-title { font-size: 24px; font-weight: bold; color: var(--success); margin-bottom: 4px; }
.success-sub { color: var(--muted); margin-bottom: 24px; }
.success-details {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 360px;
  margin: 0 auto 20px;
  border: 1px solid var(--border);
  text-align: left;
}
.success-row { display: flex; justify-content: space-between; padding: 10px 0; font-size: 14px; }
.success-row .label { color: var(--muted); }
.success-row .val { font-weight: bold; }
.success-row .val.status-ok { color: var(--success); }
.success-divider { border-top: 1px solid var(--border); }

/* ===== ORDERS ===== */
.order-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 16px 10px;
}
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-num { font-size: 15px; font-weight: bold; }
.order-status {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}
.order-status.Paid { background: #1a3a2a; color: var(--success); }
.order-status.Pending { background: #3a2a1a; color: var(--warning); }
.order-status.Shipped { background: #1a2a3a; color: var(--info); }
.order-status.Delivered { background: #1a3a2a; color: var(--success); }
.order-status.Cancelled { background: #3a1a1a; color: var(--primary); }
.order-date { color: #666; font-size: 12px; margin-bottom: 6px; }
.order-items { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.order-amount { text-align: right; font-size: 18px; font-weight: bold; color: var(--primary); }

/* ===== PROFILE ===== */
.profile-header {
  background: var(--card);
  padding: 30px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  font-weight: bold;
  margin: 0 auto 12px;
}
.profile-name { font-size: 22px; font-weight: bold; }
.profile-email { color: var(--muted); font-size: 14px; margin-top: 4px; }

.profile-links {
  background: var(--card);
  margin: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.profile-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
}
.profile-link:active { background: rgba(255,255,255,0.03); }
.profile-link .arrow { color: #666; font-size: 20px; }
.profile-divider { border-top: 1px solid var(--border); }
.logout-btn {
  margin: 16px;
  padding: 15px;
  background: #3a1a1a;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 16px;
  font-weight: bold;
  width: calc(100% - 32px);
  cursor: pointer;
  text-align: center;
}

/* ===== MANUAL ===== */
.manual-card {
  background: var(--card);
  margin: 12px 16px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.manual-card.highlight { border-color: var(--warning); border-width: 2px; }
.manual-card h3 { font-size: 16px; margin-bottom: 10px; }
.code-block {
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.code-block .code-line { color: #888; font-size: 12px; margin-bottom: 3px; }
.code-block .code-val { color: var(--warning); font-family: monospace; font-weight: bold; font-size: 14px; }
.step { display: flex; gap: 12px; margin-bottom: 14px; }
.step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  flex-shrink: 0;
  margin-top: 2px;
}
.step-body { flex: 1; }
.step-body strong { font-size: 14px; display: block; margin-bottom: 3px; }
.step-body p { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  z-index: 1000;
  animation: slideDown 0.3s ease;
  max-width: 90%;
  text-align: center;
}
.toast.success { background: #1a3a2a; color: var(--success); border: 1px solid var(--success); }
.toast.error { background: #3a1a1a; color: var(--primary); border: 1px solid var(--primary); }

@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (min-width: 600px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
  .form-container { max-width: 440px; }
}
@media (min-width: 900px) {
  .products-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== ADMIN MODAL ===== */
.admin-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  padding-top: 40px;
  overflow-y: auto;
}
.admin-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  animation: slideDown 0.25s ease;
}
.admin-modal-content table td, .admin-modal-content table th {
  border-bottom: 1px solid var(--border);
}
