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

:root {
  --primary: #7C3AED;
  --primary-dark: #6d28d9;
  --accent: #7C3AED;
  --dark: #111111;
  --gray: #6b7280;
  --light-gray: #e5e5e5;
  --bg: #ffffff;
  --bg-subtle: #f9fafb;
  --white: #ffffff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --max-width: 1180px;

  /* Spacing scale */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;

  /* Font size scale */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 2.5rem;
  --font-size-4xl: 3rem;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--dark);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* Navbar */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--light-gray);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.navbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark);
}

.navbar .brand:hover {
  text-decoration: none;
}

.navbar .brand img {
  width: 32px;
  height: 32px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links a {
  color: var(--dark);
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--primary);
  text-decoration: none;
}

.cart-toggle {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--dark);
  padding: 4px;
}

.cart-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--accent);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  background: var(--primary);
  color: var(--white);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

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

.btn-secondary:hover {
  background: var(--bg-subtle);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  padding: 80px 0;
  text-align: center;
}

.hero h1 {
  font-size: 2.75rem;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.15rem;
  max-width: 640px;
  margin: 0 auto 32px;
  opacity: 0.92;
}

.hero .actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.hero .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Sections */
.section {
  padding: 56px 0;
}

.section h2 {
  font-size: 1.75rem;
  margin-bottom: 24px;
  text-align: center;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

.feature-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.feature-card .icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.feature-card h3 {
  margin-bottom: 8px;
}

.feature-card p {
  color: var(--gray);
  font-size: 0.95rem;
}

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

.product-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.product-card .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--light-gray);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.product-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card .body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.product-card h3 {
  font-size: 1rem;
}

.product-card .price {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 1.05rem;
}

.product-card .category {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
}

.product-card .actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
}

/* Filters */
.filters {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  padding: 8px 12px;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--white);
}

/* Product detail */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

@media (max-width: 768px) {
  .product-detail {
    grid-template-columns: 1fr;
  }

  .product-detail-image {
    max-width: 480px;
  }
}

.product-detail-image {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.product-detail-info h1 {
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.product-detail-info .price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 16px;
}

.product-detail-info .description {
  color: var(--gray);
  margin-bottom: 24px;
}

.qty-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.qty-selector button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--light-gray);
  background: var(--white);
  font-size: 1.1rem;
  cursor: pointer;
}

.qty-selector input {
  width: 56px;
  text-align: center;
  padding: 8px;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
}

/* Forms */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  max-width: 640px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--light-gray);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.helper-text {
  color: var(--gray);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
}

.alert-info {
  background: #e0e7ff;
  color: #3730a3;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-pending { background: #fef3c7; color: var(--warning); }
.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-shipped { background: #ede9fe; color: var(--primary-dark); }
.badge-completed,
.badge-delivered { background: #dcfce7; color: var(--success); }
.badge-cancelled,
.badge-new { background: #f3f4f6; color: var(--gray); }
.badge-reviewed { background: #dbeafe; color: #1d4ed8; }
.badge-quoted { background: #ede9fe; color: var(--primary-dark); }

/* Cart drawer */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: none;
}

.cart-overlay.open {
  display: block;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 400px;
  height: 100%;
  background: var(--white);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--light-gray);
}

.cart-header h2 {
  font-size: 1.1rem;
}

.cart-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--light-gray);
}

.cart-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--light-gray);
}

.cart-item .info {
  flex: 1;
}

.cart-item .info h4 {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.cart-item .info .price {
  color: var(--gray);
  font-size: 0.85rem;
}

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

.cart-item .qty-controls button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--light-gray);
  background: var(--white);
  border-radius: 4px;
  cursor: pointer;
}

.cart-item .remove {
  color: var(--danger);
  font-size: 0.8rem;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  margin-top: 6px;
}

.cart-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--light-gray);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.cart-empty {
  text-align: center;
  color: var(--gray);
  padding: 40px 0;
}

/* Footer */
footer {
  background: var(--dark);
  color: #d1d5db;
  padding: 32px 0;
  margin-top: 64px;
  text-align: center;
  font-size: 0.9rem;
}

footer a {
  color: #d1d5db;
}

/* Tables (admin/track) */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--light-gray);
  font-size: 0.9rem;
}

th {
  background: var(--bg-subtle);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--gray);
}

tr:last-child td {
  border-bottom: none;
}

.table-wrapper {
  overflow-x: auto;
  margin-bottom: 32px;
}

/* Admin */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--light-gray);
}

.admin-tab {
  padding: 10px 18px;
  cursor: pointer;
  border: none;
  background: none;
  font-weight: 600;
  color: var(--gray);
  border-bottom: 2px solid transparent;
}

.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.text-center {
  text-align: center;
}

.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }

.empty-state {
  text-align: center;
  color: var(--gray);
  padding: 48px 0;
}

.spinner-text {
  text-align: center;
  color: var(--gray);
  padding: 24px 0;
}

/* Store (Phase 2) */
.store-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.store-header h2 {
  margin-bottom: 0;
  text-align: left;
}

.product-count {
  color: var(--gray);
  font-size: 0.95rem;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 80px;
}

.filter-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--light-gray);
  background: var(--white);
  color: var(--dark);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* Product badges */
.badge-material {
  background: #ede9fe;
  color: var(--primary-dark);
  align-self: flex-start;
}

.badge-stock {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--danger);
  color: var(--white);
  z-index: 1;
}

/* Quick view modal */
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--gray);
  padding: 4px;
}

.modal-close:hover {
  color: var(--dark);
}

.modal-lg {
  max-width: 760px;
}

.quickview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 640px) {
  .quickview {
    grid-template-columns: 1fr;
  }
}

.quickview-image {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--light-gray);
  aspect-ratio: 1 / 1;
}

.quickview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quickview-info h3 {
  font-size: 1.35rem;
  margin: 8px 0;
}

.quickview-info .price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 12px 0;
}

.quickview-info .description {
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.view-full-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.9rem;
  color: var(--gray);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--gray);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb .sep {
  margin: 0 6px;
}

.breadcrumb .current {
  color: var(--dark);
  font-weight: 600;
}

/* Checkout (Phase 3) */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 768px) {
  .checkout-layout {
    grid-template-columns: 1fr;
  }
}

.checkout-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}

.order-summary h3 {
  margin-bottom: 16px;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--light-gray);
}

.summary-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--light-gray);
  flex-shrink: 0;
}

.summary-item .info {
  flex: 1;
}

.summary-item .info h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.summary-item .info .meta {
  color: var(--gray);
  font-size: 0.85rem;
}

.summary-item .line-total {
  font-weight: 700;
  white-space: nowrap;
}

.summary-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.1rem;
  padding-top: 16px;
  margin-top: 8px;
}

.payment-box {
  background: var(--bg-subtle);
}

.payment-box h3 {
  margin-bottom: 8px;
}

.payment-box p {
  color: var(--gray);
  font-size: 0.9rem;
}

/* Product image gallery */
.gallery-main {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--light-gray);
}

.gallery-main img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.gallery-thumbs img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.8;
}

.gallery-thumbs img:hover {
  opacity: 1;
}

.gallery-thumbs img.active {
  border-color: var(--primary);
  opacity: 1;
}
