/* ============================================
   BAHA — Haryt Bahasy | Рейтинг Товаров
   Global Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400&family=DM+Sans:wght@300;400;500;600&display=swap');

/* === CSS Variables === */
:root {
  --primary:        #B5161B;
  --primary-dark:   #8A0F13;
  --primary-light:  #F9EAEA;
  --gold:           #C9942A;
  --gold-light:     #FDF5E0;
  --bg:             #FFFDF8;
  --bg-alt:         #F4EFE6;
  --surface:        #FFFFFF;
  --text:           #1C1410;
  --text-muted:     #7A6C62;
  --border:         #E4DDD4;
  --star:           #E8A020;
  --star-empty:     #D9D1C8;
  --success:        #2E7D4F;
  --font-display:   'Fraunces', serif;
  --font-body:      'DM Sans', sans-serif;
  --radius:         14px;
  --radius-sm:      8px;
  --radius-lg:      20px;
  --shadow-sm:      0 1px 6px rgba(28,20,16,0.07);
  --shadow:         0 3px 16px rgba(28,20,16,0.09);
  --shadow-hover:   0 8px 32px rgba(28,20,16,0.14);
  --transition:     0.22s ease;
  --max-width:      1120px;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-body); border: none; background: none; }
input, textarea { font-family: var(--font-body); }

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

/* === Header === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,253,248,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

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

.logo {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.logo-dot { color: var(--primary); }

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

.lang-switcher {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  transition: var(--transition);
  letter-spacing: 0.3px;
}
.lang-switcher:hover { border-color: var(--primary); color: var(--primary); }

.btn-login {
  font-size: 14px;
  font-weight: 500;
  color: var(--surface);
  background: var(--primary);
  padding: 8px 20px;
  border-radius: 20px;
  transition: var(--transition);
}
.btn-login:hover { background: var(--primary-dark); }

.btn-logout {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  transition: var(--transition);
}
.btn-logout:hover { border-color: var(--primary); color: var(--primary); }

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

/* === Hero Section === */
.hero {
  background: linear-gradient(135deg, #1C1410 0%, #3A1F1A 50%, #2C1A10 100%);
  padding: 72px 0 80px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(181,22,27,0.25) 0%, transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 10%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(201,148,42,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-label {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 18px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  color: #FFFDF8;
  line-height: 1.15;
  margin-bottom: 36px;
}

.search-box {
  display: flex;
  max-width: 580px;
  background: var(--surface);
  border-radius: 50px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

.search-input {
  flex: 1;
  padding: 16px 24px;
  font-size: 15px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
}
.search-input::placeholder { color: var(--text-muted); }

.search-btn {
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 0 50px 50px 0;
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 500;
  transition: var(--transition);
}
.search-btn:hover { background: var(--primary-dark); }

/* === Sections === */
.section { padding: 56px 0; }
.section-alt { background: var(--bg-alt); }

.section-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 28px;
}

/* === Categories Grid === */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.category-card:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.cat-icon { font-size: 28px; line-height: 1; }

/* === Product Cards Grid === */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}
.product-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }

.product-card-img {
  height: 160px;
  background: var(--bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
}

.product-card-body { padding: 16px; }

.product-card-category {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}

.product-card-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.product-card-brand {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* === Stars === */
.stars {
  display: flex;
  align-items: center;
  gap: 3px;
}
.star { font-size: 16px; line-height: 1; }
.star.filled { color: var(--star); }
.star.empty  { color: var(--star-empty); }
.star.half   { color: var(--star); }

.rating-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rating-number {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.rating-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* === Skeleton Loader === */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  min-height: 260px;
  border-radius: var(--radius);
  border: none !important;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Ad Placeholder === */
.ad-placeholder {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 32px 0;
  background: var(--bg-alt);
}

/* === Footer === */
.footer {
  background: var(--text);
  color: rgba(255,253,248,0.7);
  padding: 40px 0;
  text-align: center;
}
.footer .logo { color: #FFFDF8; display: inline-block; margin-bottom: 8px; }
.footer p { font-size: 13px; }

/* ============================================
   PRODUCT PAGE SPECIFIC
   ============================================ */

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { opacity: 0.4; }

.product-hero {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  padding: 40px 0;
  align-items: start;
}

.product-image-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 80px;
}

.product-meta { padding-top: 8px; }

.product-category-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.product-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 6px;
}

.product-brand {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.rating-big {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.rating-big .score {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.rating-big .stars { font-size: 22px; }
.rating-big .count { font-size: 14px; color: var(--text-muted); }

/* Rating breakdown bars */
.rating-bars { margin-bottom: 28px; }
.rating-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.rating-bar-row span:first-child { width: 16px; text-align: right; }
.bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-alt);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--star);
  border-radius: 3px;
  transition: width 0.8s ease;
}
.rating-bar-row span:last-child { width: 28px; }

.btn-write-review {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  padding: 13px 28px;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-write-review:hover { background: var(--primary-dark); }

/* === Reviews Section === */
.reviews-section { padding: 48px 0; }

.reviews-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.reviews-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

.sort-select {
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.review-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 14px;
  transition: var(--transition);
}
.review-card:hover { box-shadow: var(--shadow-sm); }

.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.reviewer-info { display: flex; align-items: center; gap: 10px; }
.reviewer-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.reviewer-name { font-size: 14px; font-weight: 500; }
.review-date { font-size: 12px; color: var(--text-muted); }
.review-text { font-size: 15px; line-height: 1.65; color: var(--text); margin-top: 10px; }

.empty-reviews {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 15px;
}
.empty-reviews .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* === Review Form Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,20,16,0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  transform: translateY(20px);
  transition: transform 0.25s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}
.modal-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 28px; }

/* Star Rating Input */
.star-input-group { margin-bottom: 22px; }
.star-input-label { font-size: 14px; font-weight: 500; margin-bottom: 10px; display: block; }
.star-input {
  display: flex;
  gap: 6px;
  flex-direction: row-reverse;
  justify-content: flex-end;
}
.star-input input { display: none; }
.star-input label {
  font-size: 36px;
  cursor: pointer;
  color: var(--star-empty);
  transition: color 0.15s, transform 0.15s;
  line-height: 1;
}
.star-input label:hover,
.star-input label:hover ~ label,
.star-input input:checked ~ label { color: var(--star); }
.star-input label:hover { transform: scale(1.15); }

.form-group { margin-bottom: 18px; }
.form-label { font-size: 14px; font-weight: 500; margin-bottom: 8px; display: block; }
.form-input, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.18s;
  outline: none;
  resize: vertical;
}
.form-input:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { min-height: 100px; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.btn-submit {
  flex: 1;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-submit:hover { background: var(--primary-dark); }
.btn-cancel {
  padding: 14px 24px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: 15px;
  color: var(--text-muted);
  transition: var(--transition);
}
.btn-cancel:hover { border-color: var(--primary); color: var(--primary); }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: #FFFDF8;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success::before { content: '✓  '; color: #5DCE8F; }
.toast.error::before { content: '✕  '; color: #F07070; }

/* Login required message */
.login-required {
  background: var(--gold-light);
  border: 1px solid #E8D08A;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 14px;
  color: #7A5C1A;
  margin-bottom: 20px;
  display: none;
}
.login-required.visible { display: block; }

/* === Responsive === */
@media (max-width: 700px) {
  .product-hero { grid-template-columns: 1fr; }
  .product-image-box { max-width: 220px; }
  .modal { padding: 24px; }
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
  .hero { padding: 48px 0 56px; }
}
