/* Explain: Shared UI component styles, including buttons, cards, badges, and notifications. */
/* Buttons */
.btn-mg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
    padding: 0.7rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    text-align: center;
    min-height: 44px;
    white-space: nowrap;
}
.btn-mg:active { transform: translateY(1px); }
.btn-mg-primary { background: var(--primary-color); color: #fff; box-shadow: var(--shadow-sm); }
.btn-mg-primary:hover { background: var(--primary-hover); }
.btn-mg-gold { background: var(--accent-color); color: #2a1d00; }
.btn-mg-gold:hover { background: var(--accent-hover); }
.btn-mg-outline { background: transparent; color: var(--text-color); border-color: var(--border-color); }
.btn-mg-outline:hover { border-color: var(--primary-color); color: var(--primary-color); background: var(--primary-soft); }
.btn-mg-ghost { background: transparent; color: var(--text-muted); }
.btn-mg-ghost:hover { background: var(--surface-alt); color: var(--text-color); }
.btn-mg-danger { background: var(--danger-soft); color: var(--danger-color); }
.btn-mg-danger:hover { background: var(--danger-color); color: #fff; }
.btn-mg-block { width: 100%; }
.btn-mg-lg { padding: 0.9rem 1.6rem; font-size: 1rem; }
.btn-mg-sm { padding: 0.5rem 0.85rem; font-size: 0.82rem; min-height: 38px; }
.btn-mg[disabled], .btn-mg.is-loading { opacity: 0.65; pointer-events: none; }

/* Cards */
.card-mg {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card-mg-pad { padding: 1.5rem; }
.card-mg-hover { transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease; }
.card-mg-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--primary-color) 30%, var(--border-color));
}

/* Badges */
.badge-mg {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
}
.badge-success { background: var(--primary-soft); color: var(--primary-color); }
.badge-pending { background: var(--warning-soft); color: var(--warning-color); }
.badge-danger { background: var(--danger-soft); color: var(--danger-color); }
.badge-neutral { background: var(--surface-alt); color: var(--text-muted); }
.badge-info { background: var(--secondary-soft); color: var(--secondary-color); }

/* Forms */
.field-mg { display: flex; flex-direction: column; gap: 0.4rem; }
.label-mg { font-size: 0.82rem; font-weight: 600; color: var(--text-color); }
.input-mg, .select-mg, .textarea-mg {
    width: 100%;
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text-color);
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    min-height: 44px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.input-mg::placeholder, .textarea-mg::placeholder { color: #9aa8a0; }
.input-mg:focus, .select-mg:focus, .textarea-mg:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary-color) 14%, transparent);
}
.textarea-mg { min-height: 110px; resize: vertical; }
.input-mg[disabled], .select-mg[disabled], .textarea-mg[disabled] {
    background: var(--surface-alt);
    color: var(--text-muted);
    cursor: not-allowed;
}
.hint-mg { font-size: 0.76rem; color: var(--text-muted); }

/* Nav */
.nav-mg-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.86);
    transition: color 0.18s ease, background 0.18s ease;
}
.nav-mg-link:hover { color: #fff; background: rgba(255, 255, 255, 0.16); }

/* Header */
.mg-header {
    background: linear-gradient(120deg, var(--primary-color), var(--secondary-color));
    border-bottom: 1px solid color-mix(in srgb, #000 14%, transparent);
}
.mg-header .btn-mg-outline {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.45);
    background: transparent;
}
.mg-header .btn-mg-outline:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: #fff;
    color: #fff;
}
.mg-header .btn-mg-ghost {
    color: rgba(255, 255, 255, 0.86);
}
.mg-header .btn-mg-ghost:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}
.mg-logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-color);
    font-size: 1.05rem;
    box-shadow: var(--shadow-sm);
    flex: 0 0 auto;
}
.mg-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
}
.mg-mobile-menu {
    border-top: 1px solid var(--border-color);
    background: #fff;
    box-shadow: var(--shadow-md);
}
.mobile-mg-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 0.9rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--text-color);
}
.mobile-mg-link:hover { background: var(--surface-color); }

/* Stats */
.stat-mg { display: flex; flex-direction: column; gap: 0.3rem; }
.stat-mg-value { font-family: var(--font-heading); font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-mg-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 1rem;
    flex: 0 0 auto;
}

/* Table */
.table-mg { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table-mg th {
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    white-space: nowrap;
}
.table-mg td { padding: 0.85rem 0.9rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table-mg tbody tr:hover { background: var(--surface-color); }
.table-mg tbody tr:last-child td { border-bottom: none; }

/* Alerts */
.alert-mg {
    display: flex;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    border: 1px solid transparent;
}
.alert-info { background: var(--secondary-soft); color: #0b4f4a; }
.alert-success { background: var(--primary-soft); color: var(--primary-hover); }
.alert-warning { background: var(--warning-soft); color: var(--warning-color); }
.alert-danger { background: var(--danger-soft); color: var(--danger-color); }

/* Toast */
#mgToastWrap {
    position: fixed;
    right: 1rem;
    bottom: 5.6rem;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 92vw;
}
.toast-mg {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    background: #10241a;
    color: #fff;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    animation: mgToastIn 0.25s ease;
}
.toast-mg.toast-success { background: var(--primary-color); }
.toast-mg.toast-error { background: var(--danger-color); }
.toast-mg.toast-info { background: #10241a; }
@keyframes mgToastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tabs */
.tab-mg {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}
.tab-mg:hover { background: var(--surface-color); color: var(--text-color); }
.tab-mg.is-active { background: var(--primary-soft); color: var(--primary-color); }

/* Action tiles */
.action-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
    min-height: 88px;
}
.action-tile i { font-size: 1.15rem; color: var(--primary-color); }
.action-tile:hover { border-color: var(--primary-color); background: var(--primary-soft); transform: translateY(-2px); }

/* Misc */
.chip-mg {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: var(--surface-alt);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}
.divider-mg { height: 1px; background: var(--border-color); border: 0; margin: 0; }
.link-mg { color: var(--primary-color); font-weight: 600; cursor: pointer; }
.link-mg:hover { text-decoration: underline; }
.amount-in { color: var(--primary-color); font-weight: 700; }
.amount-out { color: var(--danger-color); font-weight: 700; }
.empty-mg { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); font-size: 0.9rem; }
.footer-link { color: var(--text-muted); transition: color 0.18s ease; }
.footer-link:hover { color: var(--primary-color); }
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    flex: 0 0 auto;
}

/* Floating help chat */
.mg-chat { position: fixed; right: 1rem; bottom: 1rem; z-index: 80; }
.mg-chat-launcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 52px;
    padding: 0 1.1rem;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    border: 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    transition: background 0.18s ease, transform 0.18s ease;
}
.mg-chat-launcher:hover { background: var(--primary-hover); transform: translateY(-2px); }
.mg-chat-panel {
    position: absolute;
    right: 0;
    bottom: 64px;
    width: min(92vw, 360px);
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.mg-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
}
.mg-chat-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.mg-chat-close:hover { background: #fff; color: var(--text-color); }
.mg-chat-tabs { display: flex; gap: 0.25rem; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border-color); }
.mg-chat-body { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.6rem; overflow-y: auto; }
.mg-chat-log { display: flex; flex-direction: column; gap: 0.5rem; min-height: 120px; max-height: 40vh; overflow-y: auto; }
.mg-chat-msg { max-width: 86%; padding: 0.55rem 0.7rem; border-radius: 12px; font-size: 0.86rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.mg-chat-msg.assistant { background: var(--surface-color); color: var(--text-color); align-self: flex-start; border-bottom-left-radius: 4px; }
.mg-chat-msg.user { background: var(--primary-color); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.mg-chat-msg.mg-chat-typing { color: var(--text-muted); font-style: italic; }
.mg-chat-form { display: flex; gap: 0.4rem; }
.mg-chat-form .input-mg { min-height: 42px; }
.mg-chat-form .btn-mg { padding: 0.6rem 0.85rem; }
.mg-chat-note { font-size: 0.76rem; color: var(--text-muted); }
.mg-chat-note .link-mg { background: transparent; border: 0; padding: 0; cursor: pointer; font: inherit; }
/* Email-to-SMS gateway */
.gateway-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
}
.gateway-row + .gateway-row { margin-top: 0.5rem; }
.gateway-addr {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    word-break: break-all;
    line-height: 1.45;
}
.sms-counter { font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.sms-counter.is-ok { color: var(--text-muted); }
.sms-counter.is-warn { color: var(--warning-color); }
.sms-counter.is-over { color: var(--danger-color); }

/* Live member-admin chat */
.lc-log {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem;
    min-height: 340px;
    max-height: 56vh;
    overflow-y: auto;
    background: var(--surface-color);
}
.lc-msg {
    max-width: 78%;
    padding: 0.6rem 0.8rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.lc-msg.me { align-self: flex-end; background: var(--primary-color); color: #fff; border-bottom-right-radius: 4px; }
.lc-msg.them { align-self: flex-start; background: #fff; border: 1px solid var(--border-color); color: var(--text-color); border-bottom-left-radius: 4px; }
.lc-msg .lc-meta { display: block; margin-top: 0.3rem; font-size: 0.68rem; opacity: 0.75; }
.lc-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.85rem;
    flex: 0 0 auto;
}
.lc-thread {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    width: 100%;
    text-align: left;
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.lc-thread:hover { background: var(--surface-color); }
.lc-thread.is-active { border-color: var(--primary-color); background: var(--primary-soft); }
.lc-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent-color);
    color: #2a1d00;
    font-size: 0.68rem;
    font-weight: 800;
    flex: 0 0 auto;
}

/* Notification bell */
.mg-notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent-color);
    color: #2a1d00;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.mg-header .mg-notif-badge { box-shadow: 0 0 0 2px var(--primary-color); }
.mg-admin-notif #mgAdminNotifBtn { color: var(--accent-color); }
.mg-admin-notif #mgAdminNotifBtn:hover { color: #fff; background: rgba(255, 255, 255, 0.16); }
.mg-admin-notif .mg-notif-badge { background: #fff; color: var(--primary-color); box-shadow: 0 0 0 2px var(--primary-color); }
.mg-admin-notif .mg-notif-head { background: var(--surface-color); }
.mg-notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: min(360px, 88vw);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 70;
    overflow: hidden;
}
.mg-notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}
.mg-notif-list { max-height: 60vh; overflow-y: auto; }
.mg-notif-item {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: background 0.18s ease;
}
.mg-notif-item:hover { background: var(--surface-color); }
.mg-notif-item.is-unread { background: var(--primary-soft); }
.mg-notif-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-alt);
    color: var(--primary-color);
    flex: 0 0 auto;
}
.mg-notif-item.is-unread .mg-notif-icon { background: #fff; }

/* Meetings */
.meeting-agenda { font-size: 0.9rem; color: var(--text-color); }
.meeting-agenda p { margin: 0 0 0.5rem; }
.meeting-agenda p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
    .mg-chat-launcher-label { display: none; }
    .mg-chat-launcher { padding: 0; width: 52px; justify-content: center; }
}

/* Membership card printing */
#mgPrintRoot { display: none; }
@media print {
    body.mg-printing > *:not(#mgPrintRoot) { display: none !important; }
    body.mg-printing #mgPrintRoot {
        display: block !important;
        padding: 24px;
        background: #ffffff;
    }
    body.mg-printing #mgPrintRoot .card-mg {
        border: 1px solid #dde7e1;
        box-shadow: none;
    }
}