:root {
  --bg: #f8f9fa;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --gold: #ff4500;
  --gold-soft: #ff6a00;
  --gold-dark: #cc3700;
  --text: #212529;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --danger: #ff5252;
  --radius: 16px;
  --nav-height: 65px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, .display {
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 800;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
}

input,
textarea,
select {
  font-family: inherit;
  outline: none;
  border: none;
}

::selection {
  background: var(--gold);
  color: #000;
}

img {
  max-width: 100%;
  height: auto;
}

header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  color: var(--gold-soft);
  font-size: 22px;
  line-height: 1.2;
}

.brand small {
  font-family: 'Vazirmatn';
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 300;
}

.desktop-nav {
  display: none;
  gap: 8px;
}

.desktop-nav a {
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 14px;
  color: var(--text-muted);
  transition: 0.2s;
}

.desktop-nav a:hover,
.desktop-nav a.active {
  color: #000;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-container {
  display: none;
  flex: 1;
  max-width: 300px;
  position: relative;
}

.search-container svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
}

.search-container input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px 10px 36px;
  border-radius: 99px;
  font-size: 13px;
}

.search-container input:focus {
  border-color: var(--gold);
}

/* Fix for mobile search box on desktop */
.mobile-search {
  display: none;
  padding: 12px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.mobile-search.active {
  display: block;
}

.mobile-search .search-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  gap: 10px;
}

.mobile-search input {
  flex: 1;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  position: relative;
  transition: 0.2s;
}

.icon-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  height: 20px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  z-index: 45;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 10px;
  width: 33.3%;
  transition: 0.2s;
}

.bottom-nav a svg {
  width: 22px;
  height: 22px;
  transition: 0.2s;
}

.bottom-nav a.active {
  color: var(--gold);
}

#app,
#adminApp {
  padding-bottom: calc(var(--nav-height) + 20px);
}

.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.section-head {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.section-head h2 {
  font-size: 24px;
  color: var(--gold-soft);
  margin: 0;
}

.section-head .sub {
  font-size: 13px;
  color: var(--text-muted);
}

.hero {
  text-align: center;
  padding: 60px 20px 40px;
  position: relative;
  background: radial-gradient(ellipse at top, rgba(212, 175, 55, 0.15) 0%, transparent 70%);
}

.hero-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--gold);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 99px;
  background: var(--surface);
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(38px, 8vw, 72px);
  color: var(--gold-soft);
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero p {
  max-width: 500px;
  margin: 0 auto 30px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.8;
}

.btn {
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: 0.2s;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(255, 69, 0, 0.35);
}

.btn-gold:active {
  transform: scale(0.96);
}

.btn-outline {
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.cat-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}

.cat-scroll::-webkit-scrollbar {
  display: none;
}

.cat-card {
  flex: 0 0 auto;
  width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
  scroll-snap-align: start;
  transition: 0.2s;
  cursor: pointer;
}

.cat-card svg {
  width: 32px;
  height: 32px;
  color: var(--gold-soft);
  margin-bottom: 8px;
}

.cat-card span {
  display: block;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-card.active {
  border-color: var(--gold);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--gold);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: 0.2s;
  cursor: pointer;
}

.product-img {
  background: var(--surface-2);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-cat {
  font-size: 10px;
  color: var(--gold);
  margin-bottom: 4px;
}

.product-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-desc {
  display: none;
}

.product-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.product-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-soft);
}

.product-price span {
  font-size: 9px;
  font-weight: 400;
  color: var(--text-muted);
}

.add-btn-mini {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  z-index: 2;
  position: relative;
}

.add-btn-mini:active {
  background: var(--gold);
  color: #000;
  transform: scale(0.9);
}

.out-of-stock {
  font-size: 11px;
  color: var(--danger);
  font-weight: 500;
  background: rgba(255, 82, 82, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
}

.slider-container {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: 10px;
  margin-bottom: 20px;
  scrollbar-width: none;
}

.slider-container::-webkit-scrollbar {
  display: none;
}

.slider-container img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  scroll-snap-align: center;
  border-radius: var(--radius);
  flex: 0 0 100%;
  background: var(--surface-2);
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }

  #app,
  #adminApp {
    padding-bottom: 40px;
  }

  .desktop-nav {
    display: flex;
  }

  .search-container {
    display: block;
  }

  .mobile-search.active {
    display: none !important;
  }

  .brand {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: 26px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
  }

  .cat-card {
    width: 140px;
    padding: 20px 12px;
  }

  .cat-card span {
    font-size: 14px;
  }

  .product-info {
    padding: 16px;
  }

  .product-title {
    font-size: 15px;
  }

  .product-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.6;
  }

  .add-btn-mini {
    width: auto;
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 12px;
  }

  .add-btn-mini::after {
    content: 'افزودن';
    margin-right: 4px;
  }

  .slider-container img {
    flex: 0 0 400px;
    height: 400px;
    aspect-ratio: auto;
  }
}

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.field {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 13px;
  color: var(--text-muted);
}

.field input,
.field textarea,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  transition: 0.2s;
  width: 100%;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: 13px;
}

th {
  text-align: right;
  color: var(--text-muted);
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: middle;
}

.action-del {
  color: var(--danger);
  background: rgba(255, 82, 82, 0.1);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.td-img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 85vh;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  z-index: 51;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .drawer {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 400px;
    height: 100vh;
    border-radius: 0;
    transform: translateX(-100%);
    border-right: 1px solid var(--border);
  }

  .drawer.open {
    transform: translateX(0);
  }
}

.drawer.open {
  transform: translateY(0);
}

@media (min-width: 768px) {
  .drawer.open {
    transform: translateX(0);
  }
}

.drawer-head {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-head h3 {
  font-size: 18px;
  color: var(--gold-soft);
  margin: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.cart-item {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
  background: var(--bg);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.cart-img {
  width: 60px;
  height: 60px;
  background: var(--surface-2);
  border-radius: 8px;
  object-fit: cover;
}

.cart-info {
  flex: 1;
}

.cart-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.cart-price {
  font-size: 13px;
  color: var(--gold);
}

.cart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  color: var(--text);
}

.drawer-foot {
  padding: 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  margin-bottom: 16px;
}

.total-row b {
  color: var(--gold-soft);
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translate(-50%, -20px);
  background: var(--surface-2);
  border: 1px solid var(--gold);
  color: #000000;
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  text-align: center;
  width: max-content;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

footer {
  text-align: center;
  padding: 30px 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-bottom: var(--nav-height);
}

@media (min-width: 768px) {
  footer {
    margin-bottom: 0;
  }
}