﻿/* ==========================================================================
   History page (تاریخچه پیام‌ها) — scoped entirely under .hist-*
   Loaded only on this page via the Styles section, so it can never
   collide with dashboard.css or any other page's rules.
   Reuses the shared design tokens defined in dashboard.css (:root vars).
   ========================================================================== */

.content.hist-mode {
    padding: 0;
    overflow: hidden;
    height: 100%;
}

.hist-app {
    display: flex;
    height: 100%;
    min-height: 0;
}

/* ==========================================================================
   Conversation list panel
   ========================================================================== */

.hist-list {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-inline-end: 1px solid rgba(246, 241, 228, 0.08);
    background: linear-gradient(180deg, var(--bg-panel), var(--bg-deep));
}

.hist-list-head {
    padding: 20px 18px 14px;
    border-bottom: 1px solid rgba(246, 241, 228, 0.07);
}

.hist-list-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.hist-list-title {
    font-size: 15.5px;
    font-weight: 800;
}

.hist-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--success);
    background: var(--success-dim);
    padding: 4px 10px;
    border-radius: 20px;
}

    .hist-live .hist-live-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--success);
        animation: hist-live-pulse 1.8s ease-in-out infinite;
    }

@keyframes hist-live-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.75);
    }
}

.hist-search {
    position: relative;
    margin-bottom: 12px;
}

    .hist-search svg {
        position: absolute;
        inset-inline-start: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 16px;
        height: 16px;
        color: rgba(246, 241, 228, 0.4);
        pointer-events: none;
    }

    .hist-search input {
        width: 100%;
        background: rgba(246, 241, 228, 0.06);
        border: 1.5px solid rgba(246, 241, 228, 0.1);
        border-radius: 10px;
        padding: 10px 14px 10px 36px;
        color: var(--cream);
        font-family: var(--font-body);
        font-size: 13.5px;
    }

        .hist-search input::placeholder {
            color: rgba(246, 241, 228, 0.35);
        }

        .hist-search input:focus {
            outline: none;
            border-color: var(--accent-turquoise);
            background: rgba(246, 241, 228, 0.09);
        }

.hist-tabs {
    display: flex;
    gap: 6px;
}

.hist-tab {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 700;
    color: rgba(246, 241, 228, 0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

    .hist-tab:hover {
        background: rgba(246, 241, 228, 0.05);
    }

    .hist-tab.is-active {
        background: var(--accent-turquoise-dim);
        color: var(--cream);
    }

    .hist-tab .hist-tab-count {
        font-size: 10.5px;
        background: rgba(246, 241, 228, 0.12);
        padding: 1px 6px;
        border-radius: 20px;
    }

    .hist-tab.is-active .hist-tab-count {
        background: var(--accent-turquoise);
        color: #052220;
    }

.hist-list-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

    .hist-list-body::-webkit-scrollbar {
        width: 6px;
    }

    .hist-list-body::-webkit-scrollbar-thumb {
        background: rgba(246,241,228,0.12);
        border-radius: 6px;
    }

.hist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

    .hist-item:hover {
        background: rgba(246, 241, 228, 0.05);
    }

    .hist-item.is-active {
        background: var(--accent-turquoise-dim);
    }

.hist-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    color: #052220;
}

.hist-item.is-new .hist-avatar::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--accent-gold);
    animation: hist-ring 1.6s ease-out infinite;
}

@keyframes hist-ring {
    0% {
        transform: scale(0.9);
        opacity: 0.9;
    }

    100% {
        transform: scale(1.25);
        opacity: 0;
    }
}

.hist-online-dot {
    position: absolute;
    bottom: -1px;
    inset-inline-end: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--success);
    border: 2.5px solid var(--bg-panel);
}

.hist-item-body {
    flex: 1;
    min-width: 0;
}

.hist-item-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.hist-item-name {
    font-size: 13.8px;
    font-weight: 700;
    color: var(--cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hist-item-time {
    font-size: 11px;
    color: rgba(246, 241, 228, 0.4);
    flex-shrink: 0;
}

.hist-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.hist-item-preview {
    font-size: 12.5px;
    color: rgba(246, 241, 228, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hist-item.is-active .hist-item-preview {
    color: rgba(246, 241, 228, 0.7);
}

.hist-unread {
    flex-shrink: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 20px;
    background: var(--accent-gold);
    color: #2a1c05;
    font-size: 10.5px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hist-empty-list {
    text-align: center;
    padding: 40px 20px;
    color: rgba(246, 241, 228, 0.4);
    font-size: 12.5px;
}

/* ==========================================================================
   Toast — "new message" notification (visual demo of webhook push)
   ========================================================================== */

.hist-toast {
    position: absolute;
    top: 18px;
    inset-inline-start: 50%;
    transform: translateX(-50%) translateY(-140%);
    background: var(--cream);
    color: var(--ink);
    padding: 10px 16px;
    border-radius: 30px;
    font-size: 12.5px;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 30;
    opacity: 0;
    transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2), opacity 0.35s ease;
    pointer-events: none;
}

    .hist-toast.is-visible {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }

    .hist-toast .dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--accent-gold);
    }

/* ==========================================================================
   Chat panel
   ========================================================================== */

.hist-chat {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-deep-2);
}

.hist-chat-active {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hist-new-chip {
    position: absolute;
    bottom: 88px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-turquoise);
    color: #052220;
    border: none;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 12.5px;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    animation: hist-chip-in 0.25s ease;
}

@keyframes hist-chip-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.hist-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: rgba(246, 241, 228, 0.4);
    text-align: center;
    padding: 30px;
}

    .hist-chat-empty svg {
        width: 56px;
        height: 56px;
        opacity: 0.35;
    }

    .hist-chat-empty .t1 {
        font-size: 15px;
        font-weight: 700;
        color: rgba(246,241,228,0.6);
    }

    .hist-chat-empty .t2 {
        font-size: 12.5px;
        max-width: 280px;
        line-height: 1.9;
    }

.hist-chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid rgba(246, 241, 228, 0.07);
    flex-shrink: 0;
}

    .hist-chat-head .hist-avatar {
        width: 38px;
        height: 38px;
        font-size: 13px;
    }

.hist-chat-head-name {
    font-size: 14.5px;
    font-weight: 800;
}

.hist-chat-head-sub {
    font-size: 11.5px;
    color: rgba(246, 241, 228, 0.45);
    direction: ltr;
    text-align: right;
}

.hist-chat-head-actions {
    margin-inline-start: auto;
    display: flex;
    gap: 8px;
}

.hist-chat-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid rgba(246,241,228,0.12);
    background: transparent;
    color: rgba(246,241,228,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

    .hist-chat-icon-btn:hover {
        border-color: var(--accent-turquoise);
        color: var(--cream);
    }

.hist-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 26px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background-image: radial-gradient( circle, rgba(214,169,75,0.05) 1px, transparent 1.2px ), linear-gradient( 180deg, var(--bg-deep-2), var(--bg-deep) );
    background-size: 18px 18px, 100% 100%;
}

    .hist-messages::-webkit-scrollbar {
        width: 6px;
    }

    .hist-messages::-webkit-scrollbar-thumb {
        background: rgba(246,241,228,0.1);
        border-radius: 6px;
    }

.hist-date-pill {
    align-self: center;
    background: rgba(246, 241, 228, 0.07);
    color: rgba(246, 241, 228, 0.55);
    font-size: 11px;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 20px;
    margin: 10px 0;
}

.hist-msg-row {
    display: flex;
    margin-bottom: 4px;
}

    .hist-msg-row.out {
        justify-content: flex-start;
    }

    .hist-msg-row.in {
        justify-content: flex-end;
    }

.hist-msg {
    max-width: 62%;
    padding: 10px 14px;
    font-size: 13.8px;
    line-height: 1.9;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 6px 16px -10px rgba(0,0,0,0.5);
    position: relative;
}

    .hist-msg .hist-msg-attachment {
        font-weight: 700;
        font-size: 12.5px;
        opacity: 0.85;
        margin-bottom: 4px;
    }

.hist-msg-photo-link {
    display: block;
    margin: -2px -2px 6px;
}

.hist-msg-photo {
    display: block;
    max-width: 260px;
    max-height: 260px;
    width: 100%;
    border-radius: 12px;
    object-fit: cover;
    cursor: zoom-in;
}

.hist-msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.hist-msg-row.in .hist-msg-file {
    background: rgba(23, 36, 43, 0.06);
}

.hist-msg-file-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.hist-msg-file-name {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hist-msg-file-download {
    flex-shrink: 0;
    opacity: 0.7;
}

.hist-msg-file:hover .hist-msg-file-download {
    opacity: 1;
}

.hist-msg .hist-msg-caption {
    white-space: pre-wrap;
}

.hist-msg .hist-msg-time {
    display: block;
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.65;
    text-align: left;
}

.hist-msg-row.out .hist-msg {
    background: linear-gradient(135deg, var(--accent-turquoise), #1f918d);
    color: #052220;
    border-radius: 16px 16px 16px 4px;
}

.hist-msg-row.in .hist-msg {
    background: var(--cream);
    color: var(--ink);
    border-radius: 16px 16px 4px 16px;
}

.hist-attach-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 22px 10px;
    padding: 8px 12px;
    background: rgba(214, 169, 75, 0.1);
    border: 1px solid rgba(214, 169, 75, 0.3);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--cream);
}

    .hist-attach-preview .hist-attach-name {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .hist-attach-preview .hist-attach-remove {
        background: transparent;
        border: none;
        color: var(--danger);
        cursor: pointer;
        font-size: 13px;
        font-weight: 700;
    }

.hist-chat-composer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid rgba(246, 241, 228, 0.07);
    flex-shrink: 0;
}

    .hist-chat-composer input {
        flex: 1;
        background: rgba(246, 241, 228, 0.06);
        border: 1.5px solid rgba(246, 241, 228, 0.12);
        border-radius: 24px;
        padding: 12px 18px;
        color: var(--cream);
        font-family: var(--font-body);
        font-size: 13.8px;
    }

        .hist-chat-composer input::placeholder {
            color: rgba(246,241,228,0.35);
        }

        .hist-chat-composer input:focus {
            outline: none;
            border-color: var(--accent-turquoise);
        }

.hist-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent-turquoise), #1c8783);
    color: #052220;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 8px 18px -8px rgba(47,180,176,0.6);
}

/* ==========================================================================
   Responsive: stack list above chat on small screens
   ========================================================================== */

@media (max-width: 860px) {
    .hist-app {
        flex-direction: column;
    }

    .hist-list {
        width: 100%;
        height: 44%;
        border-inline-end: none;
        border-bottom: 1px solid rgba(246,241,228,0.08);
    }

    .hist-chat {
        flex: 1;
    }

    .hist-list.is-hidden-mobile {
        display: none;
    }

    .hist-chat.is-hidden-mobile {
        display: none;
    }
}
