/* ---------------------------------------------------------------------------
   outreach-compose.css — WM Outreach Stage C.

   The rich-text editor (kp-rte) plus the compose extras that sit around it:
   the template picker, the attachment tray and the signature toggle.

   Shared-component CSS lives here rather than in a <style> block, per the
   frontend convention. Colours are tokens only — there is a hex-code gate.
   --------------------------------------------------------------------------- */

/* ---- Rich text editor ---------------------------------------------------- */

.kp-rte {
    position: relative;
    border: 1px solid var(--kp-gray-25);
    border-radius: 4px;
    background: var(--kp-white);
}

.kp-rte__toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--kp-space-1);
    padding: var(--kp-space-1) var(--kp-space-2);
    border-bottom: 1px solid var(--kp-gray-20);
    background: var(--kp-gray-10);
    border-radius: 4px 4px 0 0;
}

.kp-rte__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 28px;
    padding: 0 var(--kp-space-1);
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--kp-gray-70);
    font-size: var(--kp-fs-small);
    cursor: pointer;
}

.kp-rte__btn:hover:not(:disabled) {
    background: var(--kp-white);
    border-color: var(--kp-gray-25);
    color: var(--kp-text);
}

.kp-rte__btn:focus-visible {
    outline: 2px solid var(--kp-accent);
    outline-offset: 1px;
}

.kp-rte__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.kp-rte__btn--text {
    min-width: auto;
    padding: 0 var(--kp-space-2);
    font-weight: var(--kp-fw-medium);
}

.kp-rte__sep {
    width: 1px;
    height: 18px;
    margin: 0 var(--kp-space-1);
    background: var(--kp-gray-25);
}

.kp-rte__linkbar {
    display: flex;
    align-items: center;
    gap: var(--kp-space-2);
    padding: var(--kp-space-2);
    border-bottom: 1px solid var(--kp-gray-20);
    background: var(--kp-gray-10);
}

.kp-rte__linkbar .form-control {
    flex: 1 1 auto;
}

.kp-rte__surface {
    min-height: 120px;
    max-height: 380px;
    overflow-y: auto;
    padding: var(--kp-space-3);
    font-family: var(--kp-font-body);
    font-size: var(--kp-fs-body);
    color: var(--kp-text);
    line-height: 1.5;
}

/* A compose box wants room to write; a signature is three lines. */
.kp-rte--tall .kp-rte__surface {
    min-height: 220px;
}

.kp-rte__surface:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--kp-accent);
}

.kp-rte__surface--disabled {
    background: var(--kp-gray-10);
    color: var(--kp-text-muted);
}

.kp-rte__surface p {
    margin: 0 0 var(--kp-space-2);
}

.kp-rte__surface ul,
.kp-rte__surface ol {
    margin: 0 0 var(--kp-space-2);
    padding-left: var(--kp-space-6);
}

.kp-rte__surface a {
    color: var(--kp-blue-primary);
}

/* Sits over the surface, so it must not swallow the click that focuses it. */
.kp-rte__placeholder {
    position: absolute;
    top: 46px;
    left: var(--kp-space-3);
    color: var(--kp-text-muted);
    font-size: var(--kp-fs-body);
    pointer-events: none;
}

/* ---- Compose extras ------------------------------------------------------ */

.kp-compose__row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--kp-space-2);
    margin-top: var(--kp-space-2);
}

.kp-compose__spacer {
    flex: 1 1 auto;
}

.kp-compose__hint {
    color: var(--kp-text-muted);
    font-size: var(--kp-fs-small);
}

/* The real <input type="file">, driven by the styled label next to it. Hidden with
   clip rather than display:none so it stays focusable by keyboard. */
.kp-compose__file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.kp-compose__attach-btn {
    margin: 0;
    cursor: pointer;
}

.kp-compose__file-input:focus-visible + .kp-compose__attach-btn {
    outline: 2px solid var(--kp-accent);
    outline-offset: 1px;
}

.kp-compose__attachments {
    display: flex;
    flex-direction: column;
    gap: var(--kp-space-1);
    margin-top: var(--kp-space-2);
}

.kp-compose__attachment {
    display: flex;
    align-items: center;
    gap: var(--kp-space-2);
    padding: var(--kp-space-1) var(--kp-space-2);
    border: 1px solid var(--kp-gray-20);
    border-radius: 3px;
    background: var(--kp-gray-10);
    font-size: var(--kp-fs-small);
}

.kp-compose__attachment--rejected {
    border-color: var(--kp-danger);
    background: var(--kp-danger-tint);
    color: var(--kp-danger-deep);
}

.kp-compose__attachment-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kp-compose__attachment-size {
    color: var(--kp-text-muted);
}

.kp-compose__remove {
    border: none;
    background: transparent;
    color: var(--kp-gray-60);
    cursor: pointer;
}

.kp-compose__remove:hover {
    color: var(--kp-danger);
}

/* Total-size meter: turns red before the send is refused, so the rep finds out
   while they can still remove something. */
.kp-compose__total {
    font-size: var(--kp-fs-small);
    color: var(--kp-text-muted);
}

.kp-compose__total--over {
    color: var(--kp-danger-deep);
    font-weight: var(--kp-fw-bold);
}

@media (max-width: 768px) {
    .kp-rte__surface {
        max-height: 240px;
    }

    .kp-compose__row {
        align-items: flex-start;
    }
}

/* ---- Leads list (spec 7.6) ----------------------------------------------- */

.kp-lead__who {
    display: flex;
    flex-direction: column;
}

.kp-lead__title,
.kp-lead__sub {
    color: var(--kp-text-muted);
    font-size: var(--kp-fs-small);
}

/* Overdue is stated in colour AND by position (the default sort puts it first),
   so it does not rely on colour alone. */
.kp-lead__due--over {
    color: var(--kp-danger-deep);
    font-weight: var(--kp-fw-bold);
}

.kp-grid-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--kp-space-8) var(--kp-space-4);
    color: var(--kp-text-muted);
    text-align: center;
}

/* ---- Template admin ------------------------------------------------------ */

.kp-template__help {
    background: var(--kp-gray-10);
    border-radius: 4px;
}

.kp-template__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--kp-space-1);
}
