/* ===== تنظیمات پایه ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0b0b0e;
    background: linear-gradient(145deg, #0a0a0d 0%, #121217 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    color: #e8e8e8;
}

/* ===== کانتینر اصلی چت ===== */
.chat-container {
    width: 100%;
    max-width: 480px;
    height: 95vh;
    max-height: 900px;
    background: #14141a;
    border: 1px solid #2a2a33;
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ===== هدر ===== */
.chat-header {
    background: #1c1c24;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2a33;
    flex-shrink: 0;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.robot-icon {
    font-size: 2rem;
    color: #ff3b3b;
    filter: drop-shadow(0 0 8px rgba(255, 59, 59, 0.4));
}

.header-info h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ff6b6b, #ff2e2e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status {
    font-size: 0.7rem;
    color: #4cd964;
    background: rgba(76, 217, 100, 0.15);
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 2px;
}

.clear-btn {
    background: none;
    border: none;
    color: #6b6b7a;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(255, 59, 59, 0.15);
    color: #ff3b3b;
}

/* ===== ناحیه پیام‌ها ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* اسکرول بار سفارشی */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #ff3b3b;
    border-radius: 10px;
}

/* ===== پیام‌ها ===== */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, #ff3b3b, #d32f2f);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 15px rgba(255, 59, 59, 0.3);
}

.bot-message .message-content {
    background: #1e1e28;
    border: 1px solid #2a2a33;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.message-content p {
    margin: 0;
}

/* دکمه کپی */
.copy-btn {
    background: none;
    border: none;
    color: #6b6b7a;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    align-self: flex-end;
    opacity: 0.6;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ff3b3b;
    opacity: 1;
}

.copy-btn.copied {
    color: #4cd964;
    opacity: 1;
}

.message-time {
    font-size: 0.6rem;
    color: #5a5a6a;
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .message-time {
    text-align: right;
}

/* ===== ورودی ===== */
.chat-input-area {
    background: #1c1c24;
    border-top: 1px solid #2a2a33;
    padding: 12px 16px 16px;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: #0d0d11;
    border: 1px solid #2a2a33;
    border-radius: 50px;
    padding: 4px 4px 4px 16px;
    transition: border 0.3s;
}

.input-wrapper:focus-within {
    border-color: #ff3b3b;
    box-shadow: 0 0 0 2px rgba(255, 59, 59, 0.15);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e8e8e8;
    font-size: 0.95rem;
    padding: 10px 0;
    font-family: inherit;
}

#userInput::placeholder {
    color: #5a5a6a;
}

#sendBtn {
    background: linear-gradient(135deg, #ff3b3b, #d32f2f);
    border: none;
    color: #fff;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(255, 59, 59, 0.3);
}

#sendBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(255, 59, 59, 0.5);
}

#sendBtn:active {
    transform: scale(0.95);
}

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

.footer-note {
    text-align: center;
    font-size: 0.65rem;
    color: #5a5a6a;
    margin-top: 10px;
}

/* ===== حالت بارگذاری ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #ff3b3b;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== واکنش‌گرایی ===== */
@media (max-width: 480px) {
    body {
        padding: 0;
    }
    .chat-container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
        border: none;
    }
    .chat-header {
        padding: 14px 16px;
    }
    .chat-messages {
        padding: 16px 12px;
    }
}
