/* /Account/Memory — "what Tapi knows" manager.
   Brand teal (var(--primary) = #00b3c9 family). Dark-mode aware via the
   surface tokens the manage layout already defines. */

.memory-page { padding-bottom: 3rem; }

.mem-loading { color: var(--subtitle-color, #64748b); padding: 2rem 0; }

/* Header */
.mem-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.mem-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 .25rem;
    display: flex;
    align-items: center;
    gap: .55rem;
    color: var(--title-color, #0f172a);
}
.mem-title i { color: var(--primary, #00b3c9); }
.mem-sub { color: var(--subtitle-color, #64748b); margin: 0; max-width: 46rem; font-size: .92rem; }
.mem-head-actions { display: flex; align-items: center; gap: .5rem; }

.memory-page .btn-primary {
    background: var(--primary, #00b3c9);
    border-color: var(--primary, #00b3c9);
}
.memory-page .btn-primary:hover {
    background: var(--primary-dark, #0090a3);
    border-color: var(--primary-dark, #0090a3);
}

/* Groups */
.mem-group { margin-bottom: 1.75rem; }
.mem-group-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 .15rem .55rem;
    border-bottom: 1px solid var(--card-border, rgba(0,0,0,.08));
    margin-bottom: .85rem;
}
.mem-group-head i { color: var(--primary, #00b3c9); width: 1.1rem; text-align: center; }
.mem-group-label { font-weight: 700; color: var(--title-color, #0f172a); }
.mem-group-count {
    background: var(--primary, #00b3c9);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    padding: .05rem .5rem;
    border-radius: 999px;
}
.mem-group-blurb { color: var(--subtitle-color, #94a3b8); font-size: .82rem; margin-left: .35rem; }
@media (max-width: 575px) { .mem-group-blurb { display: none; } }

.mem-group-cards { display: flex; flex-direction: column; gap: .6rem; }

/* Cards */
.mem-card {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    background: var(--card-bg, #fff);
    border: 1px solid var(--card-border, rgba(0,0,0,.1));
    border-radius: 12px;
    padding: .85rem 1rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.mem-card:hover {
    border-color: var(--primary, #00b3c9);
    box-shadow: 0 4px 14px rgba(0,179,201,.10);
}
.mem-card-body { flex: 1; min-width: 0; }
.mem-card-content { color: var(--text-color, #1f2937); line-height: 1.45; word-break: break-word; }
.mem-card-ctx {
    color: var(--subtitle-color, #64748b);
    font-size: .82rem;
    margin-top: .3rem;
    font-style: italic;
}
.mem-card-meta { color: var(--subtitle-color, #94a3b8); font-size: .74rem; margin-top: .4rem; }

.mem-card-actions { display: flex; gap: .25rem; flex-shrink: 0; }
.mem-icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--subtitle-color, #94a3b8);
    width: 32px; height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s ease;
    display: inline-flex; align-items: center; justify-content: center;
}
.mem-icon-btn:hover { background: rgba(0,179,201,.10); color: var(--primary, #00b3c9); border-color: rgba(0,179,201,.25); }
.mem-icon-btn.mem-del:hover { background: rgba(220,53,69,.10); color: #dc3545; border-color: rgba(220,53,69,.25); }

/* Empty state */
.mem-empty {
    text-align: center;
    padding: 3rem 1rem;
    border: 1px dashed var(--card-border, rgba(0,0,0,.15));
    border-radius: 16px;
    background: var(--card-bg, #fff);
}
.mem-empty i.fa-brain { font-size: 2.5rem; color: var(--primary, #00b3c9); opacity: .35; margin-bottom: .75rem; }

/* Modals */
.mem-modal { border: none; border-radius: 16px; }
.mem-modal .modal-header { border-bottom: 1px solid var(--card-border, rgba(0,0,0,.08)); }
.mem-modal .modal-footer { border-top: 1px solid var(--card-border, rgba(0,0,0,.08)); }
.mem-modal .form-control:focus, .mem-modal .form-select:focus {
    border-color: var(--primary, #00b3c9);
    box-shadow: 0 0 0 3px rgba(0,179,201,.15);
}
.mem-modal .btn-primary { background: var(--primary, #00b3c9); border-color: var(--primary, #00b3c9); }
.mem-modal .btn-primary:hover { background: var(--primary-dark, #0090a3); border-color: var(--primary-dark, #0090a3); }
.mem-or {
    text-align: center;
    color: var(--subtitle-color, #94a3b8);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* Toast */
.mem-toast {
    position: fixed;
    bottom: 1.5rem; left: 50%;
    transform: translateX(-50%) translateY(2rem);
    background: #0f172a; color: #fff;
    padding: .7rem 1.15rem;
    border-radius: 10px;
    font-size: .9rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 1090;
}
.mem-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.mem-toast-ok { background: var(--primary-dark, #0090a3); }
.mem-toast-err { background: #b91c1c; }

[data-theme="dark"] .mem-card { background: var(--card-bg, #2c3338); }
[data-theme="dark"] .mem-empty { background: var(--card-bg, #2c3338); }

/* ──────────────────────────────────────────────────────────────────────────
   Chat-page Memory pane (#chatMemoryRoot inside the settings modal).
   The chat page has no Bootstrap, so buttons + dialogs are styled here
   self-contained. Scoped to .chat-memory-root / .mem-overlay so the manage
   page keeps using Bootstrap.
   ────────────────────────────────────────────────────────────────────────── */
.chat-memory-root { padding: 4px 2px 8px; }
.chat-memory-root .mem-title { font-size: 1.35rem; }

/* Button fallbacks (no Bootstrap on chat page) */
.chat-memory-root .btn,
.mem-overlay .btn,
.mem-overlay .mem-btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    border: 1px solid transparent; border-radius: 9px;
    padding: .5rem .95rem; font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: all .15s ease; text-decoration: none; line-height: 1.2;
}
.chat-memory-root .btn-primary,
.mem-overlay .btn-primary { background: var(--primary, #00b3c9); color: #fff; }
.chat-memory-root .btn-primary:hover,
.mem-overlay .btn-primary:hover { background: var(--primary-dark, #0090a3); }
.mem-overlay .btn-danger { background: #dc3545; color: #fff; }
.mem-overlay .btn-danger:hover { background: #b91c1c; }
.mem-overlay .mem-btn-ghost { background: transparent; border-color: var(--card-border, rgba(0,0,0,.15)); color: var(--text-color, #334155); }
.mem-overlay .mem-btn-ghost:hover { background: rgba(0,0,0,.04); }

/* Ghost icon buttons in the pane header (export / import / clear) */
.mem-ghost-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 9px;
    background: transparent; border: 1px solid var(--card-border, rgba(0,0,0,.15));
    color: var(--subtitle-color, #64748b); cursor: pointer; transition: all .15s ease;
    text-decoration: none;
}
.mem-ghost-btn:hover { background: rgba(0,179,201,.10); color: var(--primary, #00b3c9); border-color: rgba(0,179,201,.3); }
.mem-ghost-btn.mem-clear:hover { background: rgba(220,53,69,.10); color: #dc3545; border-color: rgba(220,53,69,.3); }

/* Custom overlay dialogs (editor / confirm / import) — above the settings modal */
.mem-overlay {
    position: fixed; inset: 0; z-index: 100000;
    background: rgba(15,23,42,.55);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; animation: memFade .12s ease;
}
@keyframes memFade { from { opacity: 0; } to { opacity: 1; } }
.mem-dialog {
    width: 100%; max-width: 540px;
    background: var(--card-bg, #fff); color: var(--text-color, #1f2937);
    border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.35);
    overflow: hidden; animation: memPop .14s ease;
}
@keyframes memPop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.mem-dialog-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--card-border, rgba(0,0,0,.08));
}
.mem-dialog-head h3 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.mem-x { background: transparent; border: none; color: var(--subtitle-color, #94a3b8); cursor: pointer; font-size: 1rem; padding: .25rem; border-radius: 6px; }
.mem-x:hover { color: var(--text-color, #1f2937); }
.mem-dialog-body { padding: 1.15rem 1.25rem; }
.mem-dialog-foot {
    display: flex; justify-content: flex-end; gap: .6rem;
    padding: .9rem 1.25rem; border-top: 1px solid var(--card-border, rgba(0,0,0,.08));
}
.mem-flabel { display: block; font-weight: 600; font-size: .85rem; margin: 0 0 .35rem; color: var(--text-color, #334155); }
.mem-muted { color: var(--subtitle-color, #94a3b8); font-weight: 400; font-size: .85rem; }
.mem-input {
    width: 100%; padding: .6rem .75rem; border-radius: 9px;
    border: 1px solid var(--input-border, #d1d5db);
    background: var(--input-bg, #fff); color: var(--input-text, #1f2937);
    font-size: .92rem; font-family: inherit;
}
.mem-input:focus { outline: none; border-color: var(--primary, #00b3c9); box-shadow: 0 0 0 3px rgba(0,179,201,.15); }
textarea.mem-input { resize: vertical; }
.mem-frow { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: .9rem; }
@media (max-width: 520px) { .mem-frow { grid-template-columns: 1fr; } }
.mem-confirm-msg { margin: 0; color: var(--text-color, #334155); }
