/* ==========================================================================
   Components: Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0.85rem 1.75rem; /* Improved padding */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-radius: var(--radius-md); /* Consistent radius */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Smooth transition */
  text-align: center;
  cursor: pointer;
  border: none;
  font-family: inherit;
  line-height: 1.2;
  font-size: 0.9rem;
  position: relative;
  z-index: 1;
  overflow: hidden;
  width: auto;
  box-shadow: var(--shadow-sm);
}

.btn:disabled, .btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  background-color: #ccc !important;
  color: #666 !important;
}

@media (max-width: 479px) {
  .btn {
    width: 100%;
    min-height: 52px; /* Touch friendly */
    padding: 0.8rem 1.5rem;
  }
}

@media (min-width: 480px) {
  .btn {
    padding: 0.8rem 1.75rem;
    font-size: 0.9rem;
  }
}

@media (min-width: 768px) {
  .btn {
    padding: 0.85rem 2rem;
    font-size: 0.95rem;
  }
}

.btn:hover {
  transform: translateY(-5px) scale(1.02);
}

.btn:active {
  transform: translateY(-2px) scale(0.98);
}

.btn i, .btn svg {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 2.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .btn i, .btn svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

.btn-primary {
  background: var(--color-black);
  color: var(--color-white);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-black);
}

.btn-primary:hover {
  background: var(--color-accent);
  color: var(--color-black);
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.5);
  border-color: var(--color-accent);
}

.btn-primary::before, .btn-secondary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.btn-primary:hover::before, .btn-secondary:hover::before {
  animation: goldSweep 1.2s infinite;
}

.btn-secondary {
  background-color: var(--color-black);
  color: var(--color-white);
  border: 1px solid var(--color-black);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
  background-color: var(--color-accent);
  color: var(--color-black);
  border-color: var(--color-accent);
}

.btn-large {
  font-size: 1rem;
  padding: 1rem 2rem;
  gap: 12px;
}

@media (min-width: 768px) {
  .btn-large {
    font-size: 1.1rem;
    padding: 1.1rem 3rem;
    gap: 14px;
  }
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-icon {
  background: none;
  border: none;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  cursor: pointer;
}

.btn-icon i, .btn-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke-width: 2.5;
}

/* ==========================================================================
   Components: Cards
   ========================================================================== */
.product-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 5;
  border: 1px solid rgba(0,0,0,0.05); /* Subtle border */
}

.product-card:hover {
  transform: translateY(-4px); /* Slight lift */
  box-shadow: var(--shadow-lg);
  border-color: rgba(0,0,0,0.1);
}

.product-image-wrapper {
  aspect-ratio: 4/3;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.product-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 12px 12px 0 0;
  transition: transform 0.5s ease;
}

.product-card:hover .product-image {
  transform: scale(1.05); /* Gentle zoom */
}

.product-info {
  padding: var(--spacing-md);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-category {
  font-size: 0.75rem;
  color: var(--color-text-light);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.product-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: var(--spacing-xs);
  color: var(--color-text);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

@media (min-width: 768px) {
  .product-title {
    font-size: 1.25rem;
  }
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  gap: var(--spacing-sm);
  padding-top: var(--spacing-xs);
}

.product-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-accent);
  letter-spacing: -0.02em;
}

@media (min-width: 768px) {
  .product-price {
    font-size: 1.35rem;
  }
}

.add-to-cart-btn {
  background-color: var(--color-black);
  color: var(--color-white);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.75rem;
  transition: all 0.4s var(--ease-out-expo);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--color-black);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
}

@media (min-width: 768px) {
  .add-to-cart-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.875rem;
    gap: 6px;
  }
}

.add-to-cart-btn:hover {
  background-color: var(--color-accent);
  color: var(--color-black);
  transform: translateY(-3px) rotate(-1deg) scale(1.02);
  box-shadow: 0 6px 15px rgba(212, 175, 55, 0.4);
  border-color: var(--color-accent);
}

.add-to-cart-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.add-to-cart-btn:hover::before {
  animation: goldSweep 1s infinite;
}

/* ==========================================================================
   Components: Inputs & Forms
   ========================================================================== */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--color-white);
  border: 3px solid var(--color-text);
  border-radius: 25px;
  padding: 0 1.25rem;
  width: 100%;
  max-width: 400px;
  min-height: 48px;
  box-sizing: border-box;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.search-bar:focus-within {
  border-color: var(--color-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 0 var(--color-accent);
}

.search-bar input {
  border: none;
  outline: none;
  padding: 0.5rem 0;
  flex: 1;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  background: transparent;
}

.filter-chip {
  min-height: 40px;
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 24px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  transition: all 0.3s ease;
  cursor: pointer;
  font-size: 0.875rem;
  position: relative;
  z-index: 2;
  flex: 1;
}

@media (min-width: 480px) {
  .filter-chip {
    padding: 0.5rem 1.75rem;
    font-size: 0.95rem;
  }
}

@media (min-width: 768px) {
  .filter-chip {
    min-height: 44px;
    padding: 0.5rem 2rem;
  }
}

.filter-chip.active {
  color: var(--color-white);
  background: transparent;
  border: none;
  box-shadow: none;
  transform: none;
}

.filter-chip:hover:not(.active) {
  color: var(--color-accent);
  background: rgba(0, 0, 0, 0.05);
}

.sort-select, .pagination-select {
  appearance: none;
  background-color: var(--color-white);
  border: 3px solid var(--color-text);
  border-radius: 12px;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  min-height: 48px;
  min-width: 140px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sort-select:hover, .pagination-select:hover,
.sort-select:focus, .pagination-select:focus {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 var(--color-text);
}

/* ==========================================================================
   Components: Pagination
   ========================================================================== */
.pagination-footer {
  margin-top: var(--spacing-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  width: 100%;
}

.pagination-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-white);
  padding: 0.75rem;
  border: 3px solid var(--color-text);
  box-shadow: 4px 4px 0 var(--color-text);
  border-radius: 12px;
  flex-wrap: nowrap;
  justify-content: center;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  padding: 0.25rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.page-numbers::-webkit-scrollbar {
  display: none;
}

@media (min-width: 768px) {
  .pagination-wrapper {
    gap: var(--spacing-sm);
    padding: 0.6rem;
    box-shadow: 6px 6px 0 var(--color-text);
  }
}

.pagination-btn, .page-number {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-text);
  background: var(--color-bg);
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border-radius: 8px;
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .pagination-btn, .page-number {
    width: 44px;
    height: 44px;
    border-width: 3px;
    font-size: 1rem;
  }
}

.page-number.active {
  background: var(--color-black);
  color: var(--color-white);
  border-color: var(--color-black);
  box-shadow: 0 4px 0 var(--color-accent);
}

/* ==========================================================================
   Components: Modals
   ========================================================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal.hidden {
  display: none !important;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: saturate(160%) blur(4px);
  -webkit-backdrop-filter: saturate(160%) blur(4px);
}

.modal-content {
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  position: relative;
  z-index: 2501;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border-radius: 16px;
  transform: scale(0.95) translateY(20px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  background: var(--color-bg);
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.close-btn-round {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-black);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 2510;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.close-btn-round:hover {
  background: var(--color-white);
  transform: scale(1.1);
}

@media (min-width: 768px) {
  .close-btn-round {
    top: 1.5rem;
    right: 1.5rem;
  }
}

.product-detail-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

@media (min-width: 768px) {
  .product-detail-layout {
    display: grid;
    grid-template-columns: 50% 50%;
    gap: 0;
    align-items: stretch;
    min-height: 500px;
  }
}

.detail-image-wrapper {
  width: 100%;
  height: 300px;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid #e5e5e5; /* Frame for mobile */
}

@media (min-width: 768px) {
  .detail-image-wrapper {
    height: 100%;
    border-radius: 16px 0 0 16px;
    border-bottom: none;
    border-right: 1px solid #e5e5e5; /* Frame for desktop */
  }
}

.detail-image {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Using contain to ensure whole product is visible, but on a nice background */
  padding: 1rem; /* Add some padding so it's not edge-to-edge if contained */
  transition: transform 0.5s ease;
}

.detail-image:hover {
  transform: scale(1.1);
}

.detail-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

@media (min-width: 768px) {
  .detail-info {
    padding: 48px;
  }
}

.detail-category {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.detail-info h2 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

@media (min-width: 768px) {
  .detail-info h2 {
    font-size: 40px;
  }
}

.detail-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 1.5rem;
  display: block;
}

@media (min-width: 768px) {
  .detail-price {
    font-size: 28px;
  }
}

.detail-description {
  color: var(--color-text-light);
  line-height: 1.6;
  font-size: 1rem;
  margin-bottom: 2.5rem;
}

.detail-quantity-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.detail-quantity-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  background: transparent;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-quantity-btn:hover {
  background: #f5f5f5;
  border-color: #d4d4d4;
}

.detail-quantity-val {
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

.detail-info .btn {
  width: 100%;
  height: 56px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.detail-info .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Out of Stock Styling */
.product-card.out-of-stock {
  opacity: 0.8;
}

.stock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.stock-overlay span {
  background: var(--color-error, #ef4444);
  color: white;
  padding: 0.5rem 1rem;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.9rem;
  transform: rotate(-5deg);
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.stock-overlay-detail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-lg);
}

.stock-overlay-detail span {
  background: var(--color-error, #ef4444);
  color: white;
  padding: 1rem 2rem;
  font-weight: 900;
  text-transform: uppercase;
  font-size: 1.5rem;
  transform: rotate(-5deg);
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.stock-warning {
  color: var(--color-error, #ef4444);
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Ensure disabled buttons look correct */
.add-to-cart-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  background-color: #ccc !important;
  border-color: #ccc !important;
  color: #666 !important;
}

.opacity-50 {
  opacity: 0.5;
  pointer-events: none;
}
