/* =============================================================================
   chat_history.css — Painel lateral "Histórico de conversas" (index.php)
   ============================================================================= */

.chat-history-trigger {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px;
    border-radius: 50% !important;
    border: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: #1c1d1d !important;
    color: #fff !important;
    box-shadow: #a8a7a7 0 0 2px;
    cursor: pointer;
    transition: all .18s ease;
    padding: 0 !important;
}
.chat-history-trigger .material-symbols-outlined { font-size: 17px; }
.chat-history-trigger:hover,
.chat-history-trigger.is-open {
    background: linear-gradient(135deg, #f67503, #ff9a44) !important;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(246, 117, 3, .38);
}

.chp-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9400;
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
}
.chp-backdrop.show { opacity: 1; visibility: visible; }

.chp-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(370px, 92vw);
    z-index: 9500;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(420px 220px at 100% 0%, rgba(246, 117, 3, .18), transparent 62%),
        linear-gradient(180deg, #111827, #0c1220 65%, #0a0f1a);
    color: #fff;
    box-shadow: 18px 0 60px rgba(0, 0, 0, .38);
    transform: translateX(-104%);
    transition: transform .26s cubic-bezier(.2, .8, .2, 1);
    overflow: hidden;
}
.chp-panel.show { transform: none; }
body.chp-lock { overflow: hidden !important; }

.chp-head {
    padding: 18px 16px 13px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex-shrink: 0;
}
.chp-head-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chp-kicker {
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #ffb37a;
}
.chp-head h3 {
    margin: 5px 0 4px;
    font-family: 'Montserrat', 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: #fff;
}
.chp-company {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .10);
    font-size: 9.5px;
    font-weight: 700;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chp-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .06);
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .18s ease;
    flex-shrink: 0;
}
.chp-icon:hover { border-color: rgba(246, 117, 3, .55); color: #ffb37a; background: rgba(246, 117, 3, .10); }
.chp-icon i { font-size: 13px; }

.chp-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px 8px;
    flex-shrink: 0;
}
.chp-new {
    flex: 1;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #f67503, #ff9a44);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 7px 18px rgba(246, 117, 3, .28);
    transition: transform .16s ease, box-shadow .16s ease;
}
.chp-new:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(246, 117, 3, .36); }
.chp-new .material-symbols-outlined { font-size: 16px; }

.chp-search {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 4px 14px 9px;
    padding: 0 10px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(255, 255, 255, .05);
    flex-shrink: 0;
}
.chp-search .material-symbols-outlined { font-size: 16px; color: #8fa0bd; }
.chp-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
}
.chp-search input::placeholder { color: #7f8ea8; }

.chp-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2px 10px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(246, 117, 3, .45) transparent;
}
.chp-list::-webkit-scrollbar { width: 4px; }
.chp-list::-webkit-scrollbar-thumb { background: rgba(246, 117, 3, .45); border-radius: 99px; }
.chp-list::-webkit-scrollbar-track { background: transparent; }

.chp-day {
    position: sticky;
    top: -2px;
    z-index: 2;
    padding: 8px 5px 5px;
    background: linear-gradient(180deg, #0d1422 70%, transparent);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .10em;
    text-transform: uppercase;
    color: #71809b;
}
.chp-session {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, .07);
    background: rgba(255, 255, 255, .035);
    border-radius: 11px;
    padding: 9px 10px;
    margin-bottom: 6px;
    cursor: pointer;
    color: #fff;
    transition: all .16s ease;
}
.chp-session:hover { background: rgba(255, 255, 255, .065); border-color: rgba(246, 117, 3, .30); transform: translateY(-1px); }
.chp-session.active {
    border-color: rgba(246, 117, 3, .65);
    background: rgba(246, 117, 3, .12);
    box-shadow: 0 5px 16px rgba(246, 117, 3, .12);
}
.chp-s-top { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.chp-s-time { font-size: 9px; font-weight: 800; color: #8fa0bd; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chp-theme {
    font-size: 8px;
    font-weight: 900;
    border-radius: 5px;
    padding: 2px 6px;
    background: rgba(246, 117, 3, .16);
    color: #ffb37a;
    border: 1px solid rgba(246, 117, 3, .28);
    white-space: nowrap;
}
.chp-theme.general { background: rgba(148, 163, 184, .12); color: #aeb9c8; border-color: rgba(148, 163, 184, .20); }
.chp-theme.call { background: rgba(99, 102, 241, .16); color: #b9baff; border-color: rgba(99, 102, 241, .30); }
.chp-s-subject {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #e5eaf3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chp-s-meta {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 4px;
    font-size: 8.5px;
    color: #7f8ea8;
    font-weight: 700;
}
.chp-s-meta span { display: inline-flex; align-items: center; gap: 3px; }
.chp-s-meta i { font-size: 10px; color: #ffb37a; }

.chp-new-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 4px 0 8px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px dashed rgba(246, 117, 3, .45);
    background: rgba(246, 117, 3, .08);
    color: #ffb37a;
    font-size: 10px;
    font-weight: 700;
}
.chp-new-badge .material-symbols-outlined { font-size: 16px; }

.chp-empty {
    padding: 30px 16px;
    text-align: center;
    color: #8fa0bd;
}
.chp-empty i { display: block; font-size: 28px; color: #3b4a63; margin-bottom: 8px; }
.chp-empty strong { display: block; font-size: 12px; color: #cbd5e1; margin-bottom: 3px; }
.chp-empty span { display: block; font-size: 10px; line-height: 1.5; color: #71809b; }

.chp-skel {
    height: 62px;
    border-radius: 10px;
    margin-bottom: 7px;
    background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 37%, rgba(255,255,255,.04) 63%);
    background-size: 400% 100%;
    animation: chpShimmer 1.3s infinite;
}
@keyframes chpShimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.chp-foot {
    flex-shrink: 0;
    padding: 9px 15px 12px;
    border-top: 1px solid rgba(255, 255, 255, .06);
    font-size: 8.5px;
    color: #71809b;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chp-foot i { color: #f67503; }

.chp-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 10px);
    z-index: 9600;
    padding: 9px 14px;
    border-radius: 10px;
    background: #111827;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
    opacity: 0;
    pointer-events: none;
    transition: all .2s ease;
    max-width: 80vw;
    text-align: center;
}
.chp-toast.show { opacity: 1; transform: translate(-50%, 0); }

.chp-chat-loading {
    list-style: none;
    text-align: center;
    color: #8fa0bd;
    font-size: 11px;
    padding: 18px 8px;
    animation: chpPulse 1.2s ease-in-out infinite alternate;
}
@keyframes chpPulse { from { opacity: .45; } to { opacity: 1; } }

@media (max-width: 640px) {
    .chp-panel { width: 92vw; }
    .chp-head { padding-top: 14px; }
    .chp-head h3 { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .chp-panel, .chp-backdrop, .chp-session, .chp-new { transition: none !important; animation: none !important; }
}
