/**
 * Place Order form — shared field styles, popup modal, page card container,
 * and product search dropdown.
 */

/* ==========================================================================
   FORM FIELDS (shared across all three contexts)
   ========================================================================== */

.place-order-form {
  display: flex;
  flex-direction: column;
  gap: 14px; /* Balanced field layout grouping separation gap */
}

.place-order-form__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  width: 100%;
}

/* Structural wrapper container forcing icon & text alignment layers */
.place-order-form__input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

/* Absolute position layer for new SVG elements */
.place-order-form__input-icon {
  position: absolute;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted, #9ca3af);
  pointer-events: none;
  z-index: 2;
  transition: color 0.2s ease;
}

/* Sleek Balanced Input Fields */
.place-order-form__input {
  width: 100% !important;
  height: 44px !important; /* Increased for premium structural clarity */
  border: 1px solid var(--color-border-strong) !important;
  border-radius: var(--radius) !important;
  padding: 0 16px 0 40px !important; /* Left space carved out for SVGs */
  font-family: var(--font-base) !important;
  font-size: 14px !important;
  color: var(--color-text) !important;
  background: var(--color-white) !important;
  box-sizing: border-box !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

/* Native Placeholder color correction */
.place-order-form__input::placeholder {
  color: var(--color-text-muted, #9ca3af);
  opacity: 1;
}

/* Dynamic Interactive focus handling */
.place-order-form__input-wrapper:focus-within .place-order-form__input-icon {
  color: var(--color-primary);
}

.place-order-form__input:focus {
  outline: none !important;
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04) !important;
}

/* Form Submit Wrap actions layout module */
.place-order-form__action-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
  margin-top: 4px;
}

/* Action button profile overrides with share implementation settings */
.place-order-form__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: var(--color-success);
  color: var(--color-white);
  font-family: var(--font-base);
  font-size: 14px;
  font-weight: 600;
  height: 44px; /* Matching increased input vertical metrics */
  padding: 0 24px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.place-order-form__submit:hover {
  background: var(--color-success-hover);
}

.place-order-form__submit:active {
  transform: scale(0.99);
}

.place-order-form__submit-icon {
  flex-shrink: 0;
  display: inline-block;
}

.place-order-form__submit:disabled {
  background: var(--color-border-strong);
  cursor: not-allowed;
}

/* Clean WhatsApp info tag typography beneath the submission loop */
.place-order-form__whatsapp-notice {
  font-family: var(--font-base);
  font-size: 12px;
  color: var(--color-text-muted, #6b7280);
  text-align: center;
  margin: 0;
  line-height: 1.4;
  font-weight: 500;
}

.place-order-form__message {
  font-family: var(--font-base);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius);
  display: none;
}

.place-order-form__message--info {
  display: block;
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.place-order-form__message--success {
  display: block;
  background: rgba(4, 161, 43, 0.1);
  color: var(--color-success);
}

.place-order-form__message--error {
  display: block;
  background: rgba(220, 53, 69, 0.08);
  color: #dc3545;
}

/* ==========================================================================
   PRE-FILLED PRODUCT (product page popup context)
   ========================================================================== */

.place-order-form__prefilled-product {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 10px;
}

.place-order-form__prefilled-product img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.place-order-form__prefilled-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.place-order-form__prefilled-name {
  font-family: var(--font-base);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.place-order-form__prefilled-price {
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--color-success);
  font-weight: 700;
}

/* ==========================================================================
   PRODUCT SEARCH (searchable mode — homepage popup + Place Order page)
   ========================================================================== */

.place-order-form__product-search {
  position: relative;
  width: 100%;
}

.place-order-form__search-input {
  width: 100% !important;
  height: 44px !important; /* Unified expanded footprint metrics */
  border: 1px solid var(--color-border-strong) !important;
  border-radius: var(--radius) !important;
  padding: 0 16px 0 40px !important; /* Left space carved out for SVGs */
  font-family: var(--font-base) !important;
  font-size: 14px !important;
  color: var(--color-text) !important;
  background: var(--color-white) !important;
  box-sizing: border-box !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.place-order-form__search-input::placeholder {
  color: var(--color-text-muted, #9ca3af);
  opacity: 1;
}

.place-order-form__search-input:focus {
  outline: none !important;
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04) !important;
}

.place-order-form__search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), inset -8px 0 0 var(--color-white);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  padding: 8px 14px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-success) var(--color-bg);
  scrollbar-gutter: stable;
  box-sizing: border-box;
}

.place-order-form__search-results::-webkit-scrollbar {
  width: 6px;
}

.place-order-form__search-results::-webkit-scrollbar-track {
  background: var(--color-bg);
  border-radius: 999px;
}

.place-order-form__search-results::-webkit-scrollbar-thumb {
  background-color: var(--color-success);
  border-radius: 999px;
}

.place-order-form__search-results::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-success-hover);
}

.place-order-form__search-results[hidden] {
  display: none !important;
}

.place-order-form__search-loading {
  width: 100%;
  padding: 18px 12px;
  text-align: center;
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--color-text-muted);
}

.place-order-form__search-loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: place-order-spinner 0.8s linear infinite;
}

@keyframes place-order-spinner {
  to { transform: rotate(360deg); }
}

.place-order-form__search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.place-order-form__search-item:hover {
  background: var(--color-bg);
}

.place-order-form__search-item img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.place-order-form__search-item-name {
  flex: 1 1 auto;
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--color-text);
}

.place-order-form__search-item-price {
  font-family: var(--font-base);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-success);
  white-space: nowrap;
}

.place-order-form__search-empty {
  padding: 16px;
  text-align: center;
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--color-text-muted);
}

.place-order-form__selected-product {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 8px;
  margin-top: 4px;
}

.place-order-form__selected-product[hidden] {
  display: none !important;
}

.place-order-form__selected-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}

.place-order-form__selected-name {
  flex: 1 1 auto;
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--color-text);
}

.place-order-form__selected-clear {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
}

.place-order-form__selected-clear:hover {
  color: var(--color-text);
}

/* ==========================================================================
   POPUP MODAL (with Reveal Smooth CSS Entrance Animation Keyframe)
   ========================================================================== */

.place-order-popup[hidden] {
  display: none;
}

.place-order-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.place-order-popup__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px); /* Premium background structural smoothing */
  animation: sleekFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.place-order-popup__panel {
  position: relative;
  background: var(--color-white);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  width: min(92vw, 460px);
  max-width: 100%;
  max-height: 90vh;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
  z-index: 1;
  pointer-events: auto;
  
  /* Reveal Animation execution handles */
  opacity: 0;
  transform: scale(0.95) translateY(8px);
  animation: sleekPanelReveal 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.05s;
}

/* Entry Animation Blueprints */
@keyframes sleekFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sleekPanelReveal {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.place-order-popup__content {
  position: relative;
  height: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 28px 24px 24px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(193, 191, 191, 0.25) var(--color-bg);
  scrollbar-gutter: stable;
}

.place-order-popup__content::-webkit-scrollbar {
  width: 8px;
}

.place-order-popup__content::-webkit-scrollbar-track {
  background: var(--color-bg);
  border-radius: 999px;
}

.place-order-popup__content::-webkit-scrollbar-thumb {
  background-color: rgba(128, 128, 128, 0.25);
  border-radius: 999px;
}

.place-order-popup__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  border: 1px solid var(--color-border-strong);
  background: var(--color-white);
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.place-order-popup__close:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-text);
}

.place-order-form__category-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.place-order-form__category-badges::-webkit-scrollbar {
  height: 4px;
}

.place-order-form__category-badges::-webkit-scrollbar-track {
  background: transparent;
}

.place-order-form__category-badges::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
}

.place-order-form__category-badge {
  border: 1px solid var(--color-border-strong);
  background: var(--color-white);
  color: var(--color-text);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: var(--font-base);
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.place-order-form__category-badge:hover,
.place-order-form__category-badge--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-white);
}

.place-order-popup__title {
  font-family: var(--font-base);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 16px;
  padding-right: 32px;
}

body.place-order-popup-open {
  overflow: hidden;
}

/* ==========================================================================
   PLACE ORDER PAGE — card container around the embedded form
   ========================================================================== */

.place-order-page-wrapper {
  max-width: 460px;
  margin: 40px auto;
  background: var(--color-white);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  padding: 24px;
}

@media (max-width: 600px) {
  .place-order-page-wrapper {
    margin: 20px auto;
    padding: 20px;
    border-radius: 12px;
  }

  .place-order-popup__panel {
    padding: 0;
  }
}


/* ==========================================================================
   NEW ADDITIONS: Readonly Input & Checkbox Styles
   ========================================================================== */

/* Visual cue for the locked email field */
.place-order-form__input[readonly] {
  background-color: rgba(0, 0, 0, 0.04) !important;
  color: var(--color-text-muted, #9ca3af) !important;
  cursor: not-allowed;
}

.place-order-form__input[readonly]:focus {
  border-color: var(--color-border-strong) !important;
  box-shadow: none !important;
}

/* Layout for the Terms of Service Checkbox */
.place-order-form__field--checkbox {
  flex-direction: row;
  align-items: center;
  margin-top: 4px;
}

.place-order-form__checkbox-label {
  font-family: var(--font-base);
  font-size: 13px;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  line-height: 1.4;
}

.place-order-form__checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary); /* Uses your theme's primary color */
}

.place-order-form__checkbox-label a {
  color: var(--color-primary);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.place-order-form__checkbox-label a:hover {
  color: var(--color-text);
}


/* =========================================================
   PRODUCT + QUANTITY ROW
   ========================================================= */

.place-order-form__product-selection-row,
.place-order-form__product-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
}


/* Product selector */

.place-order-form__product-selector {
    flex: 1 1 auto;
    min-width: 0;
}


/* =========================================================
   GENERIC FORM QUANTITY CONTROL
   ========================================================= */

.place-order-form__quantity-control {
    flex: 0 0 auto;

    display: flex;
    align-items: center;

    height: 48px;

    border: 1px solid #ded9e7;
    border-radius: 10px;

    background: #fff;

    overflow: hidden;
}


.place-order-form__quantity-btn {
    width: 36px;
    height: 100%;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    background: transparent;

    color: #5f526d;

    font-size: 18px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background .2s ease,
        color .2s ease;
}


.place-order-form__quantity-btn:hover {
    background: #f3eef9;
    color: #69449b;
}


.place-order-form__quantity-input {
    width: 42px !important;
    height: 100% !important;

    padding: 0 !important;

    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;

    background: transparent !important;

    color: #242027 !important;

    font-size: 14px !important;
    font-weight: 700 !important;

    text-align: center !important;
}


/* Remove browser spinner */
.place-order-form__quantity-input::-webkit-inner-spin-button,
.place-order-form__quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.place-order-form__quantity-input {
    -moz-appearance: textfield;
}


/* =========================================================
   PRODUCT DETAIL PAGE QUANTITY DISPLAY
   ========================================================= */

.place-order-form__product-quantity-display {
    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: center;

    min-width: 52px;
    padding: 0 10px;

    color: #2b2332;

    font-size: 17px;
    font-weight: 800;
    line-height: 1;
}


.place-order-form__quantity-x {
    font-weight: 800;
}


.place-order-form__quantity-value {
    font-weight: 800;
}


/* Product detail product row */
.place-order-form__product-row {
    align-items: center;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {

    .place-order-form__product-selection-row {
        gap: 7px;
    }

    .place-order-form__quantity-control {
        height: 46px;
    }

    .place-order-form__quantity-btn {
        width: 32px;
    }

    .place-order-form__quantity-input {
        width: 36px !important;
        font-size: 13px !important;
    }

    .place-order-form__product-quantity-display {
        min-width: 46px;
        padding: 0 7px;
        font-size: 15px;
    }

}