/* =============================================================================
   Agent Meeko - CRM settings (General, Tags) and tag chips (22 Oct 2026)
   AM Navy: flat bordered cards, navy accents, Kudio fields, am-btn buttons.
   ============================================================================= */

/* ---- Page --------------------------------------------------------------------- */
.crm-settings { display: flex; flex-direction: column; }
/* Breathing room under the header's divider before the first card. */
.crm-settings__body { padding: var(--content-gap-top, 24px) var(--gutter, 24px) 32px; display: flex; flex-direction: column; gap: 16px; }
.crm-settings__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.record-tabs.crm-settings__tabs { margin: var(--content-gap-top, 24px) var(--gutter, 24px) 0; }
.record-tabs.crm-settings__tabs + .crm-settings__body { padding-top: 18px; }

/* ---- Card --------------------------------------------------------------------- */
.crm-card {
    border: 1px solid var(--border-default, #e4e7ec);
    border-radius: 5px;
    background: var(--surface-panel, #fff);
    overflow: hidden;
}
.crm-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: var(--surface-subtle, #f6f7fb);
    border-bottom: 1px solid var(--border-subtle, #eaecf0);
}
.crm-card__title { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--am-blue, #19213b); }
.crm-card__note { font-size: 12px; color: var(--text-muted, #667085); }
.crm-card__body { display: flex; flex-direction: column; gap: 16px; padding: 18px 18px 20px; }
.crm-card__foot { display: flex; justify-content: flex-end; padding: 0 18px 18px; }
.crm-card__muted { margin: 0; font-size: 13px; color: var(--text-muted, #667085); }
.crm-card > .crm-card__muted { padding: 0 18px 18px; }

/* ---- Reference preview -------------------------------------------------------- */
.crm-ref-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px dashed var(--border-strong, #d0d5dd);
    border-radius: 5px;
    background: var(--surface-subtle, #f6f7fb);
}
.crm-ref-preview__label { font-size: 12.5px; color: var(--text-muted, #667085); }
.crm-ref-preview__value {
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 15px;
    font-weight: 700;
    color: var(--am-blue, #19213b);
}

/* ---- Tags settings ------------------------------------------------------------ */
.crm-tag-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 16px; align-items: start; }
.crm-tag-add .kudio-field-group { grid-column: 1 / -1; margin: 0; }
.crm-tag-add__colour { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.crm-tag-add__label { font-size: 12.5px; font-weight: 600; color: var(--text-muted, #667085); }
.crm-tag-add__actions { display: flex; justify-content: flex-end; }

.crm-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-swatch {
    position: relative;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.12);
    transition: transform 0.3s ease, border-color 0.3s ease;
}
.crm-swatch:hover { transform: scale(1.08); }
.crm-swatch.is-on { border-color: var(--surface-panel, #fff); box-shadow: 0 0 0 2px var(--am-blue, #19213b); }
.crm-swatch:focus-visible { outline: none; box-shadow: var(--am-focus); }
.crm-swatch--custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-subtle, #f6f7fb);
    color: var(--text-muted, #667085);
    border: 1px dashed var(--border-strong, #d0d5dd);
    box-shadow: none;
    overflow: hidden;
}
.crm-swatch--custom input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.crm-tag-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-subtle, #eaecf0); }
.crm-tag-list__row {
    display: grid;
    grid-template-columns: minmax(110px, 180px) minmax(0, 1fr) 30px 32px;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle, #eaecf0);
}
.crm-tag-list__empty { padding: 18px 0 4px; font-size: 13px; color: var(--text-muted, #667085); }
.crm-tag-list__name {
    height: 34px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    font: inherit;
    font-size: 13.5px;
    color: var(--text-primary, #101828);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}
.crm-tag-list__name:hover { border-color: var(--border-default, #e4e7ec); }
.crm-tag-list__name:focus { outline: none; border-color: var(--am-blue, #19213b); background: var(--surface-panel, #fff); }
.crm-tag-list__name--fixed { display: inline-flex; align-items: center; }
.crm-tag-list__colour {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.15);
    overflow: hidden;
}
.crm-tag-list__colour input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.crm-tag-list__delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: none;
    color: var(--text-muted, #667085);
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease;
}
.crm-tag-list__delete:hover { color: var(--status-danger); border-color: var(--status-danger); }

.crm-confirm-pop {
    position: absolute;
    z-index: 4000;
    width: 280px;
    padding: 14px;
    border: 1px solid var(--border-default, #e4e7ec);
    border-radius: 5px;
    background: var(--surface-panel, #fff);
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14);
}
.crm-confirm-pop p { margin: 0 0 12px; font-size: 13px; color: var(--text-primary, #101828); }
.crm-confirm-pop__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- Chips (records and settings) --------------------------------------------- */
.crm-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 28px; }
.crm-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
.crm-tag__name { overflow: hidden; text-overflow: ellipsis; }
.crm-tag__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: -4px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
    cursor: pointer;
}
.crm-tag__remove:hover { background: rgba(255, 255, 255, 0.4); }
.crm-tags__empty { font-size: 13px; color: var(--text-muted, #667085); }
.crm-tags__add {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 10px;
    border: 1px dashed var(--border-strong, #d0d5dd);
    border-radius: 999px;
    background: none;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--am-blue, #19213b);
    cursor: pointer;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}
.crm-tags__add:hover { border-color: var(--am-blue, #19213b); background: var(--surface-subtle, #f6f7fb); }
.crm-tags-host { padding: 4px 0; }
.crm-tags-host__loading { font-size: 12.5px; color: var(--text-muted, #667085); }
.record-row--tags .crm-tags-host { padding: 6px 2px; }

/* ---- Picker (a small pop-up under the button) ---------------------------------- */
.crm-tag-picker {
    position: absolute;
    z-index: 4000;
    width: 240px;
    padding: 8px;
    border: 1px solid var(--border-default, #e4e7ec);
    border-radius: 5px;
    background: var(--surface-panel, #fff);
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14);
}
.crm-tag-picker__search {
    width: 100%;
    height: 34px;
    margin-bottom: 6px;
    padding: 0 10px;
    border: 1px solid var(--border-default, #e4e7ec);
    border-radius: 5px;
    font: inherit;
    font-size: 13px;
}
.crm-tag-picker__search:focus { outline: none; border-color: var(--am-blue, #19213b); }
.crm-tag-picker__list { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; }
.crm-tag-picker__row {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: 0;
    border-radius: 5px;
    background: none;
    font: inherit;
    font-size: 13px;
    text-align: left;
    color: var(--text-primary, #101828);
    cursor: pointer;
}
.crm-tag-picker__row:hover { background: var(--surface-subtle, #f6f7fb); }
.crm-tag-picker__row.is-on { font-weight: 600; }
.crm-tag-picker__dot { width: 12px; height: 12px; border-radius: 50%; }
.crm-tag-picker__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-tag-picker__tick { color: var(--am-blue, #19213b); }
.crm-tag-picker__empty { margin: 6px 4px; font-size: 12.5px; color: var(--text-muted, #667085); }

/* ---- Small screens ------------------------------------------------------------ */
@media (max-width: 720px) {
    .crm-settings__body { padding-left: 16px; padding-right: 16px; }
    .record-tabs.crm-settings__tabs { margin-left: 16px; margin-right: 16px; }
    .crm-settings__grid { grid-template-columns: 1fr; }
    .crm-tag-add { grid-template-columns: 1fr; }
    .crm-tag-list__row { grid-template-columns: minmax(0, 1fr) 30px 32px; }
    .crm-tag-list__preview { display: none; }
}

/* ---- Tag filter in list toolbars ----------------------------------------------- */
.crm-tag-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--am-field-height, 40px);
    padding: 0 10px;
    border: 1px solid var(--border-default, #e4e7ec);
    border-radius: 5px;
    background: var(--surface-panel, #fff);
    color: var(--text-muted, #667085);
}
.crm-tag-filter[hidden] { display: none; }
.crm-tag-filter:focus-within { border-color: var(--am-blue, #19213b); }
.crm-tag-filter__select {
    height: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 13px;
    color: var(--text-primary, #101828);
    cursor: pointer;
}
.crm-tag-filter__select:focus { outline: none; }

/* A select is as wide as its longest option, so one long tag name made the
   filter wider than a phone and dragged the whole page sideways with it. */
.crm-tag-filter { max-width: 100%; min-width: 0; }
.crm-tag-filter__select { min-width: 0; max-width: 240px; text-overflow: ellipsis; }

@media (max-width: 560px) {
    .crm-tag-filter { flex: 1 1 100%; }
    .crm-tag-filter__select { flex: 1; max-width: none; font-size: 16px; }
}

/* ---- RM-096: the account manager in Client details ------------------------- */

.account-manager-host { display: flex; flex-direction: column; gap: 8px; }

.account-manager__change { display: block; }
.account-manager__change .form-field__control { width: 100%; }
