/* Shared storefront account UI, used by every template (template2, jayeat-template1, Eatandrepeat,
   template1, jayeat-template). Self-contained: no template fonts, form classes or Bootstrap; neutral greys
   so it suits every theme; primary buttons also get the template's own class (ui_button_classes()).
   Loaded by ui_dialog_script() in each footer and by the shared partials in views/shared/.
   1. dialogs + buttons (js/common/confirm-dialog.js)   2. saved addresses (js/common/address-book.js)
   3. order history table (views/shared/order_history_table.php) */

/* 1. dialogs + buttons */
body.ui-modal-open { overflow: hidden; }
.ui-modal { position: fixed; inset: 0; z-index: 10050; display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; background: rgba(17, 17, 17, .55); overflow-y: auto; }
.ui-modal.is-open { display: flex; }
.ui-modal__box { position: relative; width: 100%; max-width: 560px; background: #fff; border-radius: 12px; box-shadow: 0 16px 48px rgba(0, 0, 0, .25); text-align: left; color: #333; animation: ui-pop .16s ease-out; }
@keyframes ui-pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.ui-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid #eee; }
.ui-modal__title { margin: 0; font-size: 18px; font-weight: 700; color: #222; line-height: 1.3; }
.ui-modal__x { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: #888; font-size: 24px; line-height: 1; cursor: pointer; }
.ui-modal__x:hover { background: #f2f2f2; color: #222; }
.ui-modal__body { padding: 20px 24px 8px; }
.ui-modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid #eee; }
.ui-btn { display: inline-flex !important; align-items: center; justify-content: center; gap: 8px; min-height: 42px; margin: 0 !important; padding: 9px 22px !important; border: 0; border-radius: 6px; font-size: 15px; line-height: 1.3; text-decoration: none !important; white-space: nowrap; cursor: pointer; width: auto; }
:where(.ui-btn--primary) { background: #222; color: #fff; }
:where(.ui-btn--secondary) { background: #ececec; color: #333; }
.ui-btn--secondary:hover { filter: brightness(.96); }
.ui-btn[disabled] { opacity: .6; cursor: default; }
.ui-dialog .ui-modal__box { max-width: 420px; text-align: center; }
.ui-dialog .ui-modal__body { padding: 28px 28px 8px; }
.ui-dialog__icon { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: #f2f2f2; color: #444; font-size: 24px; margin-bottom: 14px; }
.ui-dialog.is-danger .ui-dialog__icon { background: #fdecea; color: #b3261e; }
.ui-dialog h4 { font-size: 19px; font-weight: 700; color: #222; margin: 0 0 8px; }
.ui-dialog p { color: #666; font-size: 14px; line-height: 1.5; margin: 0; }
.ui-dialog .ui-modal__foot { padding: 20px 28px 26px; border: 0; }
.ui-dialog .ui-modal__foot .ui-btn { flex: 1; }
.ui-dialog.is-danger .ui-dialog__ok { background: #b3261e !important; color: #fff !important; }
.ui-dialog.is-danger .ui-dialog__ok:hover { background: #8c1d17 !important; }
.ui-dialog.is-alert .ui-dialog__cancel { display: none !important; }
.ui-icon { display: inline-block; flex: none; width: 1em; height: 1em; vertical-align: -.125em; }
.ui-spin { animation: ui-spin 1s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
@media (max-width: 767px) {
    .ui-modal { padding-top: 4vh; }
    .ui-modal__foot .ui-btn { flex: 1; }
}

/* 2. saved addresses */
.ab { margin-bottom: 24px; font-size: 14px; color: #333; }
.ab-heading { font-weight: 700; font-size: 15px; color: #222; margin-bottom: 10px; }

.ab-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 10px;
    text-align: left;
    transition: border-color .15s, box-shadow .15s;
}
.ab-card.is-selectable { cursor: pointer; }
.ab-card.is-selectable:hover { border-color: #b5b5b5; }
.ab-card.ab-selected { border-color: #222; box-shadow: inset 0 0 0 1px #222; }

.ab-radio { flex: none; width: 18px !important; height: 18px !important; margin: 3px 0 0 !important; padding: 0 !important; accent-color: #222; cursor: pointer; }
.ab-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: #f3f3f3; color: #555; font-size: 17px; }

.ab-body { flex: 1; min-width: 0; }
.ab-line1 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-weight: 700; font-size: 15px; color: #222; line-height: 1.4; overflow-wrap: anywhere; }
.ab-line2 { margin-top: 2px; color: #666; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.ab-badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 10px; background: #efefef; color: #555; }

.ab-status { display: flex; align-items: flex-start; gap: 6px; margin-top: 10px; font-size: 13px; line-height: 1.4; color: #666; }
.ab-status .ui-icon { margin-top: 1px; font-size: 15px; }
.ab-status.ok { color: #2e7d32; }
.ab-status.error { color: #b3261e; }

.ab-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 0 -8px; }
.ab-link .ui-icon { font-size: 14px; }
.ab-link { display: inline-flex !important; align-items: center; gap: 6px; width: auto !important; min-height: 0; margin: 0 !important; padding: 5px 8px !important; border: 0 !important; border-radius: 6px; background: none !important; color: #555 !important; font-size: 13px; line-height: 1.3; cursor: pointer; }
.ab-link:hover, .ab-link:focus { background: #f2f2f2 !important; color: #111 !important; }
.ab-link.is-danger { color: #b3261e !important; }
.ab-link.is-danger:hover, .ab-link.is-danger:focus { background: #fdecea !important; }

.ab-add {
    display: flex !important;
    align-items: center;
    gap: 12px;
    width: 100% !important;
    margin: 0 !important;
    padding: 14px 18px !important;
    border: 1px dashed #c4c4c4 !important;
    border-radius: 10px;
    background: #fafafa !important;
    color: #333 !important;
    font-weight: 700;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.ab-add:hover, .ab-add:focus { background: #f2f2f2 !important; border-color: #999 !important; }
.ab-add__icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 1px solid #ddd; font-size: 17px; }
.ab-empty { color: #777; margin: 0 0 12px; }

/* add/edit dialog fields */
.ab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.ab-field { margin-bottom: 16px; }
.ab-field label { display: block; margin: 0 0 6px; font-weight: 600; font-size: 14px; color: #444; }
.ab-field input {
    display: block;
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid #d6d6d6;
    border-radius: 6px;
    background: #fff;
    color: #222;
    font-size: 15px;
    box-shadow: none;
    box-sizing: border-box;
}
.ab-field input:focus { outline: none; border-color: #222; box-shadow: 0 0 0 3px rgba(0, 0, 0, .08); }
.ab-hint { display: block; margin-top: 4px; font-size: 12px; color: #888; }
.ab-check { display: flex !important; align-items: center; gap: 10px; margin: 0 0 12px; font-weight: normal; color: #333; cursor: pointer; }
.ab-check input { margin: 0; width: 18px; height: 18px; accent-color: #222; }
.ab-error:not(:empty) { margin-bottom: 12px; padding: 10px 12px; border-radius: 6px; background: #fdecea; color: #b3261e; }

@media (max-width: 767px) {
    .ab-card { padding: 14px; gap: 12px; }
    .ab-grid { grid-template-columns: 1fr; }
}

/* checkout with saved addresses: the cards replace the typed address fields and their postcode
   feedback (those stay in the form, hidden, for the post; feedback shows on the selected card) */
#delivery_fields.ab-saved > :not(#address_book):not(.ab-keep) { display: none !important; }

/* profile page: default address summary (views/shared/default_address.php) */
.ab-summary { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border: 1px solid #e6e6e6; border-radius: 10px; background: #fafafa; text-align: left; }
.ab-summary__icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 1px solid #e6e6e6; font-size: 18px; color: #555; }
.ab-summary__text { flex: 1; min-width: 0; color: #333; line-height: 1.5; overflow-wrap: anywhere; }
.ab-summary__text strong { display: block; color: #222; }
.ab-summary .ui-btn { flex: none; white-space: nowrap; }
@media (max-width: 767px) {
    .ab-summary { flex-wrap: wrap; }
    .ab-summary .ui-btn { width: 100% !important; }
}

/* 3. order history table */
.oh-pages { text-align: right; margin-bottom: 8px; }
/* sized by its own column, not the screen: Eatandrepeat's content column is ~670 px on desktop */
.oh-wrap { container: oh / inline-size; overflow-x: auto; }
/* the templates' Bootstrap .table-responsive wrapper adds its own border on phones */
.table-responsive:has(> .oh-wrap) { border: 0 !important; margin: 0 !important; overflow: visible !important; }
.oh-table { width: 100%; border-collapse: collapse; background: none; font-size: 14px; color: #333; }
.oh-table th { padding: 10px 12px !important; border: 0 !important; border-bottom: 1px solid #e6e6e6 !important; background: none !important; color: #777 !important; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: left; white-space: nowrap; }
.oh-table td { padding: 14px 12px !important; border: 0 !important; border-bottom: 1px solid #f0f0f0 !important; background: none !important; vertical-align: middle !important; text-align: left; }
.oh-table tbody tr:hover td { background: #fafafa !important; }
.oh-table .oh-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.oh-date { white-space: nowrap; }
.oh-pill { display: inline-block; padding: 3px 10px; border-radius: 12px; background: #f2f2f2; color: #444; font-size: 12px; white-space: nowrap; }
.oh-stars { color: #f5a623; letter-spacing: 1px; white-space: nowrap; }
.oh-muted { color: #888; white-space: nowrap; }
.oh-actions { text-align: right !important; white-space: nowrap; }
.oh-actions .ui-btn { min-height: 34px; padding: 6px 14px !important; font-size: 13px; margin-left: 6px !important; }
.oh-empty { text-align: center !important; color: #777; padding: 40px 12px !important; }
.oh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@container oh (max-width: 720px) {
    /* too narrow for the columns: each order becomes a card */
    .oh-table thead { display: none; }
    .oh-table, .oh-table tbody, .oh-table tr, .oh-table td { display: block; width: 100%; }
    .oh-table tr { margin-bottom: 12px; padding: 6px 14px 12px; border: 1px solid #e6e6e6; border-radius: 10px; background: #fff; }
    .oh-table tbody tr:hover td { background: none !important; }
    .oh-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0 !important; text-align: right; }
    .oh-table td::before { content: attr(data-label); color: #777; font-size: 13px; text-align: left; }
    .oh-table td.oh-actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; border-bottom: 0 !important; padding-top: 12px !important; }
    .oh-table td.oh-actions::before, .oh-table td.oh-empty::before { display: none; }
    .oh-actions .ui-btn { margin: 0 !important; flex: 1; }
}
@container oh (min-width: 480px) and (max-width: 720px) {
    /* room for the details in two columns, actions across the bottom */
    .oh-table tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
    .oh-table td.oh-actions, .oh-table td.oh-empty { grid-column: 1 / -1; }
}
