/* ═══════════════════════════════════════════════════════════
   Ernos Chat Interface — Premium dark UI
   ═══════════════════════════════════════════════════════════ */

/* ─── Chat View Layout ──────────────────────────────── */
#view-chat.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.chat-header {
    text-align: center;
    padding: 30px 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-header .chat-avatar {
    font-size: 48px;
    margin-bottom: 8px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-6px);
    }
}

.chat-header h2 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--text-primary, #e8eaed);
    margin: 0 0 4px;
}

.chat-header p {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary, #9aa0a6);
    margin: 0;
}

/* ─── Connection Status ─────────────────────────────── */
.chat-connection {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 8px;
    transition: all 0.3s ease;
}

.chat-connection.connected {
    background: rgba(52, 168, 83, 0.15);
    color: #34a853;
}

.chat-connection.connecting {
    background: rgba(251, 188, 4, 0.15);
    color: #fbbc04;
}

.chat-connection.offline {
    background: rgba(234, 67, 53, 0.15);
    color: #ea4335;
}

.chat-connection .conn-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.chat-connection.connected .conn-dot {
    animation: pulse-green 2s infinite;
}

.chat-connection.connecting .conn-dot {
    animation: pulse-yellow 1s infinite;
}

@keyframes pulse-green {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

@keyframes pulse-yellow {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 4px #fbbc04;
    }

    50% {
        opacity: 0.5;
        box-shadow: none;
    }
}

/* ─── Messages Container ────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* ─── Message Bubbles ───────────────────────────────── */
.chat-msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: msgAppear 0.3s ease-out;
}

@keyframes msgAppear {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.ernos {
    align-self: flex-start;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-msg.ernos .msg-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.chat-msg.user .msg-avatar {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg.ernos .msg-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #e8eaed);
    border-top-left-radius: 4px;
}

.chat-msg.user .msg-content {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.25), rgba(118, 75, 162, 0.25));
    border: 1px solid rgba(102, 126, 234, 0.3);
    color: #fff;
    border-top-right-radius: 4px;
}

.msg-time {
    font-size: 0.7rem;
    color: var(--text-secondary, #9aa0a6);
    padding: 0 4px;
}

.chat-msg.user .msg-time {
    text-align: right;
}

/* ─── Markdown in Messages ──────────────────────────── */
.msg-content strong {
    font-weight: 600;
    color: #a8c7fa;
}

.msg-content em {
    font-style: italic;
    color: #c8acf0;
}

.msg-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    color: #a8d8a8;
}

.msg-content pre {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.msg-content pre code {
    background: none;
    padding: 0;
    font-size: 0.8rem;
}

.msg-content ul,
.msg-content ol {
    padding-left: 20px;
    margin: 6px 0;
}

.msg-content li {
    margin: 3px 0;
}

.msg-content a {
    color: #8ab4f8;
    text-decoration: none;
}

.msg-content a:hover {
    text-decoration: underline;
}

/* ─── Thinking Indicator ────────────────────────────── */
.chat-thinking {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    animation: msgAppear 0.3s ease-out;
}

.chat-thinking .msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    border-top-left-radius: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.6);
    animation: thinking 1.4s infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ─── Input Area ────────────────────────────────────── */
.chat-input-wrapper {
    padding: 16px 0 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input-container:focus-within {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary, #e8eaed);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    min-height: 24px;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* ─── Welcome Message ───────────────────────────────── */
.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary, #9aa0a6);
}

.chat-welcome .welcome-emoji {
    font-size: 60px;
    margin-bottom: 16px;
    display: block;
}

.chat-welcome h3 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: var(--text-primary, #e8eaed);
    margin: 0 0 8px;
}

.chat-welcome p {
    font-size: 0.85rem;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

.chat-welcome .suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.chat-welcome .suggestion-chip {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary, #9aa0a6);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.chat-welcome .suggestion-chip:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
    color: #a8c7fa;
}

/* ─── File Attachments ──────────────────────────────── */
.msg-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.msg-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 0.78rem;
    color: #8ab4f8;
    text-decoration: none;
}

.msg-file:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    #view-chat.active {
        padding: 0 12px;
    }

    .chat-msg {
        max-width: 92%;
    }

    .msg-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .msg-content {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .chat-header h2 {
        font-size: 1.2rem;
    }

    .chat-welcome .suggestions {
        flex-direction: column;
        align-items: center;
    }
}