/* =========================================================
   COMPONENT — POPUP OVERLAY
   ========================================================= */

/**
 * Fullscreen popup backdrop.
 * Covers viewport and blocks interaction with background.
 */
.popup-overlay {
    display: none;

    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    box-sizing: border-box;

    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;

    overflow: hidden;

    justify-content: center;
    align-items: center;
}

/* Active state */
.popup-overlay.active {
    display: flex;
}


/* =========================================================
   MOBILE FIX (NO PADDING BUG)
   ========================================================= */

@media (max-width: 768px) {
    .popup-overlay {
        align-items: center;
        padding-bottom: 120px;
        height: 100vh;
        min-height: 100vh;
        height: 100dvh;
        min-height: 100dvh;
        box-shadow: 0 240px 0 0 rgba(0, 0, 0, 0.5);
    }

    .popup-content {
        margin: 0;
        width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
    }
}


/* =========================================================
   COMPONENT — POPUP CONTAINER
   ========================================================= */

/**
 * Main popup content container.
 */
.popup-content {
    position: relative;

    margin: 5% auto;
    width: 80%;
    max-width: 500px;

    background: #fff;
    border-radius: 8px;

    max-height: 90dvh;
    overflow-y: auto;
}

/**
 * Responsive sizing for mobile devices.
 */
@media (max-width: 768px) {
    .popup-content {
        width: 90%;
        max-width: none;
        margin: 20px auto;
        border-radius: 8px;
    }
}


/* =========================================================
   POPUP — IMAGE SECTION
   ========================================================= */

/**
 * Container for item image.
 */
.popup-image {
    width: 100%;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
}

/**
 * Image styling.
 */
.popup-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
}


/* =========================================================
   POPUP — CLOSE BUTTON
   ========================================================= */

/**
 * Floating circular close button.
 */
.popup-close {
    position: absolute;
    top: 10px;
    right: 10px;

    width: 30px;
    height: 30px;

    background: #FF6600;
    border: none;
    border-radius: 50%;

    color: #fff;
    font-size: 18px;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
}


/* =========================================================
   POPUP — DETAILS SECTION
   ========================================================= */

/**
 * Container for item information.
 */
.popup-details {
    padding: 20px;
}

/**
 * Item title.
 */

.popup-details h3 {
    font-weight: bold;
    font-size: 24px;
    margin-top: 0;
    margin-bottom: 10px;
}

/**
 * Price display.
 */
.popup-details .popup-price {
    font-weight: bold;
    font-size: 22px;
    color: #000;
    margin-bottom: 10px;
}

/**
 * Item description text.
 */
.popup-details .popup-description {
    white-space: pre-line;

    color: #777;
    font-size: 16px;

    margin-bottom: 5px;
}

.popup-details .popup-weight {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #777;
    font-size: 16px;
    white-space: normal;
    margin-bottom: 5px;
}

.popup-badge-container {
    display: flex;
    gap: 14px;
    margin-bottom: 6px;
}


/* =========================================================
   POPUP — ACTIONS CONTAINER
   ========================================================= */

/**
 * Container for quantity controls and action buttons.
 */
.action-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/**
 * Portion control wrapper.
 */
.portion-control {
    display: flex;
    align-items: center;
}


/* =========================================================
   ACTION BUTTONS — FAVORITE / ADD
   ========================================================= */

/**
 * Base favorite button.
 */
.favorite-button2 {
    width: 40px;
    height: 40px;

    padding: 10px;
    margin: 0 5px;

    border: 2px solid orange;
    background-color: transparent;
    color: orange;

    border-radius: 10px;

    cursor: pointer;
    font-weight: bold;

    transition: background-color 0.3s, color 0.3s;
}

/**
 * Active "add to favorites" button.
 */
.add-to-favorites {
    background-color: orange;
    color: white;

    flex-grow: 1;
    margin-left: 10px;
}

.add-to-favorites:hover {
    background-color: #ff8c00;
}

.add-to-favorites:active {
    background-color: #ff6f00;
}


/* =========================================================
   PORTION COUNTER
   ========================================================= */

/**
 * Displays selected portion quantity.
 */
.portion-count {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    margin: 0;
    padding: 0;

    font-size: 14px;
    font-weight: 700;

    text-align: center;
}


/* =========================================================
   FAVORITES / ORDER SUMMARY LIST
   ========================================================= */

/**
 * Section title inside popup list.
 */
h4 {
    text-align: center;

    font-size: 1.5rem;
    font-weight: bold;

    margin-bottom: 20px;
}

/**
 * Dish name styling.
 */
.dish-name {
    font-weight: bold;
    font-size: 1.2rem;
}

/**
 * Dish price display.
 */
.dish-price {
    color: gray;
    margin-top: 5px;
    display: block;
}


/* =========================================================
   PORTION CONTROLS — LIST VIEW
   ========================================================= */

/**
 * Wrapper for controls in order list.
 */
.portion-control-wrapper {
    display: grid;
    width: 88px;
    height: 30px;
    grid-template-columns: 28px 32px 28px;
    align-items: center;
    border: 1px solid rgba(255, 165, 0, 0.55);
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
    margin-top: 10px;
    margin-left: auto;
}

.decrease-button, .increase-button {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: orange;
    cursor: pointer;
    font-size: 16px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.decrease-button:hover,
.increase-button:hover {
    background-color: rgba(255, 165, 0, 0.1);
    color: orange;
}

/**
 * Total price for individual dish.
 */
.dish-total-price {
    font-weight: bold;

    margin-left: 5px;
    min-width: 60px;

    text-align: right;
}


/* =========================================================
   ORDER SUMMARY — TOTAL
   ========================================================= */

/**
 * Separator between dishes.
 */
.dish-separator {
    border: none;
    border-top: 1px solid #ddd;
    margin: 10px 0;
}

/**
 * Total order container.
 */
.total-order {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-top: 15px;
}

/**
 * Total label text.
 */
.total-order-label {
    font-size: 1.5rem;
    font-weight: bold;
}

/**
 * Total price value.
 */
#total-order-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: orange;
}


/* =========================================================
   ORDER LIST — DISH INFO ROW
   ========================================================= */

/**
 * Row displaying dish name and price.
 */
.dish-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dish-name {
    font-weight: bold;
    font-size: 1.2rem;
}

.dish-price {
    color: gray;
    margin-left: 15px;
}


/* =========================================================
   FAVORITES POPUP — COMPACT ITEM ROW
   ========================================================= */

#favorites-popup .popup-content {
    width: min(92%, 460px);
}

#favorites-popup .popup-details {
    padding: 20px;
}

#favorites-popup .favorites-popup-message {
    margin: 18px auto 14px;
    max-width: 280px;
    color: #6B7280;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
}

#favorites-popup .dish-content {
    min-width: 0;
}

#favorites-popup .dish-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 7px;
    align-items: start;
}

#favorites-popup .dish-info {
    min-width: 0;
    display: flex;
    align-items: flex-start;
}

#favorites-popup .dish-name {
    max-width: 100%;
    color: #1f1f1f;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

#favorites-popup .dish-price {
    margin: 0;
    color: #8a8a8a;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

#favorites-popup .dish-actions {
    min-width: 96px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

#favorites-popup .dish-price-row {
    min-width: 0;
    display: flex;
    align-items: center;
    min-height: 32px;
}

#favorites-popup .dish-counter-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

#favorites-popup .dish-total-price {
    min-width: 0;
    margin: 0;
    color: #222;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.15;
    text-align: right;
    white-space: nowrap;
}

#favorites-popup .portion-control-wrapper {
    width: 96px;
    height: 32px;
    margin: 0;
    display: grid;
    grid-template-columns: 31px 34px 31px;
    align-items: stretch;
    justify-items: stretch;
    column-gap: 0;
    border: 1px solid rgba(255, 165, 0, 0.55);
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
}

#favorites-popup .decrease-button,
#favorites-popup .increase-button {
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: orange;
    cursor: pointer;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.18s ease, color 0.18s ease;
}

#favorites-popup .decrease-button:hover,
#favorites-popup .increase-button:hover,
#favorites-popup .decrease-button:active,
#favorites-popup .increase-button:active {
    background-color: rgba(255, 165, 0, 0.1);
    color: orange;
}

#favorites-popup .portion-count {
    width: 100%;
    min-width: 0;
    height: 100%;
    color: #222;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

#favorites-popup .dish-separator {
    margin: 12px 0;
    border-top-color: rgba(0, 0, 0, 0.08);
}

#favorites-popup .dish-item:last-child .dish-separator {
    margin-bottom: 8px;
}

#favorites-popup .total-order {
    margin-top: 10px;
}

@media (max-width: 420px) {
    #favorites-popup .popup-details {
        padding: 18px 16px;
    }

    #favorites-popup .dish-row {
        gap: 10px;
    }

    #favorites-popup .dish-actions {
        min-width: 92px;
    }

    #favorites-popup .portion-control-wrapper {
        width: 92px;
        grid-template-columns: 30px 32px 30px;
    }
}


/* =========================================================
   DISH POPUP — MODERN CARD SYSTEM
   ========================================================= */

#popup.popup-overlay {
    inset: 0;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    padding: 24px;
    background: rgba(17, 17, 17, 0.48);
}

body.dish-modal-open #popup.popup-overlay.active {
    display: flex;
}

#popup .popup-content {
    width: min(100%, 740px);
    max-width: 740px;
    margin: 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
    overflow: visible;
}

#popup .popup-image {
    border-radius: 14px 14px 0 0;
    background-color: #f3f1ee;
}

#popup .popup-image img {
    width: 100%;
    height: clamp(260px, 42vh, 390px);
    object-fit: cover;
    display: block;
}

#popup .popup-content--text {
    width: min(100%, 560px);
    max-width: 560px;
}

#popup .popup-content--text .popup-details {
    padding: 30px 32px 28px;
}

#popup .popup-content--text .popup-details h3 {
    padding-right: 42px;
}

#popup .popup-content--text .popup-badge-container {
    padding-right: 42px;
}

#popup .popup-close {
    position: absolute;

    top: 14px;
    right: 14px;

    width: 36px;
    height: 36px;

    border: none;
    border-radius: 50%;

    background: rgba(243, 146, 0, 0.96);
    color: #fff;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 18px;
    font-weight: 800;
    line-height: 1;

    cursor: pointer;

    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);

    transition: background-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

#popup .popup-close:hover {
    background: #ffab2d;

    transform: translateY(-1px);

    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

#popup .popup-details {
    padding: 24px 30px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#popup .popup-badge-container {
    position: relative;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    min-height: 12px;
    margin: 0 0 2px;
    color: #777;
    overflow: visible;
}

#popup .popup-badge-container span {
    padding: 0;
    border-radius: 0;
    background-color: transparent;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

#popup .new-label {
    color: rgba(210, 45, 45, 0.9);
}

#popup .popular-label {
    color: rgba(45, 92, 190, 0.9);
}

#popup .vegan-badge {
    color: #3b8a45;
}

#popup .spicy-badge {
    color: #b95032;
}

#popup .popup-details h3 {
    margin: 0;
    max-width: 620px;
    color: #171717;
    font-size: 31px;
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: 0;
}

#popup .popup-details .popup-description {
    max-width: 620px;
    margin: 2px 0 0;
    color: #707070;
    font-size: 15px;
    line-height: 1.58;
    white-space: pre-line;
}

#popup .popup-details .popup-weight {
    margin: 0;
    color: #808080;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
}

#popup .popup-details .popup-weight i {
    margin-right: 4px;
    font-size: 12px;
}

#popup .action-container {
    margin-top: 8px;
    padding-top: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

#popup .popup-details .popup-price {
    margin: 0;
    color: #111;
    font-size: 25px;
    font-weight: 800;
    line-height: 1;
}

#popup .popup-action-slot {
    width: 112px;
    height: 34px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#popup .favorite-but {
    width: 112px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: orange;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
    transition: color 0.2s ease, opacity 0.18s ease, transform 0.18s ease;
}

#popup .favorite-but:hover {
    background-color: transparent;
    color: #e69500;
    opacity: 0.86;
}

#popup .favorite-but:active {
    transform: translateY(1px);
}

#popup .quantity-select {
    display: grid;

    grid-template-columns: 32px 48px 32px;

    align-items: center;
    justify-content: center;

    width: 112px;
    height: 34px;

    column-gap: 0;

    border: 1px solid rgba(255, 165, 0, 0.55);
    border-radius: 999px;

    overflow: hidden;
    background: #fff;
}

#popup .increase-but,
#popup .decrease-but {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: orange;
    cursor: pointer;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

#popup .increase-but:hover,
#popup .decrease-but:hover {
    background-color: rgba(255, 165, 0, 0.1);
    color: orange;
}

#popup .portion-cou {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    margin: 0;
    padding: 0;

    font-size: 14px;
    font-weight: 700;

    text-align: center;
}

@keyframes popupQuantityIn {
    from {
        opacity: 0;
        transform: translateY(2px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    #popup.popup-overlay {
        inset: 0;
        height: 100vh;
        min-height: 100vh;
        height: 100dvh;
        min-height: 100dvh;
        padding: 16px;
        align-items: center;
        box-shadow: 0 240px 0 0 rgba(17, 17, 17, 0.48);
    }

    #popup .popup-content {
        width: min(100%, 520px);
        max-width: 520px;
        max-height: 90vh;
        max-height: 90dvh;
        margin: 0 auto;
        border-radius: 12px;
    }

    #popup .popup-image {
        border-radius: 12px 12px 0 0;
    }

    #popup .popup-image img {
        height: clamp(220px, 38vh, 320px);
    }

    #popup .popup-content--text {
        width: min(100%, 460px);
    }

    #popup .popup-content--text .popup-details {
        padding: 24px 18px 22px;
    }

    #popup .popup-details {
        padding: 20px 18px 22px;
        gap: 11px;
    }

    #popup .popup-details h3 {
        max-width: 100%;
        font-size: 25px;
        line-height: 1.14;
    }

    #popup .popup-details .popup-description {
        max-width: 34rem;
        font-size: 14px;
        line-height: 1.55;
    }

    #popup .action-container {
        margin-top: 6px;
        padding-top: 16px;
        padding-bottom: 2px;
    }

    #popup .popup-details .popup-price {
        font-size: 22px;
    }
}

@media (max-width: 420px) {
    #popup.popup-overlay {
        padding: 10px;
    }

    #popup .popup-content {
        max-height: 92vh;
        max-height: 92dvh;
    }

    #popup .popup-image img {
        height: 210px;
    }

    #popup .popup-content--text .popup-details {
        padding: 22px 16px 20px;
    }

    #popup .popup-details {
        padding: 18px 16px 20px;
    }
}
