/* ===================================
   CSS Variables
   =================================== */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f8fafc;
    --chat-bg: #ffffff;
    --message-user-bg: #6366f1;
    --message-user-text: #ffffff;
    --message-bot-bg: #f1f5f9;
    --message-bot-text: #1e293b;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ===================================
   Reset & Base
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ===================================
   Chat Container
   =================================== */
.chat-container {
    width: 100%;
    max-width: 480px;
    height: 90vh;
    max-height: 700px;
    background: var(--chat-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===================================
   Header
   =================================== */
.chat-header {
    padding: 16px 20px;
    background: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.bot-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-text h1 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-new-chat {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-new-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===================================
   Messages Area
   =================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* ===================================
   Messages
   =================================== */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: var(--message-bot-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.message.user .message-avatar {
    background: var(--primary-color);
    color: white;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
}

.message.bot .message-content {
    background: var(--message-bot-bg);
    color: var(--message-bot-text);
    border-bottom-left-radius: 4px;
}

.message.user .message-content {
    background: var(--message-user-bg);
    color: var(--message-user-text);
    border-bottom-right-radius: 4px;
}

.message-content p {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-time {
    display: block;
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.7;
}

/* ===================================
   Typing Indicator
   =================================== */
.typing-indicator {
    display: none;
    padding: 0 20px 10px;
    gap: 10px;
    align-items: center;
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--message-bot-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ===================================
   Input Area
   =================================== */
.chat-input-container {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--chat-bg);
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.chat-input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 120px;
    color: var(--text-primary);
}

.chat-input-wrapper textarea::placeholder {
    color: var(--text-secondary);
}

.btn-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    background: var(--primary-color);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-hover);
}

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

.btn-send:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.char-count {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===================================
   Error Message
   =================================== */
.message.error .message-content {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* ===================================
   Responsive
   =================================== */
@media (max-width: 520px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}