/* ============================================================
   FZ.Checkout — modal styles
   ============================================================ */

/* Overlay container */
#checkoutOverlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
#checkoutOverlay.checkout-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Backdrop */
.checkout-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Modal */
.checkout-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 94vw;
    max-width: 480px;
    max-height: 90vh;     /* fallback dla przeglądarek bez Visual Viewport API */
    max-height: 90dvh;    /* lepszy fallback: dynamic viewport */
    /* JS (_adjustModalToViewport) nadpisuje max-height i top gdy visualViewport dostępny */
    overflow: hidden;     /* scroll jest na .checkout-body, nie tutaj */
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

/* Header */
.checkout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #eee;
}
.checkout-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a1a;
}
.checkout-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 6px;
    transition: background 0.15s;
}
.checkout-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Step indicators */
.checkout-steps {
    display: flex;
    gap: 0;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
}
.checkout-step {
    flex: 1;
    text-align: center;
    font-size: 0.82rem;
    color: #aaa;
    padding: 6px 0;
    position: relative;
    transition: color 0.2s;
}
.checkout-step--active {
    color: #0d7377;
    font-weight: 600;
}
.checkout-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 4px;
    transition: background 0.2s, color 0.2s;
}
.checkout-step--active .checkout-step-num {
    background: #0d7377;
    color: #fff;
}

/* Body — jedyny scrollowalny obszar, header/steps są przyklejone */
.checkout-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* płynny scroll iOS */
    padding: 16px 20px max(20px, env(safe-area-inset-bottom, 20px));
    overscroll-behavior: contain;      /* nie propaguj scroll do tła */
}
.checkout-body--hidden {
    display: none;
}

/* Section */
.checkout-section {
    margin-bottom: 20px;
}
.checkout-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px;
}

/* Summary rows */
.checkout-summary {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px 14px;
}
.checkout-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.9rem;
    color: #333;
}
.checkout-summary-row + .checkout-summary-row {
    border-top: 1px solid #eee;
    margin-top: 4px;
    padding-top: 8px;
}

/* Delivery cards */
.checkout-delivery-cards {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.checkout-delivery-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 6px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
}
.checkout-delivery-card:hover {
    border-color: #0d7377;
    background: #f0fafa;
}
.checkout-delivery-card--active {
    border-color: #0d7377;
    background: #e8f5f5;
}
.checkout-delivery-icon {
    font-size: 1.5rem;
}
.checkout-delivery-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}
.checkout-delivery-price {
    font-size: 0.75rem;
    color: #0d7377;
    font-weight: 600;
}

/* Delivery form */
.checkout-delivery-form {
    min-height: 0;
}

/* Form inputs */
.checkout-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.checkout-form-row {
    display: flex;
    gap: 8px;
}
.checkout-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}
.checkout-input:focus {
    border-color: #0d7377;
}
.checkout-input--short {
    max-width: 120px;
    flex-shrink: 0;
}

/* InPost parcel locker search */
.checkout-inpost-search {
    position: relative;
}
.checkout-inpost-dropdown {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: #1a2035;
    border: 1px solid #0d7377;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.checkout-inpost-item {
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid #2a3550;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.checkout-inpost-item:last-child {
    border-bottom: none;
}
.checkout-inpost-item:hover {
    background: #0d7377;
}
.checkout-inpost-item strong {
    font-size: 0.9rem;
    color: #e0e0e0;
}
.checkout-inpost-item span {
    font-size: 0.8rem;
    color: #aaa;
}
.checkout-inpost-item--loading,
.checkout-inpost-item--empty {
    color: #888;
    font-size: 0.85rem;
    cursor: default;
    padding: 0.7rem 0.9rem;
}
.checkout-inpost-item--loading:hover,
.checkout-inpost-item--empty:hover {
    background: none;
}

/* Total bar */
.checkout-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    margin: 4px 0 12px;
    border-top: 2px solid #eee;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
}
.checkout-total-amount {
    color: #0d7377;
    font-size: 1.2rem;
}

/* Buttons */
.checkout-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
}
.checkout-btn:active {
    transform: scale(0.98);
}
.checkout-btn--primary {
    background: #0d7377;
    color: #fff;
}
.checkout-btn--primary:hover {
    background: #0a5c5f;
}
.checkout-btn--primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.checkout-btn--secondary {
    background: #f0f0f0;
    color: #555;
    margin-top: 10px;
}
.checkout-btn--secondary:hover {
    background: #e0e0e0;
}
.checkout-btn--cancel {
    margin-top: 16px;
    background: transparent;
    color: #aaa;
    font-size: 0.88rem;
    font-weight: 400;
    text-decoration: underline;
}
.checkout-btn--cancel:hover {
    color: #e94560;
    background: transparent;
}

/* Telefon z prefiksem +48 */
.checkout-input-tel {
    display: flex;
    align-items: center;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.2s;
}
.checkout-input-tel:focus-within {
    border-color: #0d7377;
}
.checkout-tel-prefix {
    padding: 12px 8px 12px 14px;
    color: #555;
    font-size: 0.95rem;
    border-right: 1px solid #eee;
    white-space: nowrap;
    background: #f8f9fa;
    user-select: none;
}
.checkout-input--tel {
    border: none !important;
    border-radius: 0 !important;
    flex: 1;
    padding-left: 10px;
    box-shadow: none !important;
}
.checkout-input--tel:focus {
    outline: none;
}

/* Sekcja faktury VAT */
.checkout-section--invoice {
    border-top: 1px solid #eee;
    padding-top: 12px;
    margin-top: 4px;
}
.checkout-invoice-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #333;
    padding: 4px 0;
}
.checkout-invoice-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #0d7377;
    cursor: pointer;
    flex-shrink: 0;
}
.checkout-invoice-form {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 14px;
    margin-top: 10px;
}
.checkout-copy-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #555;
    cursor: pointer;
    margin: 8px 0 4px;
}
.checkout-copy-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0d7377;
    cursor: pointer;
}

/* Payment info (step 2) */
.checkout-payment-info {
    text-align: center;
    padding: 20px 0;
}
.checkout-payment-summary {
    font-size: 0.95rem;
    color: #333;
    line-height: 1.6;
    margin-bottom: 20px;
}
.checkout-payment-note {
    font-size: 0.82rem;
    color: #888;
    margin-bottom: 16px;
}
.checkout-payment-disabled-note {
    font-size: 0.78rem;
    color: #e94560;
    margin-top: 8px;
}

/* Payment success block */
.checkout-success-box {
    background: #f0faf4;
    border: 1.5px solid #34c471;
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    margin-bottom: 12px;
}
.checkout-success-icon {
    font-size: 2.4rem;
    margin-bottom: 8px;
}
.checkout-success-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a7a45;
    margin-bottom: 6px;
}
.checkout-success-order {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 4px;
}
.checkout-success-note {
    font-size: 0.82rem;
    color: #555;
}

/* Header price badge */
.album-header-price {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: #0d7377;
    color: #fff;
    border-radius: 16px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-left: 8px;
    cursor: help;
    white-space: nowrap;
}

/* ============================================================
   Locker picker button + info
   ============================================================ */
.checkout-btn--locker {
    margin-top: 4px;
    font-size: 0.95rem;
}
.checkout-locker-info {
    background: #e8f5f5;
    border: 1.5px solid #0d7377;
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 4px;
}
.checkout-locker-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.checkout-locker-info-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #0d7377;
}
.checkout-locker-info-addr {
    font-size: 0.82rem;
    color: #555;
    margin-top: 2px;
}
.checkout-locker-change-btn {
    background: none;
    border: 1px solid #0d7377;
    color: #0d7377;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.checkout-locker-change-btn:hover {
    background: #0d7377;
    color: #fff;
}

/* ============================================================
   Locker picker modal (Leaflet)
   ============================================================ */
#lockerPickerOverlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
#lockerPickerOverlay.lp-visible {
    opacity: 1;
    pointer-events: auto;
}
.lp-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
}
/* Picker modal — pełny ekran na mobile, duży na desktop */
.lp-modal {
    position: absolute;
    inset: 0;                       /* pełny ekran domyślnie */
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    background: #fff;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.lp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    /* safe area dla notch iOS */
    padding-top: max(12px, env(safe-area-inset-top));
}
.lp-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
}
.lp-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.lp-close:hover { background: #f0f0f0; }
/* Geowidget body */
.lp-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.lp-geowidget {
    flex: 1;
    width: 100%;
    height: 100%;
    display: block;
    min-height: 0;
}
.lp-loader {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #888;
    padding: 40px;
}
.lp-error {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.88rem;
    color: #c0392b;
    padding: 30px 20px;
    line-height: 1.6;
}

/* Desktop — też pełny ekran (geowidget sam w sobie jest duży i responsywny) */

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 500px) {
    .checkout-modal {
        /* Bottom sheet — przyklejony do dołu ekranu.
           Kiedy iOS otwiera klawiaturę, vv.height maleje i JS ustawia
           max-height = vv.height, co kurczy modal od góry bez żadnej
           skomplikowanej matematyki pozycjonowania. */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: none;
        width: 100%;
        max-width: 100%;
        max-height: 92dvh;
        max-height: 92vh; /* fallback */
        border-radius: 20px 20px 0 0;
    }

    /* Klawiatura otwarta — chowamy wskaźnik kroków (zysk ~55px)
       i zmniejszamy padding headera (zysk ~12px). Zamknięcie modal
       jest nadal możliwe przez X w headerze. */
    .checkout-modal.checkout-kbd-open .checkout-steps {
        display: none;
    }
    .checkout-modal.checkout-kbd-open .checkout-header {
        padding: 10px 16px;
    }
    .checkout-modal.checkout-kbd-open .checkout-title {
        font-size: 1rem;
    }
    .checkout-delivery-cards {
        flex-direction: column;
    }
    .checkout-delivery-card {
        flex-direction: row;
        gap: 10px;
        padding: 10px 14px;
    }
    .checkout-delivery-icon {
        font-size: 1.2rem;
    }
    .checkout-delivery-label {
        flex: 1;
        text-align: left;
    }
}
