/* =====================================================
   ToolVault - Premium Marketplace Design System
   ===================================================== */

:root {
  --primary: #15803d;
  --primary-dark: #14532d;
  --secondary: #22c55e;
  --radius: 14px;
  --bg: #f5faf6;
  --surface: #ffffff;
  --surface-alt: #eef7f0;
  --text: #14231a;
  --text-muted: #5b6b60;
  --border: #dfe9e2;
  --shadow-sm: 0 2px 8px rgba(20, 40, 25, 0.06);
  --shadow-md: 0 10px 30px rgba(20, 40, 25, 0.08);
  --shadow-lg: 0 20px 50px rgba(20, 40, 25, 0.12);
  --gradient: linear-gradient(135deg, var(--primary), var(--secondary));
  --transition: all 0.25s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg: #0d1410;
  --surface: #131c15;
  --surface-alt: #182219;
  --text: #eef5ef;
  --text-muted: #93a89a;
  --border: #243026;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius); border: none; cursor: pointer;
  font-weight: 600; font-size: 15px; transition: var(--transition);
  position: relative; overflow: hidden;
}
.btn-primary { background: var(--gradient); background-size: 200% auto; color: #fff; box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--primary) 70%, transparent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -10px color-mix(in srgb, var(--primary) 80%, transparent); background-position: right center; }
.btn-primary::before {
  content: ''; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  transform: translateX(-100%); transition: transform 0.6s ease;
}
.btn-primary:hover::before { transform: translateX(100%); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { background: #ef4444; color: #fff; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { font-weight: 800; font-size: 22px; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-links { display: flex; gap: 28px; list-style: none; margin: 0; padding: 0; }
.nav-links a { font-weight: 500; color: var(--text-muted); transition: var(--transition); position: relative; padding-bottom: 4px; }
.nav-links a::after {
  content: ''; position: absolute; left: 0; bottom: -2px; width: 0; height: 2px;
  background: var(--gradient); border-radius: 2px; transition: width 0.25s ease;
}
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }
.nav-actions { display: flex; align-items: center; gap: 14px; }
.theme-toggle {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-alt); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition);
}
.theme-toggle:hover { border-color: var(--primary); }
.cart-badge {
  position: relative;
}
.cart-badge .count {
  position: absolute; top: -6px; right: -8px; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center;
}
.mobile-toggle { display: none; background: none; border: none; font-size: 24px; color: var(--text); cursor: pointer; }
.mobile-menu {
  display: none; flex-direction: column; gap: 4px; background: var(--surface);
  border-top: 1px solid var(--border); padding: 16px 20px;
}
.mobile-menu a { padding: 12px 6px; border-radius: 10px; font-weight: 500; }
.mobile-menu a:hover { background: var(--surface-alt); }
.mobile-menu.open { display: flex; }

@media (max-width: 900px) {
  .nav-links { display: none; }
  .mobile-toggle { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 100px 0 90px; text-align: center; position: relative; overflow: hidden;
}
.hero-blob {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.35; z-index: 0;
  animation: blobFloat 14s ease-in-out infinite;
}
.hero-blob.b1 { width: 420px; height: 420px; background: var(--primary); top: -160px; left: -100px; }
.hero-blob.b2 { width: 360px; height: 360px; background: var(--secondary); top: 40px; right: -120px; animation-delay: -5s; }
.hero-blob.b3 { width: 260px; height: 260px; background: var(--primary); bottom: -140px; left: 40%; animation-delay: -9s; opacity: 0.25; }
@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.08); }
  66% { transform: translate(-20px, 25px) scale(0.95); }
}
.hero .container { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(32px, 5vw, 56px); font-weight: 800; margin: 0 0 18px; line-height: 1.15; letter-spacing: -0.02em; }
.hero p { font-size: 18px; color: var(--text-muted); max-width: 620px; margin: 0 auto 32px; }
.hero-search {
  max-width: 560px; margin: 0 auto; display: flex; gap: 10px; background: var(--surface);
  padding: 8px; border-radius: 999px; box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.hero-search input { flex: 1; border: none; background: transparent; padding: 12px 16px; font-size: 15px; color: var(--text); outline: none; }
.hero-search button { border-radius: 999px; }

/* Decorative hero illustration (pure SVG/CSS, no external images needed) */
.hero-visual { position: relative; max-width: 640px; margin: 56px auto 0; z-index: 1; }
.hero-visual svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 30px 60px rgba(17,24,39,0.18)); }
.hero-float-card {
  position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; animation: cardFloat 5s ease-in-out infinite;
}
.hero-float-card i { color: var(--primary); font-size: 16px; }
.hero-float-card.c1 { top: 6%; left: -4%; animation-delay: 0s; }
.hero-float-card.c2 { bottom: 12%; right: -6%; animation-delay: -2s; }
.hero-float-card.c3 { top: 46%; right: -2%; animation-delay: -3.5s; }
@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}
@media (max-width: 700px) { .hero-float-card { display: none; } }

/* ---------- Cards / Grid ---------- */
.section { padding: 60px 0; }
.section-title { font-size: 28px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.02em; }
.section-subtitle { color: var(--text-muted); margin-bottom: 32px; }
.grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-cats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: transform 0.35s cubic-bezier(.22,1,.36,1), box-shadow 0.35s ease, border-color 0.35s ease;
  box-shadow: var(--shadow-sm); position: relative;
}
.card::after {
  content: ''; position: absolute; inset: 0; border-radius: var(--radius); padding: 1px;
  background: var(--gradient); opacity: 0; transition: opacity 0.35s ease;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
.card:hover { transform: translateY(-8px); box-shadow: 0 24px 60px -16px color-mix(in srgb, var(--primary) 35%, rgba(17,24,39,0.15)); border-color: transparent; }
.card:hover::after { opacity: 1; }
.card-img { aspect-ratio: 4/3; overflow: hidden; background: var(--surface-alt); }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s cubic-bezier(.22,1,.36,1); }
.card:hover .card-img img { transform: scale(1.08); }
.card-body { padding: 18px; }
.card-cat { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); font-weight: 700; }
.card-title { font-size: 17px; font-weight: 700; margin: 6px 0; line-height: 1.3; }
.card-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; }
.price { font-weight: 800; font-size: 18px; }
.old-price { text-decoration: line-through; color: var(--text-muted); font-size: 13px; margin-left: 6px; font-weight: 400; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-featured { background: rgba(109,94,252,0.12); color: var(--primary); }
.badge-status-pending { background: rgba(234,179,8,0.15); color: #b45309; }
.badge-status-confirmed { background: rgba(59,130,246,0.15); color: #1d4ed8; }
.badge-status-delivered { background: rgba(34,197,94,0.15); color: #15803d; }
.badge-status-rejected, .badge-status-cancelled { background: rgba(239,68,68,0.15); color: #b91c1c; }

.category-card { text-align: center; padding: 26px 16px; }
.category-card .icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--gradient); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; }

/* ---------- Forms ---------- */
.form-card { max-width: 460px; margin: 60px auto; background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); padding: 40px 36px; box-shadow: var(--shadow-lg); }
.form-card h2 { margin-top: 0; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface-alt); color: var(--text); font-size: 14px; transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
textarea.form-control { resize: vertical; min-height: 100px; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: rgba(34,197,94,0.12); color: #15803d; }
.alert-error { background: rgba(239,68,68,0.12); color: #b91c1c; }
.alert-info { background: rgba(59,130,246,0.12); color: #1d4ed8; }

/* ---------- Tables (admin + orders) ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 12px; letter-spacing: 0.06em; background: var(--surface-alt); }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--surface-alt); }
tr:last-child td { border-bottom: none; }

/* ---------- Footer ---------- */
footer { background: var(--surface); border-top: 1px solid var(--border); padding: 50px 0 24px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 30px; }
.footer-grid h4 { font-size: 15px; margin-bottom: 14px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--text-muted); }
.footer-grid a:hover { color: var(--primary); }
.footer-bottom { text-align: center; color: var(--text-muted); font-size: 13px; padding-top: 20px; border-top: 1px solid var(--border); }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Mobile: stack any two/three-column layout ---------- */
/* Many pages (admin forms, checkout, product page, etc.) use inline
   `style="display:grid;grid-template-columns:..."` for desktop side-by-side
   layouts. On small screens these must stack to a single column or content
   gets cut off / requires horizontal scrolling. This rule catches every
   such element generically (via attribute selector) so each page doesn't
   need a separate responsive rule. */
@media (max-width: 860px) {
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
}

/* ---------- Scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- Dashboard stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: ''; position: absolute; top: -30%; right: -20%; width: 120px; height: 120px; border-radius: 50%;
  background: var(--gradient); opacity: 0.12; filter: blur(10px);
}
.stat-card .icon-badge {
  width: 42px; height: 42px; border-radius: 12px; background: var(--gradient); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 17px; margin-bottom: 14px;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--primary) 70%, transparent);
}
.stat-card .value { font-size: 28px; font-weight: 800; position: relative; z-index: 1; }
.stat-card .label { color: var(--text-muted); font-size: 13px; margin-top: 4px; position: relative; z-index: 1; }

/* ---------- Admin layout ---------- */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 250px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 24px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0;
}
.admin-sidebar .brand { display: block; margin-bottom: 30px; padding-left: 8px; font-size: 20px; }
.admin-sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px;
  color: var(--text-muted); font-weight: 600; font-size: 14px; margin-bottom: 2px; transition: var(--transition);
}
.admin-sidebar nav a i { width: 18px; text-align: center; }
.admin-sidebar nav a:hover { background: var(--surface-alt); color: var(--primary); }
.admin-sidebar nav a.active { background: var(--gradient); color: #fff; box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--primary) 60%, transparent); }
.admin-content { flex: 1; padding: 28px; max-width: 100%; overflow-x: hidden; background: var(--bg); }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.admin-mobile-toggle { display: none; }

@media (max-width: 900px) {
  .admin-sidebar { position: fixed; left: -260px; z-index: 200; transition: left 0.25s ease; box-shadow: var(--shadow-lg); }
  .admin-sidebar.open { left: 0; }
  .admin-mobile-toggle { display: inline-flex; }
}

/* ---------- Cart / Checkout ---------- */
.cart-row { display: flex; gap: 16px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.cart-row img { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; }
.cart-row .info { flex: 1; }
.qty-control { display: flex; align-items: center; gap: 8px; }
.qty-control button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-alt); cursor: pointer; }
.summary-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: sticky; top: 90px; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.summary-row.total { font-size: 18px; font-weight: 800; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }

/* ---------- AI Support Widget ---------- */
.ai-fab {
  position: fixed; bottom: 24px; z-index: 500; width: 58px; height: 58px; border-radius: 50%;
  background: var(--gradient); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 24px; box-shadow: var(--shadow-lg); cursor: pointer; border: none; transition: var(--transition);
}
.ai-fab:hover { transform: scale(1.08); }
.ai-fab.pos-left { left: 24px; }
.ai-fab.pos-right { right: 24px; }
.ai-panel {
  position: fixed; bottom: 96px; z-index: 500; width: 340px; max-width: 90vw; height: 460px; max-height: 70vh;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; overflow: hidden;
}
.ai-panel.pos-left { left: 24px; }
.ai-panel.pos-right { right: 24px; }
.ai-panel.open { display: flex; }
.ai-panel-header { background: var(--gradient); color: #fff; padding: 16px; font-weight: 700; }
.ai-panel-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { padding: 10px 14px; border-radius: 14px; font-size: 14px; max-width: 85%; }
.ai-msg.bot { background: var(--surface-alt); align-self: flex-start; }
.ai-msg.user { background: var(--primary); color: #fff; align-self: flex-end; }
.ai-panel-footer { display: flex; border-top: 1px solid var(--border); }
.ai-panel-footer input { flex: 1; border: none; padding: 14px; background: transparent; color: var(--text); outline: none; }
.ai-panel-footer button { border: none; background: var(--primary); color: #fff; padding: 0 18px; cursor: pointer; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.error-page { text-align: center; padding: 120px 20px; }
.error-page h1 { font-size: 96px; margin: 0; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.skeleton { background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 50%, var(--surface-alt) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
