/* ==========================================================================
   RineStore — Phase 1 template styles
   Mobile-first: most visitors arrive from TikTok/Facebook in-app browsers
   on a phone, so base styles target small screens and scale up from there.
   ========================================================================== */

:root {
  --brand-primary: #1f7a4d;
  --brand-accent: #f4a300;
  --text-dark: #1a1a1a;
  --text-muted: #6b6b6b;
  --bg-light: #f7f6f3;
  --border-color: #e6e3dc;
  --radius: 10px;
  --max-width: 1140px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

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

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

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

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 50;
}

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

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-dark);
}

.logo-dot { color: var(--brand-primary); }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.lang-switch a {
  color: var(--text-muted);
  padding: 4px;
}

.lang-switch a.active {
  color: var(--brand-primary);
}

.lang-divider {
  color: var(--border-color);
}

.cart-link {
  position: relative;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 4px 2px;
}

.cart-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--brand-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text-dark);
  border-radius: 2px;
}

.site-nav {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.site-nav.open {
  max-height: 320px;
}

.site-nav a {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  color: var(--text-dark);
  font-weight: 500;
}

.site-nav a.active,
.site-nav a:hover {
  color: var(--brand-primary);
}

/* ---------- Hero ---------- */

.hero {
  background: linear-gradient(135deg, var(--brand-primary), #14532d);
  color: #fff;
  text-align: center;
  padding: 64px 0;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.hero p {
  margin: 0 0 24px;
  font-size: 1.05rem;
  opacity: 0.92;
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--brand-accent);
  color: #1a1a1a;
}

/* ---------- Section headings ---------- */

.section-heading {
  font-size: 1.4rem;
  margin: 0 0 20px;
  text-align: center;
}

.categories, .featured {
  padding: 48px 0;
}

.categories { background: var(--bg-light); }

/* ---------- Category grid ---------- */

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.category-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.category-card-image {
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #e6e3dc, #cfcabd);
}

.category-card-name {
  display: block;
  padding: 12px;
  font-weight: 600;
}

/* ---------- Product grid ---------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.product-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.product-card-image {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #d8ece0, #b7d8c4);
}

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

.product-card-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.product-card-name {
  margin: 4px 0;
  font-size: 1rem;
}

.product-card-price {
  font-weight: 700;
  color: var(--brand-primary);
}

/* ---------- Category page ---------- */

.breadcrumb-trail {
  margin: 20px auto 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.breadcrumb-trail a {
  color: var(--text-muted);
}

.breadcrumb-sep {
  margin: 0 6px;
  opacity: 0.6;
}

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

.category-subcategories {
  padding-top: 32px;
}

.category-hero {
  background: linear-gradient(135deg, var(--brand-primary), #14532d);
  background-size: cover;
  background-position: center;
  color: #fff;
  text-align: center;
  padding: 48px 0;
}

.category-hero h1 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.category-hero p {
  margin: 0;
  opacity: 0.92;
}

.category-empty {
  padding: 40px 16px 64px;
  text-align: center;
}

.category-empty-note {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.category-products {
  padding: 40px 16px 64px;
}

.category-back-link {
  margin-top: 24px;
}

/* ---------- Product detail page ---------- */

.product-detail {
  padding: 32px 16px 64px;
}

.product-breadcrumb {
  margin: 0 0 20px;
  font-size: 0.9rem;
}

.product-breadcrumb a {
  color: var(--text-muted);
}

.product-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

.product-gallery-main-wrap {
  position: relative;
}

.product-gallery-main {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--bg-light);
  display: block;
}

.product-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
  transition: background 0.15s ease, transform 0.15s ease;
}

.product-gallery-nav:hover {
  background: #fff;
  transform: translateY(-50%) scale(1.05);
}

.product-gallery-nav svg {
  width: 20px;
  height: 20px;
}

.product-gallery-prev {
  left: 12px;
}

.product-gallery-next {
  right: 12px;
}

.product-gallery-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #d8ece0, #b7d8c4);
}

.product-gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.product-gallery-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.75;
}

.product-gallery-thumb:hover,
.product-gallery-thumb.active {
  opacity: 1;
  border-color: var(--brand-primary);
}

.product-info-category {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.product-info h1 {
  margin: 4px 0 12px;
  font-size: 1.6rem;
}

.product-info-price {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand-primary);
  margin: 0 0 10px;
}

.product-stock-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.product-stock-badge.in-stock {
  background: #e6f4ea;
  color: #1f7a4d;
}

.product-stock-badge.out-of-stock {
  background: #fdecea;
  color: #a4302a;
}

.product-info-description {
  color: var(--text-dark);
  margin-bottom: 24px;
  white-space: pre-line;
}

.product-condition-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0 0 16px;
  background: #eef1f6;
  color: #40506b;
}

.product-condition-badge.product-condition-new {
  background: #e6f4ea;
  color: #1f7a4d;
}

.product-condition-badge.product-condition-very_good {
  background: #eaf2fb;
  color: #2c5fa8;
}

.product-condition-badge.product-condition-good {
  background: #fdf3e2;
  color: #a06a0a;
}

.product-condition-badge.product-condition-acceptable {
  background: #f3eefc;
  color: #6c3fa3;
}

.product-buy-btn {
  border: none;
  width: 100%;
  font-family: inherit;
  cursor: pointer;
}

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

.product-buy-note {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.product-buy-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-qty-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.product-qty-field input {
  width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

@media (min-width: 760px) {
  .product-detail-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* ---------- Generic alert banner (cart/checkout) ---------- */

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.alert-success {
  background: #e6f4ea;
  color: #1f7a4d;
  border: 1px solid #b9e0c6;
}

.alert-error {
  background: #fdecea;
  color: #a4302a;
  border: 1px solid #f4c6c1;
}

/* ---------- Generic form field (checkout) ---------- */

.form-field {
  display: block;
  margin-bottom: 16px;
}

.form-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

.form-field textarea {
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
}

.form-actions .btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
}

/* ---------- Cart page ---------- */

.cart-page {
  padding: 32px 16px 64px;
}

.cart-heading {
  text-align: left;
  margin-bottom: 20px;
}

.cart-empty {
  padding: 40px 0;
  text-align: center;
}

.cart-empty p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.cart-table-wrap {
  margin-bottom: 20px;
}

.cart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

/* Below 640px the table becomes a stack of cards — one per cart line — since
   a real data-table doesn't fit a phone screen without hiding the Remove
   button off to the side. Each td's data-label attribute (set in cart.php)
   supplies its own mini-heading; the product cell doesn't need one, it's
   self-explanatory. */
.cart-table thead {
  display: none;
}

.cart-table,
.cart-table tbody,
.cart-table tr,
.cart-table td {
  display: block;
  width: 100%;
}

.cart-table tr {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
}

.cart-table td {
  border-bottom: none;
  padding: 4px 0;
}

.cart-table td[data-label] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cart-table td[data-label]::before {
  content: attr(data-label);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cart-col-product {
  padding-bottom: 10px;
}

.cart-col-remove {
  text-align: right;
}

@media (min-width: 640px) {
  .cart-table-wrap {
    overflow-x: auto;
  }

  .cart-table thead {
    display: table-header-group;
  }

  .cart-table {
    display: table;
    width: 100%;
  }

  .cart-table tbody {
    display: table-row-group;
  }

  .cart-table tr {
    display: table-row;
    width: auto;
    padding: 0;
    border-bottom: none;
  }

  .cart-table th,
  .cart-table td {
    display: table-cell;
    width: auto;
    text-align: left;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
  }

  .cart-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
  }

  .cart-col-product { min-width: 200px; }

  /* Same specificity as the mobile rule above (class + element + attribute
     selector) so source order — this block comes later — is what decides;
     without repeating the attribute selector here the mobile flex rule
     would keep winning at desktop width. */
  .cart-table td[data-label] {
    display: table-cell;
  }

  .cart-table td[data-label]::before {
    content: none;
  }

  .cart-col-remove {
    text-align: left;
  }
}

.cart-product-link {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.cart-thumb-empty {
  background: var(--bg-light);
  border: 1px dashed var(--border-color);
}

.cart-qty-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-qty-input {
  width: 56px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-primary);
}

.btn-link-danger { color: #a4302a; }

.cart-summary {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-end;
  text-align: right;
}

.cart-total {
  font-size: 1.1rem;
  margin: 0;
}

.cart-summary-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* ---------- Checkout page ---------- */

.checkout-page {
  padding: 32px 16px 64px;
}

.checkout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  align-items: start;
}

.checkout-section-title {
  font-size: 1.1rem;
  margin: 0 0 14px;
}

.checkout-summary {
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 20px;
}

.checkout-summary-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.checkout-summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.checkout-summary-qty {
  color: var(--text-muted);
  margin-left: 4px;
}

.checkout-summary-total {
  font-size: 1.05rem;
  margin: 12px 0 0;
}

.checkout-cod-note {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.checkout-form-wrap {
  max-width: 480px;
}

/* ---------- Order confirmation page ---------- */

.order-confirmation-page {
  padding: 40px 16px 64px;
}

.order-confirmation-card {
  max-width: 560px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 32px;
}

.order-confirmation-title {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.order-confirmation-number {
  margin: 0 0 16px;
  font-size: 1rem;
}

.order-confirmation-cod-note {
  margin: 0 0 28px;
  padding: 12px;
  background: var(--bg-light);
  border-radius: 8px;
  font-size: 0.9rem;
}

.order-confirmation-delivery {
  margin: 0 0 16px;
  line-height: 1.6;
}

.order-confirmation-notes {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.order-confirmation-continue {
  margin-top: 24px;
}

@media (min-width: 760px) {
  .checkout-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---------- Footer ---------- */

.site-footer {
  background: #14261d;
  color: #e9ece9;
  padding: 40px 0 0;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.footer-brand .logo { color: #fff; }
.footer-brand p { color: #bcc4bd; margin: 8px 0 0; font-size: 0.9rem; }
.footer-meta { margin-top: 4px !important; }

.footer-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa69d;
  margin: 0 0 10px;
}

.social-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.social-link {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #2c4133;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #e9ece9;
}

.social-link:hover { border-color: var(--brand-accent); color: var(--brand-accent); }

.footer-bottom {
  margin-top: 32px;
  padding: 16px 0;
  border-top: 1px solid #223528;
  text-align: center;
  font-size: 0.8rem;
  color: #8b9690;
}

/* ---------- Larger screens ---------- */

@media (min-width: 640px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 860px) {
  .nav-toggle { display: none; }

  .site-nav {
    position: static;
    flex-direction: row;
    max-height: none;
    overflow: visible;
    border-bottom: none;
    background: none;
  }

  .site-nav a {
    border-top: none;
    padding: 8px 14px;
  }

  .hero { padding: 96px 0; }
  .hero h1 { font-size: 2.75rem; }

  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
  }

  .product-grid { grid-template-columns: repeat(4, 1fr); }
}
