/* ==========================================================================
   MSA Address Book Pro — Frontend Styles  v6.1.0
   ========================================================================== */

/* ── Wrap & heading row ───────────────────────────────────────────────────── */
.msa-wrap {
    margin-top: 40px;
}

.msa-heading-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 4px;
}

.msa-heading-row h2 {
    margin: 0;
}

/* ── Address count indicator ──────────────────────────────────────────────── */
.msa-count-indicator {
    font-size: 12px;
    color: #666;
    background: #f1f1f1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 2px 10px;
    white-space: nowrap;
}

.msa-count-indicator.msa-count-at-limit {
    color: #b42318;
    background: #fdf0ef;
    border-color: #f4b9b6;
}

/* ── Shared card grid — desktop ───────────────────────────────────────────── */
.msa-grid,
.msa-checkout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin: 16px 0 28px;
}

/* ── Account page cards ───────────────────────────────────────────────────── */
.msa-card {
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    position: relative;
    transition: box-shadow 0.15s;
    min-height: 50px;
}

.msa-default-card {
    background: #fff;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.msa-secondary-card {
    background: #f9f9f9;
}

/* ── Checkout cards ───────────────────────────────────────────────────────── */
.msa-checkout-wrap {
    margin-bottom: 24px;
}

.msa-checkout-heading {
    font-size: 1rem;
    margin-bottom: 10px;
}

.msa-checkout-card {
    padding: 16px 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    position: relative;
    cursor: pointer;
    min-height: 50px;
    transition: border-color 0.15s, background 0.15s;
}

.msa-checkout-card:hover,
.msa-checkout-card:focus {
    border-color: #2271b1;
    outline: none;
}

.msa-checkout-card.msa-checkout-selected {
    border-color: #2271b1;
    background: #fff;
    box-shadow: 0 0 0 1px #2271b1;
}

/* ── Badge ────────────────────────────────────────────────────────────────── */
.msa-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #2271b1;
    color: #fff;
    padding: 3px 8px;
    font-size: 11px;
    line-height: 1.4;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Nickname ─────────────────────────────────────────────────────────────── */
.msa-nickname {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    padding-right: 70px; /* clear the badge */
}

/* ── Address text ─────────────────────────────────────────────────────────── */
.msa-address {
    margin-top: 6px;
    line-height: 1.6;
    font-size: 13px;
    color: #444;
}

/* ── Last used indicator ──────────────────────────────────────────────────── */
.msa-last-used {
    margin-top: 8px;
    font-size: 11px;
    color: #888;
    font-style: italic;
}

/* ── Action buttons (pill style, tap-friendly) ────────────────────────────── */
.msa-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.msa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    min-height: 36px;       /* tap-friendly */
    min-width: 44px;        /* tap-friendly */
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    border: 1px solid #ccc;
    border-radius: 20px;    /* pill shape */
    background: #fff;
    color: #333;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.msa-btn:hover,
.msa-btn:focus {
    background: #f0f0f0;
    border-color: #999;
    color: #111;
    outline: none;
    text-decoration: none;
}

.msa-btn--danger {
    border-color: #d9534f;
    color: #b42318;
    background: #fff;
}

.msa-btn--danger:hover,
.msa-btn--danger:focus {
    background: #fdf0ef;
    border-color: #b42318;
    color: #8d1a13;
}

/* ── Inline delete confirmation ───────────────────────────────────────────── */
.msa-delete-confirm {
    margin-top: 14px;
    padding: 12px 14px;
    background: #fdf0ef;
    border: 1px solid #f4b9b6;
    border-radius: 4px;
}

.msa-delete-confirm p {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #7a1f1a;
}

.msa-delete-confirm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Limit notice ─────────────────────────────────────────────────────────── */
.msa-limit-notice {
    padding: 12px 16px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    font-size: 13px;
    color: #5d4037;
    margin-bottom: 20px;
}

/* ── Client-side validation warning ──────────────────────────────────────── */
.msa-validation-warning {
    width: 100%;
    padding: 10px 14px;
    background: #fdf0ef;
    border: 1px solid #f4b9b6;
    border-radius: 4px;
    font-size: 13px;
    color: #7a1f1a;
    margin-bottom: 10px;
}

.msa-validation-warning strong {
    display: block;
    margin-bottom: 4px;
}

.msa-validation-warning ul {
    margin: 0;
    padding-left: 18px;
}

.msa-validation-warning li {
    margin: 2px 0;
}

/* ── Add-address form ─────────────────────────────────────────────────────── */
.msa-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.msa-row.full {
    grid-column: 1 / -1;
}

.msa-row label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
}

/* ── All form inputs & selects (account + modal) ─────────────────────────── */
.msa-form input,
.msa-form select,
#msa-edit-form input,
#msa-edit-form select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-height: 50px;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 1.4;
}

.msa-form select,
#msa-edit-form select {
    min-height: 50px;
    height: 50px;
}

/* ── Save-address checkbox block (checkout) ───────────────────────────────── */
.msa-save-address-wrap {
    margin: 16px 0;
    padding: 14px 18px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
}

.msa-save-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.msa-save-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.msa-nickname-wrap {
    margin-top: 12px;
}

.msa-nickname-wrap label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
}

.msa-nickname-wrap input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-height: 50px;
    box-sizing: border-box;
    font-size: 14px;
}

/* ── Edit modal ───────────────────────────────────────────────────────────── */
#msa-edit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99999;
    overflow-y: auto;
}

.msa-modal-inner {
    background: #fff;
    max-width: 700px;
    margin: 60px auto;
    padding: 30px;
    border-radius: 4px;
}

#msa-edit-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.msa-modal-actions {
    grid-column: 1 / -1;
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* ── Drag/drop placeholder ────────────────────────────────────────────────── */
.msa-placeholder {
    border: 2px dashed #999;
    border-radius: 4px;
    background: #fafafa;
    min-height: 50px;
}

/* ── No addresses message ─────────────────────────────────────────────────── */
.msa-no-addresses {
    color: #666;
    font-style: italic;
    margin-bottom: 20px;
}

/* ════════════════════════════════════════════════════════════════════════════
   MOBILE  (≤ 600 px)
   Checkout grid becomes a horizontal scroll strip so cards don't stack
   into tiny single-column slivers on phones.
   Account grid stays single-column (stacking is fine there).
════════════════════════════════════════════════════════════════════════════ */
@media ( max-width: 600px ) {

    /* Checkout cards: horizontal scroll strip */
    .msa-checkout-grid {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 14px;
        padding-bottom: 8px;   /* room for scrollbar on some browsers */
        /* Remove the desktop grid settings */
        grid-template-columns: unset;
    }

    .msa-checkout-card {
        flex: 0 0 240px;       /* fixed width so cards don't squash */
        scroll-snap-align: start;
    }

    /* Account grid: single column stack */
    .msa-grid {
        grid-template-columns: 1fr;
    }

    /* Add-address form: single column */
    .msa-form,
    #msa-edit-form {
        grid-template-columns: 1fr;
    }

    .msa-row.full {
        grid-column: 1;
    }

    /* Modal: full screen on mobile */
    .msa-modal-inner {
        margin: 20px 12px;
        padding: 20px 16px;
    }

    /* Make heading row stack */
    .msa-heading-row {
        flex-direction: column;
        gap: 6px;
    }
}
