/*
Theme Name: Shabakieh Store
Theme URI: https://shabakieh.ir
Author: Hamed
Description: فروشگاه مودم و تجهیزات شبکه — فارسی و راست‌چین، با WooCommerce
Version: 1.0.0
Requires at least: 6.2
Tested up to: 6.7
Requires PHP: 8.0
WooCommerce: true
Text Domain: shabakieh
Tags: rtl-language, persian, woocommerce, shop, e-commerce
*/

/* ══════════════════════════════════════════
   TOKENS
══════════════════════════════════════════ */
:root {
  --primary   : #007C91;
  --primary-dk: #005f70;
  --secondary : #40C1C7;
  --sec-lt    : #b3ecef;
  --light-bg  : #f0fbfc;
  --surface   : #ffffff;
  --text      : #1a2b30;
  --muted     : #607d82;
  --border    : #d4eef1;
  --radius    : 12px;
  --shadow    : 0 4px 24px rgba(0,124,145,.11);
  --font      : 'Vazirmatn', 'Tahoma', sans-serif;
  --transition: .22s ease;
}

/* ══════════════════════════════════════════
   RESET
══════════════════════════════════════════ */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { direction: rtl; font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: #f4f8f9;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dk); }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); direction: rtl; }

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
.site-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 2px 16px rgba(0,124,145,.07);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  height: 70px;
  display: flex;
  align-items: center;
  gap: 20px;
}

/* لوگو */
.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}
.site-logo img { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; }
.site-title   { font-size: 1.15rem; font-weight: 900; color: var(--primary); line-height: 1.2; }
.site-tagline { font-size: .7rem; color: var(--muted); margin-top: 1px; }

/* جستجو */
.header-search { flex: 1; max-width: 480px; margin: 0 auto; position: relative; }
.header-search input {
  width: 100%;
  padding: 9px 42px 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: .88rem;
  color: var(--text);
  background: var(--light-bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(64,193,199,.15);
}
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* سبد */
.header-cart {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--primary);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background var(--transition);
  white-space: nowrap;
}
.header-cart:hover { background: var(--primary-dk); }
.cart-count {
  background: var(--secondary);
  color: #fff;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; flex-shrink: 0;
}

/* ══════════════════════════════════════════
   HERO
══════════════════════════════════════════ */
.site-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: 52px 24px;
  text-align: center;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.site-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='52' height='52' viewBox='0 0 52 52' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.06' fill-rule='evenodd'%3E%3Cpath d='M0 52L52 0H26L0 26zM52 52V26L26 52z'/%3E%3C/g%3E%3C/svg%3E");
}
.hero-inner { position: relative; z-index: 1; max-width: 680px; margin: 0 auto; }
.hero-title {
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 900;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.hero-sub { font-size: .95rem; opacity: .9; line-height: 1.7; }

/* ══════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════ */
.store-wrapper {
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 24px 80px;
  flex: 1;
}

/* ══════════════════════════════════════════
   SECTION TITLE
══════════════════════════════════════════ */
.section-title {
  font-size: 1rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(to left, transparent, var(--border));
  border-radius: 2px;
}

/* ══════════════════════════════════════════
   CATEGORIES
══════════════════════════════════════════ */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin-bottom: 36px;
}

.cat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  user-select: none;
  outline: none;
}
.cat-card:hover {
  border-color: var(--secondary);
  background: var(--light-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.cat-card.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #e8f8fa, #d0f2f4);
  box-shadow: 0 4px 16px rgba(0,124,145,.14);
}
.cat-card:focus-visible { box-shadow: 0 0 0 3px rgba(64,193,199,.4); }

.cat-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
  flex-shrink: 0;
}
.cat-name  { font-size: .78rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.cat-count { font-size: .68rem; color: var(--muted); }

/* ══════════════════════════════════════════
   PRODUCTS HEADER
══════════════════════════════════════════ */
.products-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.products-count { font-size: .82rem; color: var(--muted); }

/* ══════════════════════════════════════════
   PRODUCTS GRID
══════════════════════════════════════════ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
}

/* ══════════════════════════════════════════
   PRODUCT CARD
══════════════════════════════════════════ */
.product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column;
  outline: none;
}
.product-card:hover {
  border-color: var(--secondary);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.product-card:focus-visible { box-shadow: 0 0 0 3px rgba(64,193,199,.4); }

.product-img-wrap {
  aspect-ratio: 4/3;
  background: var(--light-bg);
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.product-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}
.product-card:hover .product-img-wrap img { transform: scale(1.05); }

.product-badge {
  position: absolute; top: 9px; right: 9px;
  background: var(--secondary);
  color: #fff;
  font-size: .66rem; font-weight: 900;
  padding: 3px 9px;
  border-radius: 100px;
}
.product-badge.sale { background: #e05c5c; }

.product-info  { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.product-cat-label { font-size: .68rem; color: var(--secondary); font-weight: 800; letter-spacing: .02em; }
.product-name  { font-size: .9rem; font-weight: 800; color: var(--text); line-height: 1.4; }
.product-short-desc { font-size: .78rem; color: var(--muted); line-height: 1.55; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.product-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--light-bg);
}
.product-price { font-size: .9rem; font-weight: 900; color: var(--primary); }
.product-price .price-unit { font-size: .68rem; color: var(--muted); font-weight: 500; }
.product-price .old-price  { font-size: .72rem; color: var(--muted); text-decoration: line-through; margin-right: 5px; }

.btn-details {
  background: var(--primary); color: #fff;
  border: none; border-radius: 100px;
  padding: 6px 14px;
  font-size: .75rem; font-weight: 700;
  transition: background var(--transition);
  flex-shrink: 0;
}
.btn-details:hover { background: var(--primary-dk); }

/* ══════════════════════════════════════════
   SPINNER (loading)
══════════════════════════════════════════ */
.sk-spinner {
  width: 44px; height: 44px; margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: sk-spin .75s linear infinite;
}
@keyframes sk-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--muted); grid-column: 1 / -1;
}
.empty-state svg { margin: 0 auto 14px; opacity: .35; }
.empty-state p  { font-size: .9rem; }

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.52);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal-box {
  background: var(--surface);
  border-radius: 20px;
  width: 100%; max-width: 680px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 28px 80px rgba(0,0,0,.26);
  transform: translateY(24px) scale(.97);
  transition: transform .28s cubic-bezier(.34,1.56,.64,1);
  position: relative;
  overscroll-behavior: contain;
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }

.modal-close {
  position: sticky; top: 12px; float: left; margin: 12px;
  width: 34px; height: 34px;
  border: none; background: rgba(255,255,255,.9);
  border-radius: 50%; font-size: 1rem; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); z-index: 1;
  backdrop-filter: blur(4px);
}
.modal-close:hover { background: #fff; color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.12); }

.modal-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 20px 20px 0 0;
  display: block;
}

.modal-content { padding: 24px 28px 28px; }
.modal-category { font-size: .75rem; color: var(--secondary); font-weight: 800; margin-bottom: 5px; letter-spacing: .02em; }
.modal-title    { font-size: 1.3rem; font-weight: 900; color: var(--text); margin-bottom: 10px; line-height: 1.4; }
.modal-desc     { font-size: .88rem; color: var(--muted); line-height: 1.8; margin-bottom: 20px; white-space: pre-line; }

/* جدول مشخصات */
.modal-specs {
  background: var(--light-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; margin-bottom: 22px;
}
.specs-title { font-size: .82rem; font-weight: 800; color: var(--primary); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.specs-table { width: 100%; border-collapse: collapse; }
.specs-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.specs-table td { padding: 9px 14px; font-size: .82rem; }
.specs-table td:first-child { color: var(--muted); width: 38%; font-weight: 600; }
.specs-table td:last-child  { color: var(--text); font-weight: 700; }

/* footer مودال */
.modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.modal-price { font-size: 1.45rem; font-weight: 900; color: var(--primary); }
.modal-price-unit { font-size: .78rem; color: var(--muted); }
.modal-old-price  { font-size: .82rem; color: var(--muted); text-decoration: line-through; margin-top: 2px; }

.btn-add-cart {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; border: none; border-radius: 100px;
  padding: 13px 26px;
  font-size: .95rem; font-weight: 800;
  display: flex; align-items: center; gap: 8px;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-add-cart:hover  { opacity: .92; transform: scale(1.02); }
.btn-add-cart:active { transform: scale(.98); }
.btn-add-cart:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ══════════════════════════════════════════
   TOAST NOTICE
══════════════════════════════════════════ */
.sh-notice {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--primary); color: #fff;
  padding: 12px 24px; border-radius: 100px;
  font-size: .88rem; font-weight: 700;
  z-index: 99999; opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.sh-notice--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sh-notice--error { background: #e05c5c; }

/* ══════════════════════════════════════════
   FOOTER
══════════════════════════════════════════ */
.site-footer {
  background: linear-gradient(135deg, var(--primary-dk), var(--primary));
  color: rgba(255,255,255,.85);
  padding: 28px 24px;
  font-size: .85rem;
  margin-top: auto;
}
.footer-inner {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; flex-wrap: wrap; gap: 16px;
  justify-content: space-between;
}
.footer-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: .95rem; color: #fff; }
.footer-copy { color: rgba(255,255,255,.7); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: rgba(255,255,255,.75); font-size: .82rem; transition: color var(--transition); }
.footer-links a:hover { color: #fff; }

/* ══════════════════════════════════════════
   WOOCOMMERCE GLOBAL
══════════════════════════════════════════ */
.woocommerce-notices-wrapper { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
  padding: 14px 18px; border-radius: var(--radius);
  font-size: .88rem; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.woocommerce-message { background: #e8f8ee; border-right: 4px solid #28a745; color: #1a5c30; }
.woocommerce-info    { background: var(--light-bg); border-right: 4px solid var(--secondary); color: var(--primary); }
.woocommerce-error   { background: #fdecea; border-right: 4px solid #e05c5c; color: #8b2323; }
.woocommerce-error li { margin-right: 0; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 900px) {
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
}

@media (max-width: 640px) {
  .header-inner { gap: 10px; }
  .site-tagline { display: none; }
  .site-title   { font-size: 1rem; }
  .cart-label   { display: none; }
  .header-cart  { padding: 8px 10px; }
  .header-search { max-width: 100%; }

  .site-hero { padding: 36px 20px; }
  .store-wrapper { padding: 24px 16px 60px; }

  .categories-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
  .cat-card { padding: 12px 8px; }
  .cat-icon { width: 36px; height: 36px; font-size: 1rem; }

  .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .modal-box { border-radius: 16px; max-height: 95dvh; }
  .modal-content { padding: 18px 20px 24px; }
  .modal-title   { font-size: 1.1rem; }
  .modal-footer  { flex-direction: column; align-items: stretch; }
  .btn-add-cart  { justify-content: center; }

  .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
}

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