/* ============================================
   รัตนทิพย์ RATTANATIP - Enhancements
   สไตล์สำหรับ: Cart, Search, FAQ Page,
   Product/Article Detail, Accessibility, 404
   ============================================ */

/* ===== Accessibility: Skip Link ===== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 10000;
  background: var(--red);
  color: var(--white);
  padding: 12px 22px;
  border-radius: 0 0 12px 12px;
  font-weight: 700;
  transition: top 0.25s ease;
  box-shadow: var(--shadow-md);
}

.skip-link:focus {
  top: 0;
}

/* ===== Accessibility: Focus Styles ===== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.tab-btn:focus-visible,
.filter-btn:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== Screen Reader Only ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .trust-track {
    animation: none !important;
  }
}

/* ============================================
   SHOPPING CART
   ============================================ */

/* Cart Icon Badge in Navbar */
.nav-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 2px solid var(--yellow);
  color: var(--red);
  padding: 10px 18px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 1rem;
  margin-left: 6px;
  transition: var(--transition);
}

.nav-cart:hover {
  background: var(--yellow-light);
  transform: translateY(-2px);
}

.cart-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--red);
  color: var(--white);
  border-radius: 11px;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-red);
  transform: scale(0);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cart-badge.show {
  transform: scale(1);
}

/* Cart Drawer (Slide-out panel) */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 1500;
}

.cart-overlay.open {
  opacity: 1;
  visibility: visible;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  background: var(--white);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.2);
  z-index: 1600;
  display: flex;
  flex-direction: column;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-drawer.open {
  right: 0;
}

.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 26px;
  background: var(--gradient-red);
  color: var(--white);
}

.cart-drawer-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-close {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  color: var(--white);
  font-size: 1.4rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.cart-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.cart-empty .emoji {
  font-size: 4rem;
  margin-bottom: 16px;
  display: block;
}

.cart-empty h4 {
  font-size: 1.2rem;
  color: var(--black);
  margin-bottom: 8px;
}

.cart-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--gray-50);
  margin-bottom: 12px;
  align-items: center;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.cart-item-image {
  width: 64px;
  height: 64px;
  background: var(--gradient-yellow);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.cart-item-info h4 {
  font-size: 0.95rem;
  color: var(--black);
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}

.cart-item-price {
  color: var(--red);
  font-weight: 700;
  font-size: 0.9rem;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.cart-qty-btn {
  width: 26px;
  height: 26px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 0.9rem;
}

.cart-qty-btn:hover {
  background: var(--yellow);
  border-color: var(--yellow);
}

.cart-qty-value {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 20px;
  text-align: center;
  color: var(--gray-700);
}

.cart-item-remove {
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  color: var(--gray-300);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
  align-self: start;
}

.cart-item-remove:hover {
  color: var(--red);
  transform: scale(1.15);
}

.cart-drawer-footer {
  padding: 20px 26px 26px;
  border-top: 1px solid var(--gray-100);
  background: var(--white);
}

.cart-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.cart-subtotal .label {
  color: var(--gray-700);
  font-weight: 600;
}

.cart-subtotal .amount {
  color: var(--red);
  font-size: 1.5rem;
  font-weight: 800;
}

.cart-shipping-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 14px;
  padding: 8px;
  background: var(--yellow-light);
  border-radius: 8px;
}

.cart-checkout-btn {
  width: 100%;
  padding: 15px;
  background: var(--gradient-red);
  color: var(--white);
  border: none;
  border-radius: 30px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-red);
}

.cart-checkout-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -8px rgba(185, 28, 28, 0.5);
}

.cart-continue {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--gray-500);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
}

.cart-continue:hover {
  color: var(--red);
}

/* Add-to-cart flying animation */
.added-flash {
  animation: addedFlash 0.6s ease;
}

@keyframes addedFlash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); background: var(--red) !important; color: var(--white) !important; }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--black);
  color: var(--white);
  padding: 14px 26px;
  border-radius: 30px;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  z-index: 2000;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.4s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90vw;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast .toast-icon {
  width: 28px;
  height: 28px;
  background: #10B981;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

/* ============================================
   SEARCH
   ============================================ */

.search-toggle {
  background: var(--white);
  border: 2px solid var(--gray-200);
  color: var(--gray-700);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
  margin-left: 6px;
}

.search-toggle:hover {
  border-color: var(--yellow);
  color: var(--red);
  transform: translateY(-2px);
}

.search-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1700;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}

.search-modal.open {
  opacity: 1;
  visibility: visible;
}

.search-modal-content {
  width: 100%;
  max-width: 640px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
  margin: 0 20px;
}

.search-modal.open .search-modal-content {
  transform: translateY(0);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--gray-100);
}

.search-input-wrap .search-icon {
  font-size: 1.4rem;
  margin: 0 14px;
  color: var(--gray-500);
}

.search-input-wrap input {
  flex: 1;
  padding: 16px 8px;
  border: none;
  font-size: 1.1rem;
  font-family: inherit;
  background: transparent;
}

.search-input-wrap input:focus {
  outline: none;
}

.search-input-wrap .search-clear {
  background: var(--gray-100);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--gray-500);
  margin-right: 8px;
  transition: var(--transition);
}

.search-input-wrap .search-clear:hover {
  background: var(--red);
  color: var(--white);
}

.search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 12px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  transition: var(--transition);
  cursor: pointer;
  color: inherit;
}

.search-result-item:hover {
  background: var(--gray-50);
}

.search-result-emoji {
  width: 48px;
  height: 48px;
  background: var(--gradient-yellow);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.search-result-info h4 {
  font-size: 1rem;
  color: var(--black);
  font-weight: 700;
  margin-bottom: 2px;
}

.search-result-info p {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.search-result-price {
  margin-left: auto;
  font-weight: 800;
  color: var(--red);
}

.search-no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.search-no-results .emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
}

.search-hint {
  padding: 16px 20px;
  font-size: 0.85rem;
  color: var(--gray-500);
  text-align: center;
  background: var(--gray-50);
}

/* Search box on products page */
.products-search {
  max-width: 500px;
  margin: 0 auto 30px;
  position: relative;
}

.products-search input {
  width: 100%;
  padding: 14px 20px 14px 50px;
  border: 2px solid var(--gray-200);
  border-radius: 30px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--white);
  transition: var(--transition);
}

.products-search input:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
}

.products-search::before {
  content: '🔍';
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
}

/* ============================================
   FAQ PAGE
   ============================================ */

.faq-hero {
  padding-bottom: 0;
}

.faq-categories {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.faq-category {
  background: var(--white);
  border: 2px solid var(--gray-200);
  padding: 8px 20px;
  border-radius: 30px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
  transition: var(--transition);
}

.faq-category:hover,
.faq-category.active {
  background: var(--gradient-red);
  color: var(--white);
  border-color: transparent;
}

.faq-contact-cta {
  background: var(--gradient-yellow);
  padding: 50px;
  border-radius: var(--radius-xl);
  text-align: center;
  margin-top: 60px;
}

.faq-contact-cta h3 {
  font-size: 1.6rem;
  color: var(--red-deep);
  margin-bottom: 12px;
  font-weight: 800;
}

.faq-contact-cta p {
  color: var(--red-dark);
  margin-bottom: 22px;
  font-size: 1.05rem;
}

/* ============================================
   ARTICLE DETAIL extras
   ============================================ */

.article-related {
  margin-top: 60px;
  padding-top: 50px;
  border-top: 1px solid var(--gray-200);
}

.article-related h3 {
  font-size: 1.6rem;
  color: var(--red);
  margin-bottom: 28px;
  font-weight: 700;
  text-align: center;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.related-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--gray-100);
}

.related-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.related-card .related-image {
  height: 140px;
  background: var(--gradient-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.related-card .related-body {
  padding: 18px;
}

.related-card h4 {
  font-size: 1.05rem;
  color: var(--black);
  margin-bottom: 6px;
  font-weight: 700;
  line-height: 1.4;
}

.related-card .related-meta {
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* ============================================
   404 PAGE
   ============================================ */

.error-page {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 20px 60px;
  background:
    radial-gradient(circle at 20% 30%, rgba(245, 158, 11, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(185, 28, 28, 0.08) 0%, transparent 50%),
    var(--cream);
}

.error-code {
  font-size: clamp(6rem, 18vw, 12rem);
  font-weight: 900;
  line-height: 1;
  background: var(--gradient-warm);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 20px;
}

.error-page h1 {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  color: var(--black);
  margin-bottom: 16px;
  font-weight: 800;
}

.error-page p {
  color: var(--gray-500);
  font-size: 1.1rem;
  max-width: 500px;
  margin: 0 auto 32px;
}

.error-emoji {
  font-size: 5rem;
  margin-bottom: 24px;
  display: inline-block;
  animation: bounce-soft 2s ease-in-out infinite;
}

.error-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================
   PAGE PROGRESS BAR
   ============================================ */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--gradient-warm);
  width: 0%;
  z-index: 1100;
  transition: width 0.1s linear;
}

/* ============================================
   PRODUCT QUICK "ADD TO CART" BUTTON
   ============================================ */
.product-add-cart {
  background: var(--gray-50);
  color: var(--red);
  padding: 9px 16px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.product-add-cart:hover {
  background: var(--gradient-red);
  color: var(--white);
  border-color: transparent;
  transform: scale(1.05);
}

/* ============================================
   REAL GOOGLE MAP EMBED
   ============================================ */
.map-embed {
  height: 450px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.map-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ============================================
   FORM SUCCESS/ERROR STATES
   ============================================ */
.form-group.error input,
.form-group.error textarea,
.form-group.error select {
  border-color: var(--red);
  background: #FEF2F2;
}

.form-group .error-msg {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 6px;
  display: none;
}

.form-group.error .error-msg {
  display: block;
}

.form-success-banner {
  background: linear-gradient(135deg, #10B981, #059669);
  color: var(--white);
  padding: 16px 22px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.form-success-banner.show {
  display: flex;
  animation: fadeIn 0.4s ease;
}

/* ============================================
   RESPONSIVE for new components
   ============================================ */
@media (max-width: 768px) {
  .nav-cart span:not(.cart-badge) {
    display: none;
  }

  .nav-cart {
    padding: 10px;
    width: 42px;
    height: 42px;
    justify-content: center;
  }

  .search-toggle {
    display: flex;
  }

  .cart-drawer {
    max-width: 100%;
  }

  .faq-contact-cta {
    padding: 30px 20px;
  }

  .products-search {
    margin-bottom: 24px;
  }
}

@media (max-width: 480px) {
  .search-modal-content {
    margin: 0 12px;
  }

  .cart-item {
    grid-template-columns: 56px 1fr;
  }

  .cart-item-remove {
    grid-column: 2;
    justify-self: end;
  }
}
