/* =========================
   Dish Details (RTL)
   ========================= */

#modal-header-dishDetails {
  background: linear-gradient(to right, black, #431C7C);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#modal-header-dishDetails h2 {
  margin: 0;
  font-size: 25px;
  margin-left: 25px;
}

#close-btn-new-order_details {
  position: absolute;
  left: 16px;
  top: 4%;
  transform: translateY(-50%);
  font-size: 48px;
  font-weight: 300;
  color: #fff;
  cursor: pointer;
  width: 40px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

#close-btn-new-order_details:hover {
  background: rgba(255,255,255,0.15);
}

#DishDetailsPopup {
  display: none;
  position: fixed;
  top: 0%;
  width: 100%;
  height: 100%;
  background-color: white;
  border: 5px solid #431C7C;
  border-radius: 15px;
  box-shadow: 0px 4px 10px rgba(0,0,0,0.2);
  z-index: 9990;
}

#dish-popup-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  height: 80%;
  font-size: 18px;
}

/* =========================
   Segment blocks
   ========================= */

.segment-section {
  margin-bottom: 36px;
}

.segment-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #431C7C;
}

/* =========================
   Buttons grid (stable widths)
   gap = 10px
   3 columns => (100% - 2*gap) / 3
   2 columns => (100% - 1*gap) / 2
   ========================= */

.segment-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 10px;
  direction: rtl;
  margin-bottom: 15px;
}

/* default: 3 per row */
.segment-button {
  flex: 0 0 calc((100% - 20px) / 3);
  box-sizing: border-box;

  border: 1px solid var(--segment-color, #431C7C);
  border-radius: 20px;

  padding: 10px 12px;
  cursor: pointer;
  background-color: #fff;

  color: #111 !important;
  -webkit-text-fill-color: #111;
  -webkit-appearance: none;
  appearance: none;

  transition: all 0.2s ease-in-out;
  font-size: 14px;
  font-family: inherit;

  white-space: normal;
}

.segment-button .seg-label {
  color: #111 !important;
  -webkit-text-fill-color: #111;
}

.segment-button.selected {
  background:
    linear-gradient(
      135deg,
      var(--segment-color, #431C7C) 0%,
      color-mix(in srgb, var(--segment-color, #431C7C) 82%, #000 18%) 100%
    ) !important;

  border-color: color-mix(in srgb, var(--segment-color, #431C7C) 85%, #000 15%) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff;
  font-weight: bold;

  box-shadow:
    0 4px 10px rgba(0,0,0,0.14),
    inset 0 1px 0 rgba(255,255,255,0.16);
}

@supports not (color: color-mix(in srgb, #000 50%, #fff)) {
  .segment-button.selected {
    background: var(--segment-color, #431C7C) !important;
    border-color: var(--segment-color, #431C7C) !important;
  }
}

.segment-button.selected .seg-label {
  color: #fff !important;
  -webkit-text-fill-color: #fff;
}



/* if the segment has only 1-2 items total => 2 columns */
.segment-buttons.cols-2 .segment-button {
  flex: 0 0 calc((100% - 10px) / 2);
}

/* last row: force half width (50%) for remainder 1 or 2 */
.segment-button.last-half {
  flex: 0 0 calc((100% - 10px) / 2) !important;
}

/* =========================
   Quantity inner layout
   ========================= */

.segment-button .seg-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.segment-button .seg-label {
  width: 100%;
  text-align: center;
  line-height: 1.2;
  user-select: none;
  cursor: pointer; /* unselect via text as requested */
}

/* qty controls hidden until selected */
.segment-button.quantity .qty-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  border-radius: 14px;
  padding: 6px 8px;

  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.08);

  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;

  transition: opacity 0.18s ease, transform 0.18s ease;
}

.segment-button.quantity.selected .qty-controls,
.segment-button.quantity.qty-active .qty-controls {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.segment-button.quantity .qty-btn {
  width: 34px;
  height: 30px;
  border-radius: 12px;
  border: 1px solid rgba(67, 28, 124, 0.35);
  background: rgba(255,255,255,0.9);
  color: var(--segment-color, #431C7C);
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, background 0.12s ease;
}

.segment-button.quantity .qty-btn:active {
  transform: scale(0.96);
  background: rgba(240,240,240,0.9);
}

.segment-button.quantity .qty-label {
  min-width: 22px;
  text-align: center;
  font-weight: 800;
  color: #431C7C;
}

/* selected coloring adjustments */
.segment-button.selected .seg-label { color: #fff; }

.segment-button.quantity.selected .qty-controls {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
}

.segment-button.quantity.selected .qty-label { color: #fff; }

.segment-button.quantity.selected .qty-btn {
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.12);
  color: #fff;
}

/* =========================
   Remarks section
   ========================= */

.dish-remarks-section {
  border-right: 4px solid #431C7C;
  padding-right: 8px;
}

.dish-remarks-section .segment-title {
  color: #431C7C;
  font-size: 15px;
  margin-bottom: 6px;
}

.dish-remarks-section .optional {
  font-size: 12px;
  color: #888;
  font-weight: normal;
}

.dish-remarks-input {
  width: 100%;
  resize: none;
  min-height: 70px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border-radius: 10px;
  border: 1px solid rgba(67, 28, 124, 0.3);
  background: #faf8fd;
  outline: none;
}

.dish-remarks-input:focus {
  border-color: #431C7C;
  background: #fff;
}

/* =========================
   Footer
   ========================= */


#dish-footer {
  display: flex;
  justify-content: space-between;
  flex-direction: row-reverse;
  align-items: center;
  position: sticky;
  bottom: 0;
  z-index: 10;
}


/* =========================
   Error state + toast
   ========================= */

.segment-section.error {
  border-right-color: #E53935 !important;
  background: rgba(229, 57, 53, 0.05);
}

.segment-section.error .segment-title {
  color: #E53935 !important;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, #E53935, #C62828);
  color: #fff;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 99999;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================
   Dish header layout
   ========================= */

.dish-header-section { margin-bottom: 20px; }

.dish-header-row {
  display: flex;
  flex-direction: row-reverse;
  gap: 14px;
  align-items: flex-start;
}

.dish-thumb {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  transition: transform 0.25s ease;
}

.dish-thumb:hover { transform: scale(1.05); }

.section-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 6px;
}

.section-desc {
  font-size: 16px;
  line-height: 1.4;
  color: #333;
}

/* =========================
   Utilities
   ========================= */

.hidden { display: none !important; }
.dish-header-section {
  margin-bottom: 20px;
}

.dish-header-row {
  display: flex;
  flex-direction: row-reverse;
  gap: 14px;
  align-items: flex-start;
}

.dish-image-wrapper {
  flex-shrink: 0;
}

.dish-text-wrapper {
  flex: 1;
  text-align: right;
}

.dish-thumb {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  transition: transform 0.25s ease;
}

.dish-thumb:hover {
  transform: scale(1.05);
}

.section-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 6px;
  text-align: right;
}

.section-desc {
  font-size: 16px;
  line-height: 1.4;
  color: #333;
  text-align: right;
}

.image-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeIn 0.25s ease;
}

.image-overlay.hidden {
  display: none;
}

.image-overlay img,
#dish-image-preview {
  max-width: 90%;
  max-height: 90%;
  border-radius: 20px;
  animation: zoomIn 0.25s ease;
}

.image-overlay-close {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 42px;
  color: white;
  cursor: pointer;
  font-weight: 300;
}


@media (max-width: 400px) {
  .segment-button {
    font-size: 12px;
  }
}


/* =========================
   Footer
   ========================= */
#dish-footer {
  direction: rtl;
  min-height: 68px;
  padding: 8px 10px;
  box-sizing: border-box;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;

  background: #431C7C;
  border-top: 2px solid rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

#total-price {
  width: 100px;
  flex: 0 0 100px;
  margin: 0 !important;
  color: #fff;
  text-align: center;
  line-height: 1.05;
}

.dish-footer-price-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.dish-footer-price-value {
  display: block;
  margin-top: 3px;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
}

#dish-total-price {
  color: #fff;
}

.dish-quantity-box {
  width: 100px;
  flex: 0 0 100px;
  height: 36px;
  border-radius: 20px;
  background: #fff;

  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
}

.dish-qty-btn {
  width: 34px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #431C7C;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.dish-qty-value {
  width: 32px;
  text-align: center;
  color: #111;
  font-size: 17px;
  font-weight: 900;
}

#add-to-cart-btn {
  width: 108px;
  flex: 0 0 108px;
  height: 36px;
  padding: 0 5px;
  box-sizing: border-box;

  border: 0;
  border-radius: 9px;
  background: #fff;
  color: #431C7C;

  font-size: 15px;
  font-weight: 900;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* מתחת 430px */
@media (max-width: 430px) {
  #dish-footer {
    padding: 8px 6px;
    gap: 4px;
  }

  #total-price {
    width: 100px;
    flex-basis: 100px;
  }

  .dish-quantity-box {
    width: 92px;
    flex-basis: 92px;
  }

  #add-to-cart-btn {
    width: 100px;
    flex-basis: 100px;
    font-size: 15px;
  }
}

/* מסכים גדולים */
@media (min-width: 700px) {
  #dish-footer {
    padding: 10px 40px;
    justify-content: space-between;
  }

  #total-price {
    width: 190px;
    flex-basis: 190px;
    text-align: right;
  }

  .dish-footer-price-label,
  .dish-footer-price-value {
    display: inline;
    font-size: 18px;
  }

  .dish-quantity-box {
    width: 116px;
    flex-basis: 116px;
    height: 40px;
  }

  #add-to-cart-btn {
    width: 165px;
    flex-basis: 165px;
    height: 44px;
    font-size: 15px;
  }
}