/* ============================================================
   CART MOBILE — Premium Redesign
   Overrides new_design.css and theme.css for max-width: 640px
   ============================================================ */

@media (max-width: 640px) {

    /* -------------------------------------------------------
       1. PURCHASE ITEM — товарна картка
    ------------------------------------------------------- */
    .purchase__item {
        display: grid !important;
        grid-template-columns: 76px 1fr 34px !important;
        grid-template-rows: auto auto auto !important;
        column-gap: 12px !important;
        row-gap: 0 !important;
        padding: 14px !important;
        border-radius: 16px !important;
        background: #ffffff !important;
        border: 1px solid #e9ecf0 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
        margin-bottom: 12px !important;
        position: static !important;
    }

    /* --- Зображення: ліва колонка, охоплює 3 рядки --- */
    .purchase__image {
        grid-column: 1 / 2 !important;
        grid-row: 1 / span 3 !important;
        width: 76px !important;
        height: 76px !important;
        min-height: 76px !important;
        margin: 0 !important;
        padding: 4px !important;
        border-radius: 12px !important;
        border: 1px solid #f1f5f9 !important;
        background: #f8fafc !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
        max-width: none !important;
        flex: none !important;
        overflow: hidden !important;
    }
    .purchase__image img {
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        display: block !important;
    }

    /* --- Контентна обгортка: розчиняємо, діти беруть участь у grid --- */
    .purchase__content {
        display: contents !important;
        padding: 0 !important;
        width: auto !important;
        flex: none !important;
        max-width: none !important;
    }

    /* --- Назва товару: рядок 1, середня колонка --- */
    .purchase__name {
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: auto !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 1.35 !important;
        color: #111827 !important;
        align-self: start !important;
    }
    .purchase__name .purchase__name_link {
        color: inherit !important;
        text-decoration: none !important;
        font-size: inherit !important;
        font-weight: inherit !important;
    }
    .purchase__name i {
        font-size: 12px !important;
        color: #9ca3af !important;
        margin-top: 2px !important;
        font-style: normal !important;
        display: block !important;
    }

    /* --- Кнопка видалення: рядок 1, права колонка --- */
    .purchase__remove {
        grid-column: 3 / 4 !important;
        grid-row: 1 !important;
        position: static !important;
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #fff0f0 !important;
        color: #ef4444 !important;
        border-radius: 8px !important;
        border: 1px solid #fecaca !important;
        align-self: start !important;
        transition: background 0.15s !important;
    }
    .purchase__remove svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* --- Група (ціна за шт + кількість + підсумок) --- */
    .purchase__group {
        grid-column: 2 / 4 !important;
        grid-row: 2 !important;
        display: flex !important;
        align-items: flex-end !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        gap: 15px !important;
        margin-top: 8px !important;
        width: auto !important;
    }

    /* Ховаємо заголовки (Ціна, К-сть, Разом) — не потрібні на мобільному */
    .purchase__group_title {
        display: none !important;
    }
    .purchase__group_content {
        min-height: auto !important;
    }

    /* Ціна за одиницю — приховати на мобільному, показуємо тільки підсумок */
    .purchase__price {
        display: none !important;
    }

    /* --- Лічильник кількості --- */
    .purchase__amount {
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-shrink: 0 !important;
    }

    .fn_product_amount.amount {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: #f3f4f6 !important;
        border-radius: 10px !important;
        padding: 3px !important;
        gap: 0 !important;
        height: 36px !important;
        max-width: none !important; /* Fix for cutoff plus button */
        width: 100px !important;    /* Provide explicit width to fit buttons */
    }
    .amount__minus,
    .amount__plus {
        width: 30px !important;
        height: 30px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #ffffff !important;
        border-radius: 8px !important;
        color: #374151 !important;
        font-size: 20px !important;
        font-weight: 500 !important;
        cursor: pointer !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
        user-select: none !important;
        line-height: 1 !important;
        flex-shrink: 0 !important;
    }
    .amount__input {
        width: 34px !important;
        text-align: center !important;
        border: none !important;
        background: transparent !important;
        font-weight: 700 !important;
        font-size: 14px !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        color: #111827 !important;
    }

    /* --- Ціна підсумку --- */
    .purchase__price_total {
        font-size: 18px !important;
        font-weight: 800 !important;
        color: #2563eb !important;
        white-space: nowrap !important;
        letter-spacing: -0.3px !important;
        line-height: 1 !important;
        text-align: right !important;
        margin-bottom: 5px !important; /* Visually align with center of counter */
    }
    .purchase__price_total .currency {
        font-size: 12px !important;
        font-weight: 700 !important;
        top: -6px !important;
        position: relative !important;
    }

    /* -------------------------------------------------------
       2. ПІДСУМОК ЗАМОВЛЕННЯ — блок з сумами
    ------------------------------------------------------- */
    .purchase_detail {
        background: #f8fafc !important;
        border-radius: 16px !important;
        padding: 16px !important;
        margin: 16px 0 0 !important;
        border: 1px solid #e9ecf0 !important;
        box-shadow: none !important;
    }
    .purchase_detail__item {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 8px 0 !important;
        margin: 0 !important;
        border-bottom: 1px solid #f1f5f9 !important;
    }
    .purchase_detail__item:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }
    .purchase_detail__name {
        font-size: 14px !important;
        font-weight: 500 !important;
        color: #6b7280 !important;
    }
    .purchase_detail__name--total {
        font-size: 16px !important;
        font-weight: 700 !important;
        color: #111827 !important;
    }
    .purchase_detail__price {
        font-size: 15px !important;
        font-weight: 600 !important;
        color: #111827 !important;
        display: flex;
        align-items: baseline !important;
        gap: 3px !important;
    }
    .purchase_detail__price--total {
        font-size: 20px !important;
        font-weight: 800 !important;
        color: #2563eb !important;
    }
    .purchase_detail__price .currency {
        font-size: 11px !important;
        top: -5px !important;
        position: relative !important;
    }

    /* -------------------------------------------------------
       3. СПОСОБИ ДОСТАВКИ / ОПЛАТИ — premium look
    ------------------------------------------------------- */

    /* Контейнер кожного пункту */
    .delivery__item,
    .payment_method__item {
        margin-bottom: 10px !important;
        border-radius: 14px !important;
        border: 1.5px solid #e5e7eb !important;
        background: #ffffff !important;
        overflow: hidden !important;
        transition: border-color 0.2s, box-shadow 0.2s !important;
    }

    /* Активний (обраний) варіант */
    .delivery__item:has(input:checked),
    .payment_method__item:has(input:checked) {
        border-color: #2563eb !important;
        background: #f0f6ff !important;
        box-shadow: 0 0 0 3px rgba(37,99,235,0.1) !important;
    }

    /* Label — горизонтальний flex з відступами */
    .delivery__label {
        display: flex !important;
        align-items: center !important;
        gap: 0 !important;
        padding: 14px 14px !important;
        margin: 0 !important;
        width: 100% !important;
        cursor: pointer !important;
        min-height: 52px !important;
    }

    /* Кастомний чекбокс (SVG-квадрат з галочкою) */
    .delivery__label .checkbox__icon {
        position: relative !important;
        top: 0 !important;
        flex-shrink: 0 !important;
        margin-right: 12px !important;
        width: 22px !important;
        height: 22px !important;
    }

    /* Ховаємо стандартний radio/checkbox input */
    .delivery__item .checkbox__input,
    .payment_method__item .checkbox__input {
        position: absolute !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
    }

    /* Назва способу */
    .delivery__name {
        flex: 1 !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        color: #1f2937 !important;
        line-height: 1.4 !important;
        padding-left: 0 !important;
        max-width: none !important;
        word-break: break-word !important;
    }
    .delivery__name_price {
        display: block !important;
        font-size: 12px !important;
        color: #6b7280 !important;
        font-weight: 500 !important;
        font-style: normal !important;
        white-space: normal !important;
        margin-top: 2px !important;
    }

    /* Логотип (картинка) способу доставки/оплати */
    .delivery__image {
        flex: 0 0 auto !important;
        max-width: 50px !important;
        width: auto !important;
        padding-left: 8px !important;
        text-align: right !important;
    }
    .delivery__image img {
        max-height: 24px !important;
        max-width: 50px !important;
        width: auto !important;
    }

    /* Опис (розгорнутий текст) під обраним пунктом */
    .delivery__description {
        padding: 0 14px 14px !important;
        margin: 0 !important;
        font-size: 13px !important;
        line-height: 1.5 !important;
        color: #6b7280 !important;
        display: none;
        border-top: 1px solid #f3f4f6 !important;
        padding-top: 10px !important;
    }
    .checkbox.active + .delivery__description {
        display: block !important;
    }

    /* -------------------------------------------------------
       4. ФОРМА — поля вводу
    ------------------------------------------------------- */
    .form__group {
        margin-bottom: 14px !important;
    }
    .form__input,
    .form__textarea {
        height: 48px !important;
        border-radius: 12px !important;
        font-size: 15px !important;
        padding: 0 14px !important;
    }
    .form__textarea {
        height: auto !important;
        min-height: 80px !important;
        padding: 12px 14px !important;
    }

    /* -------------------------------------------------------
       5. КНОПКА ОФОРМЛЕННЯ — sticky bottom
    ------------------------------------------------------- */
    .form__footer {
        position: sticky !important;
        bottom: 0 !important;
        background: rgba(255,255,255,0.97) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        padding: 12px 16px !important;
        margin: 0 -15px !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1) !important;
        z-index: 100 !important;
    }
    .form__button {
        height: 52px !important;
        font-size: 15px !important;
        border-radius: 14px !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-weight: 700 !important;
        letter-spacing: 0.3px !important;
    }

    /* -------------------------------------------------------
       6. ЗАГОЛОВКИ БЛОКІВ — form__title
    ------------------------------------------------------- */
    .form__title {
        font-size: 15px !important;
        font-weight: 700 !important;
        gap: 8px !important;
    }
    .form__title svg {
        width: 20px !important;
        height: 20px !important;
        flex-shrink: 0 !important;
    }

    /* -------------------------------------------------------
       7. БЛОКИ КОШИКА — boxed
    ------------------------------------------------------- */
    .block--boxed,
    .block--cart_purchases.block--boxed,
    .block--boxed.block--border {
        border-radius: 16px !important;
        padding: 14px !important;
    }

}
/* end @media (max-width: 640px) */