/* Chat page styles - designed to work within base.html layout */

.chat-container {
    width: 100%;
    max-width: 900px;
    height: calc(100vh - 180px);
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
}

.chat-header p {
    font-size: 14px;
    opacity: 0.9;
}

#chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #f8f9fa;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

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

#chat-box::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-box::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#chat-box::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-content {
    padding: 15px 20px;
    border-radius: 18px;
    max-width: 70%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 15px;
}

.user {
    display: flex;
    justify-content: flex-end;
}

.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant {
    display: flex;
    justify-content: flex-start;
}

.assistant .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.typing-indicator {
    display: none;
    align-items: center;
    padding: 15px 20px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 70px;
    border: 1px solid #e0e0e0;
}

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

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: #667eea;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.chat-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
}

#user-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#send-btn {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#send-btn:active {
    transform: translateY(0);
}

#send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.welcome-message {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.welcome-message h2 {
    font-size: 28px;
    margin-bottom: 10px;
    color: #667eea;
}

.welcome-message p {
    font-size: 16px;
}

@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 120px);
        border-radius: 12px;
        margin: 0 10px;
    }

    .message-content {
        max-width: 85%;
        font-size: 14px;
    }

    #send-btn {
        padding: 12px 18px;
        font-size: 14px;
    }

    .chat-header h1 {
        font-size: 20px;
    }

    .chat-header p {
        font-size: 12px;
    }
}

/* Additional improvements */

.chat-container:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}


/* Loading state for send button */
#send-btn:disabled::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error message styling */
.error-message {
    background-color: #fee;
    color: #c33;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #c33;
    margin: 10px 0;
    font-size: 14px;
}

/* Success message for connection */
.connection-status {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: #4caf50;
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: none;
}

.connection-status.online {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

/* Copy code button for code blocks */
.message-content pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content code {
    font-family: 'Courier New', monospace;
    font-size: 14px;
}