/* Chat Page - Matches Global Style */

.chat-page-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 73px);
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Messages */
.message {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    max-width: 80%;
    line-height: 1.6;
    animation: messageSlide 0.2s ease;
}

.user-message {
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    color: white;
    margin-left: auto;
    align-self: flex-end;
}

.bot-message {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    margin-right: auto;
    align-self: flex-start;
}

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

/* Input Container - Wide and at bottom */
.chat-input-container {
    position: relative;
    background: var(--background-color);
    padding: 1rem 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
}

.image-upload-button {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
}

.image-upload-button:hover {
    background: var(--surface-color);
    color: var(--secondary-color);
}

.image-upload-button svg {
    width: 20px;
    height: 20px;
}

#userInput {
    flex: 1;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.625rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    background: var(--surface-color);
    transition: var(--transition);
    overflow: hidden;
}

#userInput:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

#sendButton {
    padding: 0.625rem 1.5rem;
    height: 44px;
    white-space: nowrap;
    flex-shrink: 0;
}

#sendButton.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#sendButton.loading {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.stop-icon {
    width: 20px;
    height: 20px;
}

/* Image Preview */
.image-preview {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    margin-bottom: 0.5rem;
}

.image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.image-container {
    position: relative;
    width: 120px;
    height: 80px;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.remove-image {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    padding: 0;
    line-height: 1;
}

.remove-image:hover {
    background: #dc2626;
}

.message-image {
    width: 200px;
    height: auto;
    border-radius: 8px;
    margin-top: 0.5rem;
}

/* Upload Error */
.upload-error {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #FEE2E2;
    color: #991B1B;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    animation: slideDown 0.3s ease;
}

.upload-error svg {
    width: 20px;
    height: 20px;
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -20px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-container {
        padding: 0 1rem;
    }

    .message {
        max-width: 90%;
    }

    .chat-input-container {
        padding: 0.75rem 0 1rem;
    }

    #userInput {
        font-size: 16px !important;
    }

    .image-container {
        width: 100px;
        height: 70px;
    }
}
