/* =========================================================
   寂雨AI · 页面样式
   聊天窗口
   ========================================================= */

main {
    max-width: 900px;
}

.page-header {
    margin-bottom: 2.2rem;
}

.chat-container {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: var(--shadow-lg);
}

.chat-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--grad-cool);
}

.chat-box {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: min(58vh, 520px);
    padding: 1.5rem;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 70%);
    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar {
    width: 8px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: rgba(34, 197, 94, 0.25);
    border-radius: 99px;
}

/* 欢迎语 */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 2rem 1rem;
    text-align: center;
}

.welcome-message img {
    width: 96px;
    height: 96px;
    margin-bottom: 1.3rem;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(74, 222, 128, 0.7);
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.08), 0 18px 36px rgba(16, 50, 32, 0.16);
}

.welcome-message h2 {
    margin-bottom: 0.5rem;
    font-size: 1.65rem;
    background: var(--grad-text);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.welcome-message p {
    max-width: 460px;
    margin: 0 auto;
    color: var(--text-light);
    font-size: 0.95rem;
}

/* 消息 */
.message {
    display: flex;
    align-items: flex-end;
    max-width: 82%;
    animation: messageIn 0.32s var(--ease);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
}

.bot-message {
    margin-right: auto;
}

.message-content {
    position: relative;
    max-width: 100%;
    padding: 0.75rem 1.05rem 1.55rem;
    border-radius: 18px;
    line-height: 1.65;
    font-size: 0.95rem;
    word-wrap: break-word;
}

.user-message .message-content {
    border-top-right-radius: 6px;
    background: linear-gradient(135deg, #34d399, #16a34a);
    color: #fff;
    box-shadow: 0 10px 22px rgba(22, 163, 74, 0.28);
}

.bot-message .message-content {
    border-top-left-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: 0 6px 16px rgba(16, 50, 32, 0.06);
}

[data-theme="dark"] .bot-message .message-content {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.avatar {
    width: 38px;
    height: 38px;
    margin: 0 0.65rem;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--surface-2);
    align-self: flex-end;
    flex-shrink: 0;
}

.timestamp {
    position: absolute;
    right: 1.05rem;
    bottom: 0.4rem;
    font-size: 0.66rem;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.72);
}

.bot-message .timestamp {
    color: var(--text-faint);
}

/* 输入区 */
.input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

#userInput {
    flex: 1;
    min-width: 0;
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

#userInput::placeholder {
    color: var(--text-faint);
}

#userInput:focus {
    border-color: rgba(34, 197, 94, 0.65);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

#userInput:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#sendBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--grad);
    color: #04220f;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(34, 197, 94, 0.32);
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

#sendBtn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 14px 26px rgba(34, 197, 94, 0.42);
}

#sendBtn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

#sendBtn i {
    font-size: 1.05rem;
}

/* 点赞 */
#like {
    position: absolute;
    right: 20px;
    bottom: 86px;
    z-index: 10;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    background-color: var(--surface);
    background-image: url('../images/icon/like.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 52%;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform var(--transition), background-color var(--transition), box-shadow var(--transition);
}

#like:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow);
}

#like.pressed {
    background-image: url('../images/icon/like-pressed.png');
    background-color: #ff6b81;
    border-color: transparent;
}

/* 正在输入 */
.loading-indicator {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    align-self: flex-start;
    margin-left: 3.4rem;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.loading-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.55; }
    40% { transform: translateY(-6px); opacity: 1; }
}

@media (max-width: 768px) {
    .chat-box {
        height: min(62vh, 460px);
        padding: 1rem;
    }

    .welcome-message img {
        width: 80px;
        height: 80px;
    }

    .welcome-message h2 {
        font-size: 1.4rem;
    }

    .message {
        max-width: 90%;
    }

    .avatar {
        width: 32px;
        height: 32px;
        margin: 0 0.45rem;
    }

    .input-area {
        padding: 0.85rem 1rem;
    }

    #like {
        right: 14px;
        bottom: 78px;
        width: 42px;
        height: 42px;
    }
}
