/* Global Reset and Variables */
:root {
  /* Light Theme - Default */
  --bg-color: #FAFAF9;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F5F5F4;
  --text-main: #0C0A09;
  --text-muted: #78716C;
  --text-inverse: #FAFAF9;
  --accent-color: #CA8A04;
  /* Gold */
  --accent-hover: #A16207;
  --border-color: #E7E5E4;
  --error-color: #EF4444;
  --success-color: #22C55E;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-md: 12px;
  --radius-lg: 16px;

  --font-heading: 'Rubik', sans-serif;
  --font-body: 'Nunito Sans', sans-serif;
}

[data-theme="dark"] {
  --bg-color: #1C1917;
  --bg-card: #292524;
  --bg-card-hover: #44403C;
  --text-main: #FAFAF9;
  --text-muted: #A8A29E;
  --text-inverse: #0C0A09;
  --accent-color: #EAB308;
  --accent-hover: #FACC15;
  --border-color: #44403C;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4,
.brand {
  font-family: var(--font-heading);
  font-weight: 700;
}

a {
  color: var(--accent-color);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input,
textarea {
  font-family: inherit;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(var(--bg-color-rgb), 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
}

[data-theme="dark"] .navbar {
  background-color: rgba(28, 25, 23, 0.8);
}

[data-theme="light"] .navbar {
  background-color: rgba(250, 250, 249, 0.8);
}

.navbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.5rem;
  color: var(--text-main);
}

.brand-icon {
  color: var(--accent-color);
}

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

/* Buttons */
.btn-primary {
  background-color: var(--accent-color);
  color: var(--text-inverse);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s, transform 0.1s;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: scale(1.02);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
}

.btn-ghost:hover {
  background-color: var(--bg-card-hover);
}

.btn-icon {
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
}

.icon-sm {
  width: 18px;
  height: 18px;
}

/* Theme Toggle Icons */
[data-theme="dark"] .sun-icon {
  display: block;
}

[data-theme="dark"] .moon-icon {
  display: none;
}

[data-theme="light"] .sun-icon {
  display: none;
}

[data-theme="light"] .moon-icon {
  display: block;
}

/* Announcement Banner */
.banner {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  transition: max-height 0.3s ease-out, opacity 0.3s;
  overflow: hidden;
}

.banner.hidden {
  max-height: 0;
  opacity: 0;
  padding: 0;
  border: none;
}

.banner-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 24px;
}

.banner-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.banner-text strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  margin-bottom: 8px;
  font-size: 1rem;
}

.banner-text p {
  margin-bottom: 4px;
}

/* Hero Section */
.hero-section {
  padding: 48px 0 32px;
  text-align: center;
}

.section-title {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Products Grid (Bento) */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding-bottom: 64px;
}

.product-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--accent-color);
  box-shadow: var(--shadow-lg);
}

.product-tag {
  align-self: flex-start;
  background-color: var(--bg-card-hover);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.product-name {
  font-size: 1.25rem;
  margin-bottom: 8px;
  font-family: var(--font-heading);
  line-height: 1.4;
}

.product-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
  flex-grow: 1;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.product-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
  font-family: var(--font-heading);
}

.product-price small {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.product-stock {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  border: 1px solid var(--border-color);
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background-color: var(--bg-card);
  z-index: 10;
}

.modal-title {
  font-size: 1.5rem;
}

.modal-close {
  color: var(--text-muted);
  background: var(--bg-card-hover);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: var(--error-color);
  color: white;
}

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-color);
  color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(202, 138, 4, 0.2);
}

.captcha-group {
  display: flex;
  gap: 12px;
}

.captcha-group .form-input {
  flex: 1;
}

.captcha-img {
  height: 48px;
  min-width: 120px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  background-color: #FAFAF9;
  /* Force light bg for captcha readability */
}

/* Spinner */
.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* Usage Guide within Product Modal */
.usage-guide {
  background-color: var(--bg-color);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.95rem;
  border-left: 4px solid var(--accent-color);
}

.usage-guide p {
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.usage-guide img {
  max-width: 100%;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

/* Markdown formatting helpers */
.text-error {
  color: var(--error-color);
  margin-top: 8px;
  font-size: 0.9rem;
}

.text-success {
  color: var(--success-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .section-title {
    font-size: 2rem;
  }

  .bento-grid {
    grid-template-columns: 1fr;
  }

  .banner-content {
    flex-direction: column;
  }

  #close-banner {
    position: absolute;
    right: 8px;
    top: 12px;
  }

  .footer-inner {
    flex-direction: column;
  }
}

/* UI Animations & Enhancements */
button,
.product-card,
input {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal-container {
  animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes modalPop {
  0% {
    transform: translateY(30px) scale(0.9);
    opacity: 0;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Footer & Guide Section */
.site-footer {
  margin-top: 60px;
  padding: 40px 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

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

.footer-card {
  flex: 1;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s, box-shadow 0.3s;
}

.footer-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(202, 138, 4, 0.4);
  /* subtle accent border */
}

.footer-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  margin-bottom: 20px;
  color: var(--text-main);
}

.footer-title i {
  color: var(--accent-color);
}

.guide-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.guide-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.step-num {
  background: var(--accent-color);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: bold;
  flex-shrink: 0;
}

.guide-steps strong {
  color: var(--text-main);
}

.highlight-link {
  color: #1677FF;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed #1677FF;
  transition: opacity 0.2s;
}

.highlight-link:hover {
  opacity: 0.8;
}

.warranty-content {
  background: rgba(202, 138, 4, 0.05);
  /* very light accent bg */
  border: 1px dashed var(--accent-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.warranty-highlight {
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 1.1rem;
}

/* User Dropdown */
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background-color: var(--bg-card-hover);
}

.dropdown-item.text-error {
  color: var(--error-color);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

/* Pay Options UI */
.pay-option-wrapper {
  display: block;
  cursor: pointer;
}

.pay-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pay-option-wrapper input:checked+.pay-option {
  border-color: var(--accent-color);
  background: rgba(202, 138, 4, 0.03);
  box-shadow: 0 0 0 1px var(--accent-color);
}

.pay-option span {
  font-weight: 600;
  font-size: 0.95rem;
}

.pay-option .check-icon {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  background: var(--bg-card);
  color: var(--accent-color);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s;
}

.pay-option-wrapper input:checked+.pay-option .check-icon {
  opacity: 1;
  transform: scale(1);
}

.pay-option:hover {
  background: var(--bg-card-hover);
}