/**
 * Beauty Skin Routine Builder - Frontend Styles
 * 
 * Design matching reference screenshot with brand colors #ff5000 and #1d2d8f
 */

:root {
  /* Brand Colors */
  --bsrb-primary: #ff5000;
  --bsrb-primary-light: #ff7333;
  --bsrb-primary-dark: #cc4000;
  --bsrb-secondary: #1d2d8f;
  --bsrb-secondary-light: #3d4daf;
  --bsrb-secondary-dark: #061541;

  /* Neutrals */
  --bsrb-white: #ffffff;
  --bsrb-bg-light: #f8f9fa;
  --bsrb-text: #2c2c2c;
  --bsrb-text-light: #6c757d;
  --bsrb-border: #e0e0e0;
  --bsrb-badge-green: #4caf50;

  /* Shadows */
  --bsrb-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --bsrb-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --bsrb-transition: all 0.3s ease;
}

/* ========== Main Container ========== */
.bsrb-builder {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========== Header Section ========== */
.bsrb-header {
  text-align: center;
  margin-bottom: 32px;
}

.bsrb-title {
  font-size: 2.2rem;
  font-weight: 400;
  color: var(--bsrb-text);
  margin: 0;
  line-height: 1.4;
}

.bsrb-title-highlight {
  background: #fff9e6;
  padding: 0 8px;
  font-weight: 600;
}

/* ========== 2-Column Layout ========== */
.bsrb-layout {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

/* ========== Left: Bundle Preview ========== */
.bsrb-bundle-preview {
  width: 45%;
  flex-shrink: 0;
}

/* Steps */
.bsrb-steps {
  margin-bottom: 24px;
}

.bsrb-step {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  color: var(--bsrb-text);
}

.bsrb-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--bsrb-white);
  border: 2px solid var(--bsrb-text);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Product Grid */
.bsrb-grid-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--bsrb-bg-light);
  border-radius: 8px;
}

.bsrb-placeholder {
  aspect-ratio: 0.75;
  background: #e8c4a3;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #d4a076;
  transition: var(--bsrb-transition);
}

.bsrb-placeholder.filled {
  background: var(--bsrb-white);
  border: 2px solid var(--bsrb-primary);
  overflow: hidden;
}

.bsrb-placeholder.filled img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bsrb-placeholder-icon svg {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
}

.bsrb-placeholder p {
  font-size: 0.8rem;
  margin: 0;
  font-weight: 500;
}

/* Bundle Message */
.bsrb-bundle-message {
  text-align: center;
  padding: 16px;
  background: var(--bsrb-bg-light);
  border-radius: 8px;
  margin-bottom: 20px;
}

.bsrb-bundle-message p {
  margin: 0;
  color: var(--bsrb-text);
  font-size: 0.95rem;
}

/* Pricing */
.bsrb-pricing {
  background: var(--bsrb-white);
  border: 1px solid var(--bsrb-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.bsrb-price-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.bsrb-price-row:last-child {
  margin-bottom: 0;
}

.bsrb-final-row {
  font-size: 1.2rem;
  font-weight: 700;
  padding-top: 12px;
  border-top: 1px solid var(--bsrb-border);
  color: var(--bsrb-primary);
}

/* Buttons */
.bsrb-add-to-cart {
  width: 100%;
  padding: 14px 24px;
  background: var(--bsrb-primary);
  color: var(--bsrb-white);
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--bsrb-transition);
  margin-bottom: 12px;
  text-transform: none;
}

.bsrb-add-to-cart:hover:not(:disabled) {
  background: var(--bsrb-primary-dark);
}

.bsrb-add-to-cart:disabled {
  background: var(--bsrb-border);
  color: var(--bsrb-text-light);
  cursor: not-allowed;
  opacity: 0.7;
}

.bsrb-add-to-cart.loading {
  position: relative;
  color: transparent;
}

.bsrb-add-to-cart.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 3px solid var(--bsrb-white);
  border-radius: 50%;
  border-top-color: transparent;
  animation: bsrb-spinner 0.8s linear infinite;
}

@keyframes bsrb-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Message */
.bsrb-message {
  padding: 12px;
  border-radius: 4px;
  text-align: center;
  font-size: 0.9rem;
}

.bsrb-message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.bsrb-message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* ========== Right: Products List ========== */
.bsrb-products-list {
  width: 55%;
  flex-grow: 1;
}

/* Products Header */
.bsrb-products-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.bsrb-products-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--bsrb-text);
}

.bsrb-counter {
  background: var(--bsrb-bg-light);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bsrb-text);
}

.bsrb-counter-current {
  color: var(--bsrb-primary);
}

/* Products Scroll */
.bsrb-products-scroll {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 8px;
}

.bsrb-products-scroll::-webkit-scrollbar {
  width: 6px;
}

.bsrb-products-scroll::-webkit-scrollbar-track {
  background: var(--bsrb-bg-light);
}

.bsrb-products-scroll::-webkit-scrollbar-thumb {
  background: var(--bsrb-border);
  border-radius: 10px;
}

/* Product Item (Horizontal Card) */
.bsrb-product-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bsrb-white);
  border: 1px solid var(--bsrb-border);
  border-radius: 8px;
  margin-bottom: 16px;
  transition: var(--bsrb-transition);
}

.bsrb-product-item:hover {
  box-shadow: var(--bsrb-shadow-md);
}

.bsrb-product-item.selected {
  border-color: var(--bsrb-primary);
  background: #fff8f5;
}

/* Product Image */
.bsrb-product-image-wrapper {
  width: 80px;
  height: auto;
  min-height: 80px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bsrb-bg-light);
}

.bsrb-product-image-wrapper img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Product Details */
.bsrb-product-details {
  flex: 1;
  min-width: 0;
}

.bsrb-product-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--bsrb-text);
  margin: 0 0 6px 0;
}

.bsrb-product-description {
  font-size: 0.85rem;
  color: var(--bsrb-text-light);
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.bsrb-product-price-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bsrb-product-price-old {
  font-size: 0.9rem;
  color: var(--bsrb-text-light);
  text-decoration: line-through;
}

.bsrb-product-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bsrb-text);
}

/* Add Button */
.bsrb-add-btn {
  padding: 10px 20px;
  background: var(--bsrb-white);
  color: var(--bsrb-text);
  border: 2px solid var(--bsrb-text);
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--bsrb-transition);
  white-space: nowrap;
}

.bsrb-add-btn:hover {
  background: var(--bsrb-secondary);
  color: var(--bsrb-white);
  border-color: var(--bsrb-secondary);
}

.bsrb-product-item.selected .bsrb-add-btn {
  background: var(--bsrb-primary);
  color: var(--bsrb-white);
  border-color: var(--bsrb-primary);
}

.bsrb-product-item.selected .bsrb-add-btn:hover {
  background: var(--bsrb-primary-dark);
  border-color: var(--bsrb-primary-dark);
}

/* Product Actions Container */
.bsrb-product-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Quantity Controls */
.bsrb-quantity-controls {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--bsrb-bg-light);
  border-radius: 8px;
  padding: 4px;
}

.bsrb-qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bsrb-white);
  color: var(--bsrb-text);
  border-radius: 6px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--bsrb-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.bsrb-qty-btn:hover {
  background: var(--bsrb-primary);
  color: var(--bsrb-white);
}

.bsrb-qty-value {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--bsrb-text);
}

/* Grid Quantity Badge */
.bsrb-grid-qty-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--bsrb-primary);
  color: var(--bsrb-white);
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.bsrb-placeholder.filled {
  position: relative;
}

/* ========== Responsive Design ========== */

/* Tablet: 768px - 1024px */
@media (max-width: 1024px) and (min-width: 769px) {
  .bsrb-layout {
    gap: 24px;
  }

  .bsrb-bundle-preview {
    width: 40%;
  }

  .bsrb-products-list {
    width: 60%;
  }

  .bsrb-grid-container {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
  }
}

/* Mobile Layout: < 768px */
@media (max-width: 768px) {
  .bsrb-layout {
    flex-direction: column;
    gap: 0;
  }

  /* BUNDLE PREVIEW - COMPACT (No Sticky) */
  .bsrb-bundle-preview {
    position: relative;
    /* Reset to relative */
    top: auto;
    z-index: auto;
    background: white;
    border: none;
    /* Remove border if not sticky, or keep it subtle? Let's remove to blend in */
    border-bottom: 1px solid var(--bsrb-border);
    padding: 0 0 16px 0;
    /* Remove horizontal padding to align with products */
    margin: 0 0 16px 0;
    /* Reset negative margins to center it */
    box-shadow: none;
  }

  .bsrb-bundle-preview,
  .bsrb-products-list {
    width: 100% !important;
  }

  /* Hide steps on mobile */
  .bsrb-steps {
    display: none;
  }

  /* Compact grid */
  .bsrb-grid-container {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px;
    margin-bottom: 8px;
  }

  .bsrb-placeholder {
    aspect-ratio: 0.7;
  }

  .bsrb-placeholder p {
    font-size: 0.7rem;
  }

  .bsrb-placeholder-icon svg {
    width: 20px;
    height: 20px;
    margin-bottom: 4px;
  }

  /* Compact pricing */
  .bsrb-pricing {
    padding: 12px;
    margin-bottom: 8px;
  }

  .bsrb-price-row {
    font-size: 0.85rem;
    margin-bottom: 6px;
  }

  .bsrb-final-row {
    font-size: 1.1rem;
    padding-top: 8px;
  }

  /* Compact Add to Cart button */
  .bsrb-add-to-cart {
    padding: 12px 20px;
    font-size: 0.95rem;
    margin-bottom: 0;
  }

  .bsrb-bundle-message {
    padding: 10px;
    margin-bottom: 8px;
    font-size: 0.85rem;
  }

  /* PRODUCTS LIST - NO MAX HEIGHT */
  .bsrb-products-scroll {
    max-height: none !important;
    overflow-y: visible;
    padding-right: 0;
  }

  /* PRODUCT CARDS - MORE COMPACT */
  .bsrb-product-item {
    flex-direction: row !important;
    text-align: left;
    padding: 12px;
    gap: 12px;
    margin-bottom: 12px;
  }

  .bsrb-product-image-wrapper {
    width: 70px !important;
    min-height: 70px;
    height: auto !important;
    aspect-ratio: 1;
  }

  .bsrb-product-name {
    font-size: 0.9rem;
    margin-bottom: 4px;
  }

  .bsrb-product-description {
    font-size: 0.8rem;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .bsrb-product-price {
    font-size: 0.95rem;
  }

  .bsrb-add-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    white-space: nowrap;
    align-self: center;
  }

  /* Quantity controls mobile */
  .bsrb-quantity-controls {
    padding: 2px;
    gap: 4px;
  }

  .bsrb-qty-btn {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }

  .bsrb-qty-value {
    min-width: 24px;
    font-size: 0.9rem;
  }

  .bsrb-grid-qty-badge {
    min-width: 16px;
    height: 16px;
    font-size: 0.65rem;
    top: 2px;
    right: 2px;
  }

  /* Title adjustments */
  .bsrb-title {
    font-size: 1.6rem;
  }

  .bsrb-products-header h3 {
    font-size: 1rem;
  }

  .bsrb-counter {
    font-size: 0.85rem;
    padding: 4px 12px;
  }
}

/* Very small mobile */
@media (max-width: 480px) {
  .bsrb-builder {
    padding: 20px 12px;
  }

  .bsrb-title {
    font-size: 1.4rem;
  }

  .bsrb-grid-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 6px;
  }

  .bsrb-product-image-wrapper {
    width: 60px !important;
    min-height: 60px;
  }
}