/*
 * pm-address-modal.css
 * ---------------------------------------------------------------------------
 * Shared styling for the reusable address-picker modal injected by
 * assets/pm/js/pm-address-modal.js (window.pmAddressModal).
 *
 * This is a faithful, renamed port of the `.addrx-*` rules that used to live
 * only inside main/account.php's own <style> block (there was never a
 * `.addrx-*` rule in the global style.css — it was page-local). Because the
 * modal now injects itself into document.body from a shared module instead
 * of living inside account.php markup, every selector is re-namespaced to
 * `.pmam-*` / `#pmAddrModal` so it cannot collide with the legacy
 * `.addrx-*` / `#addrxModal` block that is temporarily kept (commented out)
 * in main/account.php for rollback.
 *
 * Values (colors, spacing, radii, timings) are copied 1:1 from the legacy
 * rules — no visual redesign in Phase 1.
 */

#pmAddrModal .modal-header,
#pmAddrModal .modal-footer {
    padding: 12px 14px;
}

.pmam-modal-alert {
    margin: 12px 20px 0;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 600;
    border: 1px solid transparent;
}
.pmam-modal-alert.is-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}
.pmam-modal-alert.is-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}
.pmam-modal-alert.is-success {
    background: var(--theme-primary-soft, #d7ecdf);
    border-color: #bbe4cb;
    color: var(--theme-primary, #0c4c29);
}
.pmam-modal-alert.is-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.pmam-suggest-list {
    margin-top: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 25px rgba(15, 23, 42, .08);
    max-height: 220px;
    overflow-y: auto;
    font-size: .85rem;
}
/*
 * --compact: neo tuyệt đối theo wrapper position:relative sát input thay vì để trôi
 * theo dòng chảy tài liệu (không position/z-index như mặc định ở trên). Bắt buộc dùng
 * biến thể này khi input nằm trong modal Bootstrap (modal-dialog-centered áp transform
 * khi mở), để tránh gợi ý địa chỉ đè/che lên input hoặc nội dung phía dưới.
 */
.pmam-suggest-list--compact {
    position: absolute !important;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 4px;
    max-height: 180px;
    z-index: 2100;
}

.pmam-suggest-item {
    width: 100%;
    text-align: left;
    padding: 7px 12px;
    border: none;
    background: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    color: #374151;
    line-height: 1.4;
}
.pmam-suggest-item-main {
    font-weight: 500;
    font-size: .875rem;
    color: #111827;
}
.pmam-suggest-item-sub {
    font-size: .78rem;
    color: #6b7280;
}
.pmam-suggest-item:hover {
    background: #f0fdf4;
}
.pmam-suggest-item:hover .pmam-suggest-item-main {
    color: #0c4c29;
}

.pmam-map-wrap {
    position: relative;
}
.pmam-map {
    width: 100%;
    height: 220px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    background: #eef2f7;
}
/* Bản đồ gộp chung step 1 (xem lại/chỉnh ghim) chỉ cần thấp hơn bản đồ
   full-step trước đây, để không chiếm quá nhiều chỗ cùng khu vực giao hàng. */
.pmam-map--compact {
    height: 140px;
}
.pmam-map .leaflet-container {
    height: 100%;
    width: 100%;
    border-radius: 10px;
}
.pmam-map-gps {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    border-radius: 999px;
    background: #16613a;
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    padding: 7px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
    cursor: pointer;
}
.pmam-map-gps:hover { background: #11502f; }
.pmam-map-gps:disabled { opacity: .7; cursor: default; }

.pmam-contact-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.pmam-modal-label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--theme-primary, #0c4c29);
    font-size: .92rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.pmam-modal-label i {
    font-size: 1rem;
    color: var(--theme-primary, #0c4c29);
}
.pmam-contact-head .pmam-modal-label {
    margin-bottom: 0;
}
.pmam-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}
.pmam-field-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #374151;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.25;
}
.pmam-field-label i {
    font-size: .82rem;
    color: var(--theme-primary, #0c4c29);
}
.pmam-region-grid .form-select {
    min-height: 40px;
}
.pmam-phone-suggest {
    border: 0;
    background: transparent;
    color: var(--theme-primary, #0c4c29);
    font-size: .72rem;
    font-weight: 700;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.25;
    white-space: nowrap;
}
.pmam-phone-suggest:hover {
    color: var(--theme-primary-dark, #06391d);
    text-decoration: underline;
}
.pmam-phone-suggest i {
    font-size: .78rem;
}
.pmam-step-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pmam-step-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.pmam-step-dot::before {
    content: attr(data-step-dot);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-size: .72rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: background-color .2s ease, color .2s ease;
}
.pmam-step-dot.is-active::before {
    background: var(--theme-primary, #0c4c29);
    color: #fff;
}
.pmam-step-dot.is-done::before {
    background: var(--theme-primary-soft, #d7ecdf);
    color: var(--theme-primary, #0c4c29);
}
.pmam-step-dot-label {
    color: #6b7280;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.pmam-step-dot.is-active .pmam-step-dot-label {
    color: var(--theme-primary, #0c4c29);
}
.pmam-step-line {
    width: 24px;
    height: 1px;
    background: #e5e7eb;
    flex-shrink: 0;
}
.pmam-step2-summary {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--fb-bg, #f8fafc);
    border: 1px solid var(--order-border, #e5e7eb);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: .86rem;
    color: #374151;
}
.pmam-step2-summary i {
    color: var(--theme-primary, #0c4c29);
    font-size: 1rem;
    margin-top: 2px;
}

.pmam-input-desc {
    font-size: .78rem;
    color: #6b7280;
    margin-top: 6px;
}
.pmam-note {
    font-size: .8rem;
    color: #4b5563;
}

/* ===== Modal Địa chỉ — tinh gọn cho mobile =====
   Trên màn nhỏ: biến modal thành full-height sheet, body cuộn được,
   header + footer (nút Lưu/Hủy) luôn dính, không bị che.
   Dùng breakpoint 767.98px (thay vì 576px) vì modal-dialog-centered
   vẫn có thể đẩy đáy modal ra ngoài viewport ở màn hình rộng hơn 576px
   (điện thoại lớn/màn ngang, tablet nhỏ) — xác nhận qua ảnh chụp thực tế
   nút "Xác nhận vị trí này" vẫn bị cắt dù modal đã dạng thẻ bo góc. */
@media (max-width: 767.98px) {
    #pmAddrModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        min-height: 100%;
        /* dùng 100dvh để né thanh địa chỉ trình duyệt mobile */
        height: 100dvh;
        display: flex;
        align-items: stretch;
    }
    #pmAddrModal .modal-content {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: 0;
    }
    #pmAddrModal .modal-header,
    #pmAddrModal .modal-footer {
        flex: 0 0 auto;
        padding: 12px 14px;
    }
    #pmAddrModal .pmam-modal-alert {
        margin: 10px 14px 0;
    }
    #pmAddrModal .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 14px;
    }
    /* footer dính đáy, nền trắng để luôn nổi trên nội dung; chừa thêm
       safe-area cho các máy có thanh điều hướng cử chỉ (notch) */
    #pmAddrModal .modal-footer {
        position: sticky;
        bottom: 0;
        background: #fff;
        box-shadow: 0 -4px 12px rgba(15, 23, 42, .06);
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    #pmAddrModal .modal-footer .btn {
        flex: 1 1 auto;
    }
    /* thu gọn khoảng cách + bản đồ để thấy nhiều trường hơn */
    #pmAddrModal .modal-body .mb-3 {
        margin-bottom: .75rem !important;
    }
    #pmAddrModal .pmam-map {
        height: 150px;
    }
    #pmAddrModal .pmam-map--compact {
        height: 120px;
    }
    #pmAddrModal .pmam-input-desc {
        font-size: .72rem;
    }
    /* toastr mặc định neo top-right toàn trang (position:fixed) — khi modal
       này full-screen trên mobile, toast đè lên tiêu đề/step indicator.
       Đẩy toast xuống dưới header của modal trong lúc modal đang mở. */
    body.modal-open:has(#pmAddrModal.show) #toast-container.toast-top-right {
        top: 64px;
    }

    .pmam-step-dot-label {
        display: none;
    }
    .pmam-contact-head {
        margin-bottom: 6px;
    }
    .pmam-contact-head .pmam-modal-label {
        font-size: .88rem;
    }
    .pmam-field-head {
        margin-bottom: 3px;
    }
    .pmam-field-label {
        font-size: .74rem;
    }
    .pmam-region-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-left: 0;
        margin-right: 0;
    }
    .pmam-region-grid > [class*="col-"] {
        width: 100%;
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
    #pmAddrModal .pmam-region-grid .form-select {
        min-height: 38px;
        font-size: .9rem;
    }
    .pmam-phone-suggest {
        font-size: .7rem;
    }
}
