﻿.chat-page {
    height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 2px;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

    .chat-title h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 700;
        color: #0f172a;
    }

    .chat-title .dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #22c55e;
        box-shadow: 0 0 0 3px rgba(34,197,94,.18);
    }

.chat-top-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    user-select: none;
}

    .btn:disabled {
        opacity: .6;
        cursor: not-allowed;
    }

.btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.btn-outline {
    background: transparent;
    border-color: #cbd5e1;
    color: #0f172a;
}

.btn-danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.btn-dark {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
}

.chat-shell {
    height: 78vh;
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    background: #0b1220;
    padding: 10px;
    box-shadow: 0 18px 40px rgba(0,0,0,.15);
}

.chat-log {
    border: none;
    flex: 1;
    overflow: auto;
    background: #0b1220;
    border-radius: 12px;
    padding: 14px;
}

.empty-state {
    opacity: .8;
    color: #cbd5e1;
    padding: 18px;
    text-align: center;
    border: 1px dashed rgba(203,213,225,.25);
    border-radius: 12px;
}

.chat-row {
    display: flex;
    margin: 10px 0;
}

    .chat-row.left {
        justify-content: flex-start;
    }

    .chat-row.right {
        justify-content: flex-end;
    }

.chat-bubble {
    max-width: min(72ch, 78%);
    padding: 10px 12px;
    border-radius: 2px 14px 14px 14px;
    line-height: 1.35;
    white-space: pre-wrap;
    font-size: 14px;
}

    .chat-bubble.user {
        background-color: lightgray;
        color: #111827;
        border: 1px solid rgba(148,163,184,.15);
        border-top-left-radius: 6px;
    }

    .chat-bubble.assistant {
        background-color: lightblue;
        color: #111827;
        border: 1px solid rgba(148,163,184,.15);
        border-top-right-radius: 6px;
    }

.chat-footer {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-input-shell {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(2,6,23,.85);
    border: 1px solid rgba(148,163,184,.18);
}

.chat-input {
    flex: 1;
    min-height: 46px;
    max-height: 140px;
    resize: vertical;
    border: 0;
    outline: none;
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(15,23,42,.75);
    color: #e5e7eb;
    font-size: 14px;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(45,212,191,.28);
    background: rgba(45,212,191,.18);
    color: #d1fffb;
    font-weight: 800;
    cursor: pointer;
}

    .send-btn:hover {
        background: rgba(45,212,191,.28);
    }

    .send-btn:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.chat-error {
    color: #fecaca;
    font-size: 13px;
    padding: 0 4px;
}

.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2,6,23,.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.history-modal {
    width: min(1200px, 95vw);
    height: min(760px, 92vh);
    background: #0b1220;
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 16px;
    box-shadow: 0 30px 90px rgba(0,0,0,.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-header {
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(148,163,184,.14);
}

.history-title h4 {
    margin: 0;
    color: #e5e7eb;
    font-size: 16px;
    font-weight: 800;
}

.history-title .muted {
    display: block;
    margin-top: 2px;
    color: #94a3b8;
    font-size: 12px;
}

.history-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-toolbar {
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid rgba(148,163,184,.14);
}

.history-search {
    flex: 1;
    border: 1px solid rgba(148,163,184,.18);
    background: rgba(15,23,42,.7);
    color: #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

.history-body {
    flex: 1;
    display: grid;
    grid-template-columns: 360px 1fr;
    min-height: 0;
}

.history-list {
    border-right: 1px solid rgba(148,163,184,.14);
    padding: 12px;
    overflow: auto;
}

.history-item {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(148,163,184,.12);
    background: rgba(15,23,42,.5);
    color: #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
}

    .history-item:hover {
        border-color: rgba(45,212,191,.22);
    }

    .history-item.active {
        border-color: rgba(45,212,191,.45);
        box-shadow: 0 0 0 3px rgba(45,212,191,.12);
    }

.history-item-title {
    font-weight: 800;
    font-size: 13px;
}

.history-item-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #94a3b8;
}

.history-preview {
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.preview-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-bottom: 10px;
}

.preview-log {
    flex: 1;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid rgba(148,163,184,.14);
    background: rgba(2,6,23,.55);
    padding: 10px;
    min-height: 0;
}

.preview-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid rgba(148,163,184,.10);
}

.preview-role {
    font-size: 12px;
    font-weight: 800;
    color: #93c5fd;
    text-transform: uppercase;
}

.preview-text {
    color: #e5e7eb;
    font-size: 13px;
    white-space: pre-wrap;
}

.preview-empty {
    height: 100%;
    border-radius: 12px;
    border: 1px dashed rgba(148,163,184,.18);
    display: grid;
    place-items: center;
    color: #94a3b8;
    padding: 20px;
}

.preview-hint {
    margin-top: 10px;
    color: #94a3b8;
    font-size: 12px;
}

.history-loading,
.history-empty {
    color: #94a3b8;
    padding: 14px;
}

.history-error {
    padding: 10px 16px;
    color: #fecaca;
    border-top: 1px solid rgba(148,163,184,.14);
}

.chat-bubble.thinking {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 10px 12px;
    background: #dbeafe;
    color: #001018;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0891b2;
    opacity: 0.35;
    animation: dotPulse 1.1s infinite;
}

.dot1 {
    animation-delay: 0s;
}

.dot2 {
    animation-delay: 0.15s;
}

.dot3 {
    animation-delay: 0.30s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    40% {
        transform: translateY(-3px);
        opacity: 1;
    }
}
