/* Estimate Builder - Theme-Integrated CSS */
/* Layout and positioning styles - visual styling comes from theme */

:root {
  /* Button colors are injected by proxy only when merchant sets them */
  --eb-border-radius: var(--buttons-radius, var(--inputs-radius, 8px));
  --eb-spacing-xs: 4px;
  --eb-spacing-sm: 8px;
  --eb-spacing-md: 16px;
  --eb-spacing-lg: 24px;
  --eb-spacing-xl: 32px;
  --eb-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --eb-shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
  --eb-transition: 0.2s ease;
  --eb-border-color: rgba(0, 0, 0, 0.1);
  --eb-color-drawer-bg: #ffffff;
}

/* Container - inherit theme typography, self-contained width for full-width themes */
.eb-container {
  max-width: var(--eb-container-max-width, 1400px);
  margin-left: auto;
  margin-right: auto;
  padding: var(--eb-spacing-lg) var(--eb-spacing-md);
  padding-bottom: 100px; /* Space for collapsed drawer */
}

.eb-container * {
  box-sizing: border-box;
}

/* Loading State */
.eb-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.eb-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--eb-border-color);
  border-top-color: var(--eb-color-add-to-selection, currentColor);
  border-radius: 50%;
  animation: eb-spin 0.8s linear infinite;
}

@keyframes eb-spin {
  to { transform: rotate(360deg); }
}

/* Button loading state */
.eb-btn--loading {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: wait;
}

.eb-btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: eb-spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Header */
.eb-header {
  margin-bottom: var(--eb-spacing-lg);
}

.eb-title {
  margin: 0 0 var(--eb-spacing-md);
  font-size: var(--eb-font-size-page-title, 2rem);
}

/* Search and Filters */
.eb-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--eb-spacing-md);
  margin-bottom: var(--eb-spacing-lg);
}

.eb-search {
  flex: 1;
  min-width: 250px;
}

.eb-search-input {
  width: 100%;
  padding: var(--eb-spacing-sm) var(--eb-spacing-md);
  font-size: 16px;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  outline: none;
}

.eb-search-input:focus {
  border-color: currentColor;
}

.eb-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--eb-spacing-sm);
}

.eb-filter-select {
  padding: var(--eb-spacing-sm) var(--eb-spacing-md);
  font-size: 14px;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  background: transparent;
  cursor: pointer;
}

.eb-filter-select:focus {
  border-color: currentColor;
}

/* Tabs */
.eb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--eb-spacing-sm);
  margin-bottom: var(--eb-spacing-lg);
}

.eb-tab {
  padding: var(--eb-spacing-sm) var(--eb-spacing-md);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  cursor: pointer;
  transition: all var(--eb-transition);
}

.eb-tab:hover {
  background: rgba(0, 0, 0, 0.05);
}

.eb-tab.eb-tab--active {
  background: #000;
  color: #fff;
  border-color: #000;
}

/* Product Grid - Mobile first */
.eb-products {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--eb-spacing-md);
}

@media (min-width: 576px) {
  .eb-products {
    grid-template-columns: repeat(2, 1fr);
  }

  .eb-drawer-actions {
    gap: var(--eb-spacing-lg);
  }
}

@media (min-width: 768px) {
  .eb-products {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--eb-spacing-lg);
  }
}

@media (min-width: 1024px) {
  .eb-products {
    grid-template-columns: repeat(4, 1fr);
  }

  .eb-contact-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--eb-spacing-md);
  }
}

/* Product Card */
.eb-product {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  overflow: hidden;
  transition: box-shadow var(--eb-transition), opacity var(--eb-transition);
}

.eb-product:hover {
  box-shadow: var(--eb-shadow);
}

.eb-product-image {
  aspect-ratio: 1;
  overflow: hidden;
}

.eb-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eb-product-image-placeholder {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  background: #f5f5f5;
}

.eb-product-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--eb-spacing-md);
}

.eb-product-title {
  font-weight: 600;
  font-size: var(--eb-font-size-product-title, 1rem);
  margin: 0 0 var(--eb-spacing-xs);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.eb-product-price {
  font-weight: 600;
  margin-bottom: var(--eb-spacing-sm);
}

.eb-product-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--eb-spacing-sm);
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: var(--eb-spacing-sm);
}

.eb-product-meta-left,
.eb-product-meta-right {
  display: flex;
  flex-direction: column;
}

.eb-product-meta-right {
  text-align: right;
}

.eb-out-of-stock {
  color: #dc2626;
  opacity: 1;
}

.eb-partially-in-stock {
  color: #d97706;
  opacity: 1;
}

.eb-product-variant {
  margin-top: auto;
  margin-bottom: var(--eb-spacing-md);
}

/* Push quantity to bottom when no variant picker exists */
.eb-product-content:not(:has(.eb-product-variant)) .eb-product-quantity {
  margin-top: auto;
}

.eb-variant-select {
  width: 100%;
  padding: var(--eb-spacing-sm);
  font-size: 14px;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  background: transparent;
}

.eb-product-quantity {
  display: flex;
  align-items: center;
  gap: var(--eb-spacing-sm);
  margin-bottom: var(--eb-spacing-md);
}

.eb-qty-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  background: transparent;
  cursor: pointer;
  transition: all var(--eb-transition);
}

.eb-qty-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

.eb-qty-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.eb-qty-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: var(--eb-spacing-xs);
  font-size: 16px;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
}

/* Add Button - uses theme button class, fallback styles below */
.eb-add-btn {
  width: 100%;
  padding: var(--eb-spacing-sm) var(--eb-spacing-md);
  cursor: pointer;
}

.eb-add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.eb-add-btn.eb-add-btn--added {
  background: #28a745 !important;
  border-color: #28a745 !important;
  color: white !important;
}

/* Pagination */
.eb-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--eb-spacing-md);
  margin-top: var(--eb-spacing-xl);
}

.eb-load-more {
  padding: var(--eb-spacing-md) var(--eb-spacing-xl);
  cursor: pointer;
}

.eb-load-more:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.eb-page-numbers {
  display: flex;
  gap: var(--eb-spacing-xs);
}

.eb-page-btn {
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  background: transparent;
  cursor: pointer;
  transition: all var(--eb-transition);
}

.eb-page-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.eb-page-btn.eb-page-btn--active {
  background: var(--eb-color-add-to-selection, currentColor);
  color: white;
  border-color: var(--eb-color-add-to-selection, currentColor);
}

.eb-page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.eb-page-btn:disabled:hover {
  background: transparent;
}

.eb-pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--eb-spacing-lg);
}

.eb-page-link {
  color: inherit;
  text-decoration: none;
  font-size: 0.95rem;
  transition: opacity var(--eb-transition);
}

.eb-page-link:hover {
  text-decoration: underline;
}

.eb-page-link--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: auto;
}

.eb-page-info {
  font-size: 0.95rem;
  color: var(--eb-text-muted);
  min-width: 80px;
  text-align: center;
}

/* No Results */
.eb-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--eb-spacing-xl);
  opacity: 0.7;
}

/* Skeleton Loading */
.eb-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: eb-shimmer 1.5s infinite;
  border-radius: var(--eb-border-radius);
}

@keyframes eb-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.eb-skeleton-image {
  aspect-ratio: 1;
}

.eb-skeleton-text {
  height: 1rem;
  margin-bottom: var(--eb-spacing-sm);
}

.eb-skeleton-text.eb-skeleton-text--short {
  width: 60%;
}

/* Bottom Drawer */
.eb-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--eb-color-drawer-bg);
  box-shadow: var(--eb-shadow-lg);
  z-index: 1000;
  transform: translateY(calc(100% - 60px));
  transition: transform 0.3s ease;
}

.eb-drawer.eb-drawer--open {
  transform: translateY(0);
}

.eb-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--eb-spacing-md) var(--eb-spacing-lg);
  border-bottom: 1px solid var(--eb-border-color);
  cursor: pointer;
}

.eb-drawer-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--eb-spacing-sm);
}

.eb-drawer-summary {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.8;
}

.eb-drawer-right {
  display: flex;
  align-items: center;
  gap: var(--eb-spacing-sm);
}

.eb-drawer-cta {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.8;
}

.eb-drawer-toggle {
  font-size: 1.5rem;
  opacity: 0.6;
  transition: transform var(--eb-transition);
}

.eb-drawer.eb-drawer--open .eb-drawer-toggle {
  transform: rotate(180deg);
}

.eb-drawer-content {
  max-height: 50vh;
  overflow-y: auto;
  padding: var(--eb-spacing-md) var(--eb-spacing-lg);
}

.eb-drawer-empty {
  text-align: center;
  padding: var(--eb-spacing-xl);
  opacity: 0.6;
}

/* Drawer Items */
.eb-drawer-items {
  display: flex;
  flex-direction: column;
  gap: var(--eb-spacing-md);
}

.eb-drawer-item {
  display: flex;
  gap: var(--eb-spacing-md);
  padding: var(--eb-spacing-md);
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--eb-border-radius);
}

.eb-drawer-item-image {
  width: 60px;
  height: 60px;
  border-radius: var(--eb-border-radius);
  overflow: hidden;
  flex-shrink: 0;
}

.eb-drawer-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eb-drawer-item-details {
  flex: 1;
  min-width: 0;
}

.eb-drawer-item-title {
  font-weight: 600;
  margin-bottom: var(--eb-spacing-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eb-drawer-item-meta {
  display: flex;
  align-items: center;
  gap: var(--eb-spacing-sm);
  margin-bottom: var(--eb-spacing-xs);
}

.eb-drawer-item-variant {
  font-size: 0.85rem;
  opacity: 0.7;
}

.eb-drawer-item-controls {
  display: flex;
  align-items: center;
  gap: var(--eb-spacing-sm);
}

.eb-drawer-item-price {
  font-weight: 600;
  margin-left: auto;
}

.eb-drawer-item-remove {
  font-size: 0.85rem;
  color: #dc3545;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--eb-spacing-xs);
}

.eb-drawer-item-remove:hover {
  text-decoration: underline;
}

/* Drawer Shipping */
.eb-drawer-shipping {
  padding: var(--eb-spacing-md) 0;
  border-top: 1px solid var(--eb-border-color);
  margin-top: var(--eb-spacing-md);
}

.eb-drawer-shipping label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: var(--eb-spacing-sm);
}

.eb-shipping-select {
  width: 100%;
  padding: var(--eb-spacing-sm);
  font-size: 16px;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
}

.eb-shipping-quote-message {
  font-size: 0.9rem;
  color: var(--eb-text-muted, #666);
  font-style: italic;
}

.eb-shipping-tbd {
  font-style: italic;
  color: var(--eb-text-muted, #666);
}

/* Drawer Totals */
.eb-drawer-totals {
  padding: var(--eb-spacing-md) 0;
  border-top: 1px solid var(--eb-border-color);
}

.eb-drawer-total-row {
  display: flex;
  justify-content: space-between;
  padding: var(--eb-spacing-xs) 0;
}

.eb-drawer-total-row.eb-drawer-total-row--grand {
  font-size: 1.1rem;
  font-weight: 700;
  padding-top: var(--eb-spacing-sm);
  border-top: 1px solid var(--eb-border-color);
  margin-top: var(--eb-spacing-sm);
}

/* Drawer Actions */
.eb-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--eb-spacing-sm);
  padding: var(--eb-spacing-md) var(--eb-spacing-lg);
  border-top: 1px solid var(--eb-border-color);
}

.eb-action-btn {
  flex: 1;
  min-width: 140px;
  max-width: 310px;
  padding: var(--eb-spacing-md);
  font-weight: 600;
  cursor: pointer;
}

.eb-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modal */
.eb-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--eb-transition);
}

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

.eb-modal {
  background: var(--eb-color-drawer-bg);
  border-radius: var(--eb-border-radius);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--eb-transition);
}

.eb-modal-overlay.eb-modal--open .eb-modal {
  transform: translateY(0);
}

@media (min-width: 1024px) {
  .eb-modal {
    max-width: 700px;
  }
}

.eb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--eb-spacing-lg);
  border-bottom: 1px solid var(--eb-border-color);
}

.eb-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.eb-modal-close {
  font-size: 1.5rem;
  opacity: 0.6;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--eb-spacing-xs);
  line-height: 1;
}

.eb-modal-body {
  padding: var(--eb-spacing-lg);
}

.eb-form-group {
  margin-bottom: var(--eb-spacing-md);
}

.eb-form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: var(--eb-spacing-xs);
}

.eb-form-label .eb-required {
  color: #dc3545;
}

.eb-form-hint {
  display: block;
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: var(--eb-spacing-xs);
}

.eb-form-input,
.eb-form-textarea {
  width: 100%;
  padding: var(--eb-spacing-sm) var(--eb-spacing-md);
  font-size: 16px;
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  outline: none;
  transition: border-color var(--eb-transition);
}

.eb-form-input::placeholder,
.eb-form-textarea::placeholder {
  color: #9ca3af;
  opacity: 1;
}

.eb-form-input:focus,
.eb-form-textarea:focus {
  border-color: currentColor;
}

.eb-form-textarea {
  min-height: 80px;
  resize: vertical;
}

.eb-form-error {
  color: #dc3545;
  font-size: 0.85rem;
  margin-top: var(--eb-spacing-xs);
}

.eb-form-input--error,
.eb-form-textarea--error {
  border-color: #dc3545;
}

.eb-form-input--error:focus,
.eb-form-textarea--error:focus {
  border-color: #dc3545;
  outline-color: #dc3545;
}

.eb-form-checkbox-group {
  margin-top: var(--eb-spacing-md);
}

.eb-form-checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--eb-spacing-sm);
  cursor: pointer;
  font-size: 0.875rem;
}

.eb-form-checkbox {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: currentColor;
}

.eb-address-fieldset {
  border: 1px solid var(--eb-border-color);
  border-radius: var(--eb-border-radius);
  padding: var(--eb-spacing-md);
  margin: var(--eb-spacing-md) 0;
}

.eb-address-legend {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0 var(--eb-spacing-sm);
}

.eb-form-row {
  display: flex;
  gap: var(--eb-spacing-sm);
}

.eb-form-group--half {
  flex: 1;
}

.eb-billing-fields {
  margin-top: var(--eb-spacing-md);
}

/* Login prompt for guests */
.eb-login-prompt {
  background: #f8f9fa;
  padding: var(--eb-spacing-md);
  border-radius: var(--eb-border-radius);
  margin-bottom: var(--eb-spacing-lg);
  text-align: center;
}

.eb-login-prompt p {
  margin: 0;
  font-size: 0.9rem;
}

.eb-login-link {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.eb-login-link:hover {
  text-decoration: none;
}

/* Logged-in notice */
.eb-logged-in-notice {
  background: #d4edda;
  padding: var(--eb-spacing-sm) var(--eb-spacing-md);
  border-radius: var(--eb-border-radius);
  margin-bottom: var(--eb-spacing-lg);
  text-align: center;
  border: 1px solid #c3e6cb;
}

.eb-logged-in-notice p {
  margin: 0;
  font-size: 0.85rem;
  color: #155724;
}

.eb-modal-footer {
  display: flex;
  gap: var(--eb-spacing-sm);
  padding: var(--eb-spacing-lg);
  border-top: 1px solid var(--eb-border-color);
}

.eb-modal-btn {
  flex: 1;
  padding: var(--eb-spacing-md);
  font-weight: 600;
  cursor: pointer;
}

.eb-modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Toast Notification */
.eb-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: var(--eb-spacing-md) var(--eb-spacing-lg);
  border-radius: var(--eb-border-radius);
  box-shadow: var(--eb-shadow-lg);
  z-index: 3000;
  opacity: 0;
  transition: all 0.3s ease;
  background: #333;
  color: white;
}

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

.eb-toast.eb-toast--success {
  background: #28a745;
}

.eb-toast.eb-toast--error {
  background: #dc3545;
}

/* Accessibility */
.eb-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;
}

/* Focus styles */
.eb-container *:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .eb-drawer,
  .eb-modal-overlay {
    display: none;
  }

  .eb-container {
    padding-bottom: 0;
  }
}

/* ==========================================
   FALLBACK BUTTON STYLES
   Only apply if theme doesn't style buttons.
   Uses currentColor as fallback when no custom color is set.
   ========================================== */

/* Fallback for buttons without theme styling */
.eb-add-btn:not(.button):not(.btn) {
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  background: var(--eb-color-add-to-selection, currentColor);
  border: none;
  border-radius: var(--eb-border-radius);
}

.eb-load-more:not(.button):not(.btn) {
  font-size: 1rem;
  font-weight: 600;
  color: var(--eb-color-add-to-selection, currentColor);
  background: transparent;
  border: 2px solid var(--eb-color-add-to-selection, currentColor);
  border-radius: var(--eb-border-radius);
}

.eb-load-more:not(.button):not(.btn):hover {
  background: var(--eb-color-add-to-selection, currentColor);
  color: white;
}

.eb-action-btn:not(.button):not(.btn) {
  font-size: 1rem;
  border: none;
  border-radius: var(--eb-border-radius);
  color: white;
}

.eb-action-btn--cart:not(.button):not(.btn) {
  background: var(--eb-color-add-to-cart, currentColor);
}

.eb-action-btn--estimate:not(.button):not(.btn) {
  background: var(--eb-color-generate-estimate, currentColor);
}

.eb-action-btn--buy:not(.button):not(.btn) {
  background: var(--eb-color-buy-now, currentColor);
}

.eb-modal-btn--cancel:not(.button):not(.btn) {
  background: #f5f5f5;
  border: 1px solid #ddd;
  color: inherit;
}

.eb-modal-btn--submit:not(.button):not(.btn) {
  background: var(--eb-color-generate-estimate, currentColor);
  border: none;
  color: white;
}
