/* Gift cards, memberships and promotions admin pages (and the Payment tab
   checkout panels). Uses the app shell tokens from app-shell.css. */

/* Tokens on :root, not only inside .cm-page: popups (<dialog> on <body>) and
   the public pages (/account, /member, /gift) use these classes too. Same
   teal and 40px controls as the appointment Payment tab. */
:root {
    --cm-accent: #0f766e;
    --cm-accent-hover: #0b5e58;
    --cm-accent-soft: #e3f2ef;
    --cm-border: #d6d3d1;
    --cm-muted: #57534e;
    --cm-surface: #ffffff;
    --cm-text: #1c2321;
    --cm-ok: #15803d;
    --cm-warn: #b45309;
    --cm-bad: #b91c1c;
    --cm-control: 40px;
}

.cm-page {
    display: grid;
    gap: 16px;
    padding: 12px 4px 32px;
    max-width: 1280px;
}

.cm-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cm-head h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
}

.cm-head p {
    margin: 2px 0 0;
    color: var(--cm-muted);
}

.cm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.cm-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--cm-border);
    border-radius: 16px;
    background: var(--cm-surface);
    min-width: 0;
}

.cm-card h2,
.cm-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.cm-split {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.cm-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.cm-field {
    display: grid;
    gap: 4px;
    min-width: 0;
    font-size: .82rem;
    font-weight: 600;
    color: var(--cm-muted);
}

.cm-field small {
    font-weight: 500;
}

.cm-field input:not([type=checkbox]):not([type=radio]),
.cm-field select,
.cm-field textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: var(--cm-control);
    padding: 8px 12px;
    border: 1px solid var(--cm-border);
    border-radius: 10px;
    background: #fff;
    color: var(--app-text, #1c2321);
    font: inherit;
    font-weight: 500;
}

.cm-field textarea {
    min-height: 72px;
    resize: vertical;
}

.cm-field input:focus,
.cm-field select:focus,
.cm-field textarea:focus {
    outline: none;
    border-color: var(--cm-accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}

.cm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: .88rem;
}

.cm-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--cm-accent);
}

/* Buttons: always visible (solid colors, no reliance on hover), like the
   Payment tab's Kendo buttons. Links styled as buttons keep these colors. */
.cm-btn,
a.cm-btn,
a.cm-btn:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--cm-control);
    padding: 0 18px;
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--cm-text);
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(28, 35, 33, .06);
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}

.cm-btn:hover,
a.cm-btn:hover {
    border-color: var(--cm-accent);
    background: #f7fdfc;
    color: var(--cm-text);
}

.cm-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .25);
}

.cm-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.cm-btn--primary,
a.cm-btn--primary,
a.cm-btn--primary:visited {
    border-color: var(--cm-accent);
    background: var(--cm-accent);
    color: #ffffff;
}

.cm-btn--primary:hover,
a.cm-btn--primary:hover {
    border-color: var(--cm-accent-hover);
    background: var(--cm-accent-hover);
    color: #ffffff;
}

.cm-btn--danger {
    border-color: #fca5a5;
    background: #ffffff;
    color: var(--cm-bad);
}

.cm-btn--danger:hover {
    border-color: var(--cm-bad);
    background: #fef2f2;
    color: var(--cm-bad);
}

.cm-btn--small {
    min-height: 32px;
    padding: 0 10px;
    font-size: .85rem;
}

.cm-btn .bx {
    font-size: 1.15rem;
}

.cm-search {
    display: flex;
    gap: 8px;
}

.cm-search input {
    flex: 1;
    min-width: 0;
    min-height: var(--cm-control);
    padding: 8px 12px;
    border: 1px solid var(--cm-border);
    border-radius: 10px;
    font: inherit;
}

.cm-list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 60vh;
    overflow: auto;
}

.cm-list button {
    color: var(--cm-text);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cm-border);
    border-radius: 12px;
    background: #fff;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.cm-list button:hover,
.cm-list button.is-active {
    border-color: var(--cm-accent);
    background: var(--cm-accent-soft);
}

.cm-list small {
    grid-column: 1 / -1;
    color: var(--cm-muted);
}

.cm-money {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

.cm-big {
    font-size: 2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.cm-muted {
    color: var(--cm-muted);
}

.cm-empty {
    padding: 24px;
    text-align: center;
    color: var(--cm-muted);
}

.cm-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    background: #f1efea;
    color: #44403c;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}

.cm-badge--ok { background: #dcfce7; color: #166534; }
.cm-badge--warn { background: #fef3c7; color: #92400e; }
.cm-badge--bad { background: #fee2e2; color: #991b1b; }
.cm-badge--info { background: #dbeafe; color: #1e40af; }

.cm-table-wrap {
    overflow-x: auto;
}

.cm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.cm-table th,
.cm-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--cm-border);
    text-align: left;
    vertical-align: top;
}

.cm-table thead th {
    color: var(--cm-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.cm-table .is-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cm-plus { color: var(--cm-ok); }
.cm-minus { color: var(--cm-bad); }

.cm-message {
    margin: 0;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: .9rem;
}

.cm-message:empty {
    display: none;
}

.cm-message--error { background: #fee2e2; color: #7f1d1d; }
.cm-message--ok { background: #dcfce7; color: #14532d; }
.cm-message--info { background: #f0fdfa; color: #134e4a; }

.cm-code {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 10px;
    background: #f0fdfa;
    color: #134e4a;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: .06em;
}

.cm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cm-chips button {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--cm-border);
    border-radius: 999px;
    background: #fff;
    color: var(--cm-text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.cm-chips button:hover {
    border-color: var(--cm-accent);
}

.cm-chips button.is-active {
    border-color: var(--cm-accent);
    background: var(--cm-accent);
    color: #fff;
}

.cm-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--cm-border);
}

.cm-tabs button {
    padding: 10px 14px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    font: inherit;
    font-weight: 700;
    color: var(--cm-muted);
    cursor: pointer;
}

.cm-tabs button.is-active {
    border-bottom-color: var(--cm-accent);
    color: var(--cm-accent);
}

.cm-dialog-body {
    display: grid;
    gap: 12px;
}

.cm-dialog-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--cm-border);
}

.cm-kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    margin: 0;
    font-size: .9rem;
}

.cm-kv dt {
    color: var(--cm-muted);
    font-weight: 600;
}

.cm-kv dd {
    margin: 0;
}

@media (max-width: 860px) {
    .cm-split {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media print {
    .app-topbar, .app-nav, .cm-noprint { display: none !important; }
    .cm-print-sheet { display: grid !important; }
}

/* Modal (<dialog>) and toasts from commerce.js */
.cm-modal {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 18px 20px;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(28, 35, 33, .25);
    font-family: var(--app-font, Poppins, system-ui, sans-serif);
    color: var(--app-text, #1c2321);
}

.cm-modal::backdrop {
    background: rgba(28, 35, 33, .45);
}

.cm-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cm-modal-head h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.cm-modal-close {
    border: 0;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #5f6b67;
}

.cm-modal-content {
    display: grid;
    gap: 12px;
    overflow: auto;
}

.cm-modal .cm-field input:not([type=checkbox]):not([type=radio]),
.cm-modal .cm-field select,
.cm-modal .cm-field textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #e4e0d8;
    border-radius: 10px;
    font: inherit;
}

.cm-modal .cm-field {
    display: grid;
    gap: 4px;
    font-size: .82rem;
    font-weight: 600;
    color: #5f6b67;
}

.cm-toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 20000;
    display: grid;
    gap: 8px;
}

.cm-toast {
    padding: 12px 16px;
    border-radius: 12px;
    background: #14532d;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}

.cm-toast--error { background: #7f1d1d; }
.cm-toast--info { background: #134e4a; }

/* Member card (customer membership and account pages): proof at the desk */
.mm-card {
    display: grid;
    gap: 10px;
    margin: 0 0 14px;
    padding: 18px 18px 14px;
    border-radius: 18px;
    background: linear-gradient(135deg, #065f46 0%, #0f766e 55%, #115e59 100%);
    box-shadow: 0 10px 24px rgba(6, 95, 70, .25);
    color: #fff;
}

.mm-card.is-due {
    background: linear-gradient(135deg, #991b1b 0%, #b91c1c 60%, #7f1d1d 100%);
    box-shadow: 0 10px 24px rgba(153, 27, 27, .25);
}

.mm-card.is-paused {
    background: linear-gradient(135deg, #57534e 0%, #78716c 60%, #44403c 100%);
    box-shadow: 0 10px 24px rgba(68, 64, 60, .2);
}

.mm-card-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mm-card-biz {
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    opacity: .9;
}

.mm-card-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    font-size: .85rem;
    font-weight: 700;
}

.mm-card-status .bx {
    color: #fcd34d;
}

.mm-card-name {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.mm-card-plan {
    font-size: 1rem;
    opacity: .95;
}

.mm-card-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mm-card-qr {
    flex: none;
    width: 132px;
    height: 132px;
    padding: 0;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.mm-card-meta {
    min-width: 0;
    font-size: .88rem;
    line-height: 1.5;
    opacity: .95;
}

.mm-card-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

.mm-card-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, .7);
    animation: mm-card-pulse 1.6s infinite;
}

.mm-card.is-due .mm-card-dot,
.mm-card.is-paused .mm-card-dot {
    background: #fde68a;
}

.mm-card-hint {
    margin: 0;
    font-size: .8rem;
    opacity: .85;
}

@keyframes mm-card-pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); }
    70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .mm-card-dot {
        animation: none;
    }
}

@media (max-width: 380px) {
    .mm-card-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

.cm-crown {
    color: #d97706;
    vertical-align: -1px;
}


/* Membership plan editor (memberships.js) */
.mb-checks { max-height: 200px; overflow: auto; border: 1px solid #e4e0d8; border-radius: 10px; padding: 8px; display: grid; gap: 2px; }
.mb-checks small { color: var(--cm-muted, #6b6b6b); }
.mb-filter { width: 100%; box-sizing: border-box; min-height: 38px; margin: 4px 0 6px; }
.mb-prices { max-height: 280px; padding: 0; }
.mb-prices table { margin: 0; }
.mb-prices input { width: 110px; text-align: right; }
.mb-prices-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.mb-prices-tools label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; white-space: nowrap; }
.mb-prices-tools input { width: 80px !important; min-width: 0; }
.mb-ai-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mb-checks [hidden] { display: none !important; }

/* Anything marked hidden stays hidden, whatever layout it has (tabs, split panes). */
.cm-page [hidden] { display: none !important; }
/* Same inside pop-up windows (e.g. "Repeats" options until ticked). */
dialog [hidden] { display: none !important; }
