﻿/* ===== WhatsApp-style thread UI ===== */

/* ── Topbar ── */
.wa-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.wa-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ── Back button ── */
.wa-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px 6px 8px;
    border-radius: 8px;
    background: rgba(0,0,0,0.06);
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.15s;
}

    .wa-back-btn:hover {
        background: rgba(0,0,0,0.13);
    }

/* ── Filter bar ── */
.wa-filter {
    margin-top: 10px;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    width: 100%;
}

.wa-filter-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

    .wa-filter-grid > div {
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 150px;
    }

.wa-filter label {
    font-size: .82em;
    font-weight: 500;
    opacity: .7;
    margin: 0;
    white-space: nowrap;
}

.wa-filter input[type="date"],
.wa-filter input[type="number"] {
    padding: 6px 9px;
    border: 1px solid #d0d0d0;
    border-radius: 7px;
    font-size: 0.9rem;
    background: #fafafa;
    outline: none;
    transition: border-color 0.15s;
}

    .wa-filter input[type="date"]:focus,
    .wa-filter input[type="number"]:focus {
        border-color: #25d366;
        background: #fff;
    }

/* Push refresh button to the far right */
.wa-filter-actions {
    margin-left: auto !important;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-width: unset !important;
}

    .wa-filter-actions button[type="submit"] {
        padding: 7px 18px;
        border: none;
        border-radius: 7px;
        background: #f0f0f0;
        font-weight: 500;
        font-size: 0.9rem;
        cursor: pointer;
        transition: background 0.2s, color 0.2s;
        white-space: nowrap;
    }

        .wa-filter-actions button[type="submit"]:hover {
            background: #e0e0e0;
        }

        .wa-filter-actions button[type="submit"].is-green {
            background: #22c55e;
            color: #fff;
        }

.wa-filter-error {
    color: #b00020;
    font-size: 0.88rem;
    align-self: center;
}

.wa-filter-flash {
    margin-top: 8px;
    font-size: 0.88rem;
    padding: 6px 10px;
    border-radius: 6px;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

    .wa-filter-flash.error {
        background: #fff1f2;
        color: #9f1239;
        border-color: #fecdd3;
    }

/* ── Thread wrapper ── */
.wa-thread-wrap {
    margin-top: 14px;
    width: 100%;
    max-width: none;
    border: 1px solid #e2e2e2;
    border-radius: 12px;
    overflow: hidden;
    background: #f6f6f6;
    position: relative;
}

/* ── Thread header ── */
.wa-thread-header {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.wa-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.wa-header-text {
    min-width: 0;
}

.wa-recipient {
    font-weight: 600;
}

.wa-lastseen {
    font-size: .9em;
    opacity: .75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-count {
    font-size: .9em;
    opacity: .75;
    white-space: nowrap;
}

/* ── Avatar ── */
.wa-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    flex-shrink: 0;
}

/* ── Send Template button ── */
.wa-send-template-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px 6px 9px;
    border-radius: 8px;
    background: #25d366;
    color: #fff;
    border: none;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

    .wa-send-template-btn:hover {
        background: #1ebe5d;
    }

/* ── Messages pane ── */
.wa-messages {
    padding: 14px;
    padding-bottom: 110px;
    height: calc(100vh - 330px);
    min-height: 360px;
    overflow-y: auto;
    background: radial-gradient(circle at 20px 20px, rgba(0,0,0,0.035) 2px, transparent 3px) 0 0/44px 44px, radial-gradient(circle at 6px 32px, rgba(0,0,0,0.025) 1px, transparent 2px) 0 0/44px 44px, linear-gradient(to bottom, rgba(255,255,255,0.75), rgba(255,255,255,0.75));
}

@media (max-width: 640px) {
    .wa-messages {
        height: calc(100vh - 360px);
    }
}

/* ── Message rows ── */
.wa-row {
    display: flex;
    margin: 8px 0;
    align-items: flex-end;
}

    .wa-row.inbound {
        justify-content: flex-start;
    }

    .wa-row.outbound {
        justify-content: flex-end;
    }

/* ── Bubbles ── */
.wa-bubble {
    max-width: 100%;
    display: inline-block;
    padding: 10px 12px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    line-height: 1.35;
    word-wrap: break-word;
    position: relative;
    border: 1px solid rgba(0,0,0,0.04);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

    .wa-bubble.inbound {
        background: #fff;
        border-top-left-radius: 6px;
    }

    .wa-bubble.outbound {
        background: #dcf8c6;
        border-top-right-radius: 6px;
    }

    .wa-bubble.inbound::after {
        content: "";
        position: absolute;
        left: -7px;
        bottom: 10px;
        width: 0;
        height: 0;
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
        border-right: 7px solid #fff;
    }

    .wa-bubble.outbound::after {
        content: "";
        position: absolute;
        right: -7px;
        bottom: 10px;
        width: 0;
        height: 0;
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
        border-left: 7px solid #dcf8c6;
    }

/* ── Message meta (time / ticks) ── */
.wa-meta {
    margin-top: 6px;
    font-size: .82em;
    opacity: .75;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    white-space: nowrap;
}

    .wa-meta .wa-icon {
        opacity: .85;
        margin-left: 2px;
        margin-right: 2px;
    }

.wa-ticks {
    font-size: 1em;
    letter-spacing: -1px;
}

    .wa-ticks.read {
        color: #0b57d0;
    }

/* ── Details / expand ── */
.wa-details {
    flex: 0 0 auto;
    max-width: 55%;
    display: inline-flex;
    flex-direction: column;
    width: fit-content;
}

.wa-row.inbound .wa-details {
    margin-right: auto;
    align-items: flex-start;
}

.wa-row.outbound .wa-details {
    margin-left: auto;
    align-items: flex-end;
}

.wa-details > summary {
    list-style: none;
    cursor: pointer;
    margin: 0;
    width: fit-content;
    max-width: 100%;
}

    .wa-details > summary::-webkit-details-marker {
        display: none;
    }

    .wa-details > summary::marker {
        content: "";
    }

.wa-expand {
    margin-top: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
    background: rgba(255,255,255,0.9);
    font-size: 0.92em;
    line-height: 1.35;
}

/* ── Date pills ── */
.wa-date {
    margin: 12px 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

    .wa-date > div {
        font-size: .85em;
        padding: 6px 10px;
        border-radius: 999px;
        background: rgba(0,0,0,0.08);
        opacity: .85;
    }

.wa-sticky-date {
    position: sticky;
    top: 10px;
    z-index: 10;
    display: flex;
    justify-content: center;
    pointer-events: none;
    margin: 10px 0;
}

    .wa-sticky-date > div {
        font-size: .85em;
        padding: 6px 10px;
        border-radius: 999px;
        background: rgba(0,0,0,0.10);
        opacity: .9;
    }

/* ── Empty state ── */
.wa-empty {
    padding: 18px;
    opacity: .75;
    background: #fff;
}

/* ── Compose bar ── */
.wa-compose {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 12px;
    background: rgba(255,255,255,0.98);
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    gap: 10px;
    align-items: center;
}

    .wa-compose input[type="text"] {
        flex: 1 1 auto;
        padding: 12px 14px;
        border-radius: 999px;
        border: 1px solid rgba(0,0,0,0.14);
        outline: none;
    }

    .wa-compose button {
        border: none;
        border-radius: 999px;
        padding: 12px 14px;
        cursor: pointer;
        box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    }

/* ── Re-open FAB ── */
.wa-fab {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 20;
}

    .wa-fab button {
        border: none;
        border-radius: 999px;
        padding: 12px 14px;
        cursor: pointer;
        box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    }

        .wa-fab button:hover {
            transform: translateY(-1px);
        }

/* ── Modal backdrop ── */
.wa-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Modal box ── */
.wa-modal {
    background: #fff;
    border-radius: 12px;
    width: min(560px, 95vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    overflow: hidden;
}

.wa-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.wa-modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    transition: opacity 0.15s, background 0.15s;
}

    .wa-modal-close:hover {
        opacity: 1;
        background: rgba(0,0,0,0.07);
    }

.wa-modal-body {
    padding: 20px;
    overflow-y: auto;
}

.wa-modal-cancel {
    padding: 7px 16px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 0.9rem;
}

    .wa-modal-cancel:hover {
        background: #eaeaea;
    }

/* ── Refresh countdown badge ── */
.wa-refresh-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    opacity: 0.55;
    user-select: none;
}

/* ── ChatLog table ── */
.wa-dash-table-wrap {
    margin-top: 14px;
    border: 1px solid #e2e2e2;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.wa-dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
}

    .wa-dash-table thead tr {
        background: #f5f5f5;
    }

    .wa-dash-table th {
        text-align: left;
        padding: 9px 10px;
        border-bottom: 2px solid #e0e0e0;
        font-weight: 600;
        white-space: nowrap;
    }

    .wa-dash-table td {
        padding: 7px 10px;
        border-bottom: 1px solid #ececec;
        vertical-align: middle;
    }

    .wa-dash-table tbody tr:last-child td {
        border-bottom: none;
    }

    .wa-dash-table tbody tr:hover {
        filter: brightness(0.97);
    }

.wa-dash-nowrap {
    white-space: nowrap;
}

.wa-dash-center {
    text-align: center;
    font-size: 1.1em;
}

.wa-dash-sub {
    font-size: 0.85em;
    opacity: 0.65;
}

.wa-dash-preview {
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-dash-action {
    white-space: nowrap;
}

.wa-thread-link {
    display: inline-block;
    padding: 3px 10px;
    background: #0078d4;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.82em;
    white-space: nowrap;
    transition: background 0.15s;
}

    .wa-thread-link:hover {
        background: #005fa3;
    }

/* ── Filter select (shared) ── */
.wa-filter-select {
    padding: 6px 9px;
    border: 1px solid #d0d0d0;
    border-radius: 7px;
    font-size: 0.9rem;
    background: #fafafa;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}

    .wa-filter-select:focus {
        border-color: #25d366;
        background: #fff;
    }