/* =========================
   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 #431C7C;
  border-radius: 20px;

  padding: 10px 12px;
  cursor: pointer;
  background-color: #fff;

  transition: all 0.2s ease-in-out;
  font-size: 14px;

  white-space: normal; /* required for quantity layout */
}

.segment-button.selected {
  background-color: #431C7C !important;
  color: white !important;
  font-weight: bold;
  border: 1px solid #431C7C !important;
}

/* 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: #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;
  padding: 12px 16px;
  background-color: #431C7C;
  color: white;
  font-size: 18px;
  position: sticky;
  bottom: 0;
  border-top: 1px solid #ccc;
  z-index: 10;
}

#add-to-cart-btn {
  background-color: #ffffff;
  color: #431C7C;
  font-size: 16px;
  padding: 10px 30px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: bold;
  white-space: nowrap;
  margin-right: 20px;
}

#add-to-cart-btn:hover {
  background-color: #f0f0f0;
}

/* =========================
   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; }

@media (max-width: 400px) {
  .segment-button {
    font-size: 12px;
  }
}