/* ============================================
   Metal Store — Premium Mini App Design System
   ============================================ */

:root {
  --bg-deep: #0b0b0d;
  --bg-surface: #141416;
  --bg-elevated: #1c1c20;
  --text-primary: #f0f0f5;
  --text-secondary: #8b8b96;
  --accent: #3b9eff;
  --accent-glow: rgba(59, 158, 255, 0.25);
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --danger: #ff4d4f;
  --success: #2ecc71;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition: all 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

[data-theme="light"] {
  --bg-deep: #f4f4f7;
  --bg-surface: #ffffff;
  --bg-elevated: #f0f0f3;
  --text-primary: #1a1a1e;
  --text-secondary: #6e6e7a;
  --border: rgba(0,0,0,0.06);
  --border-strong: rgba(0,0,0,0.1);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.1);
  --accent-glow: rgba(59, 158, 255, 0.15);
}

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

html, body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ============================================
   Header
   ============================================ */
.app-header {
  position: sticky;
  top: 12px;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  margin-bottom: 28px;
  background: rgba(20, 20, 22, 0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.75);
}

.logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 18px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.icon-btn:active {
  transform: scale(0.92);
}

.badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(59,158,255,0.4);
  border: 2px solid var(--bg-surface);
}

/* ============================================
   Catalog
   ============================================ */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 480px) {
  .catalog-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

.product-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.product-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 50%);
  pointer-events: none;
}

.product-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.product-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 12px;
  position: relative;
}

.product-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--bg-surface) 0%, transparent 40%);
  pointer-events: none;
}

.product-info {
  padding: 12px 14px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.product-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-top: auto;
  padding-top: 6px;
}

.product-add-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.product-add-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

.product-add-btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

/* Card Counter */
.card-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  gap: 12px;
}

.card-counter button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.card-counter button:active {
  transform: scale(0.9);
  background: var(--accent);
  border-color: var(--accent);
}

.card-counter span {
  font-weight: 700;
  font-size: 15px;
  min-width: 24px;
  text-align: center;
}

/* ============================================
   Overlays & Sheets
   ============================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  animation: fadeIn 0.25s ease forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.sheet {
  background: var(--bg-surface);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 28px 28px 0 0;
  padding: 28px 20px;
  border-top: 1px solid var(--border-strong);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  animation: slideUp 0.35s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet h2 {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ============================================
   Cart
   ============================================ */
.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.cart-item-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-item-controls button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.cart-item-controls button:active {
  transform: scale(0.9);
  background: var(--accent);
  border-color: var(--accent);
}

.cart-item-price {
  font-weight: 700;
  min-width: 80px;
  text-align: right;
  font-size: 14px;
  color: var(--accent);
}

.cart-footer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-strong);
}

.total {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-textarea {
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 2px 4px rgba(0,0,0,0.2);
}

.form-textarea { min-height: 80px; resize: vertical; }

.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), transparent);
  pointer-events: none;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.2);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #c0392b);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

/* ============================================
   Admin Panel
   ============================================ */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.admin-tab { display: none; }
.admin-tab.active { display: block; }

.admin-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.admin-item:active {
  transform: scale(0.99);
}

.admin-item-info { flex: 1; }
.admin-item-name { font-weight: 700; font-size: 15px; }
.admin-item-meta { font-size: 13px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

.admin-actions { display: flex; gap: 8px; }
.admin-actions button {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.admin-actions button:active {
  transform: scale(0.95);
}

.order-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  transition: var(--transition);
}

.order-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 15px;
}

.order-meta {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-weight: 500;
}

/* ============================================
   Animations
   ============================================ */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================
   Empty State
   ============================================ */
.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-weight: 500;
}
