/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    position: relative;
}

/* Fixed Header */
.chat-header {
    background-color: #2c3e50;
    color: white;
    padding: 15px;
    text-align: center;
    font-size: 1.2em;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

/* Scrollable Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f9f9f9;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 150px);
}

/* Fixed Input Area */
.chat-input-area {
    padding: 15px;
    background-color: white;
    border-top: 1px solid #ddd;
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

/* Message Bubbles */
.message {
    margin-bottom: 15px;
    max-width: 70%;
    padding: 12px 15px;
    border-radius: 8px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.customer-message {
    background-color: #3498db;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 0;
}

.agent-message {
    background-color: white;
    color: #333;
    margin-right: auto;
    border: 1px solid #ddd;
    border-bottom-left-radius: 0;
}

/* Message Timestamp */
.message-time {
    font-size: 0.7em;
    color: #7f8c8d;
    margin-top: 5px;
    text-align: right;
}

.agent-message .message-time {
    color: #95a5a6;
}

/* Input Elements */
#message-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 16px;
    resize: none;
    height: 45px;
    max-height: 120px;
    transition: height 0.2s;
}

/* Attachment Button */
.attachment-button {
    position: relative;
    background: none;
    border: none;
    font-size: 1.5em;
    color: #7f8c8d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

#file-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Send Button */
#send-button {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#send-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

#send-button:hover:not(:disabled) {
    background-color: #2980b9;
}

/* Image Message */
.image-message {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-top: 5px;
    display: block;
}

/* Image Preview */
.image-preview {
    display: none;
    margin-bottom: 10px;
    position: relative;
    width: fit-content;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    display: block;
}

.remove-image {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Input Wrapper */
.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Progress Bar */
.progress-bar {
    height: 5px;
    background: #ecf0f1;
    margin-top: 5px;
    border-radius: 5px;
    overflow: hidden;
    display: none;
}

.progress {
    height: 100%;
    background: #3498db;
    width: 0%;
    transition: width 0.3s;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    padding: 10px 15px;
    background-color: white;
    border-radius: 8px;
    margin-right: auto;
    border: 1px solid #ddd;
    width: fit-content;
    margin-bottom: 15px;
    font-size: 0.9em;
    color: #7f8c8d;
}

.typing-text {
    display: flex;
    align-items: center;
}

.typing-dots {
    display: inline-flex;
    margin-left: 5px;
}

.typing-dots span {
    height: 6px;
    width: 6px;
    background-color: #95a5a6;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: typing 1s infinite;
}

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

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

@keyframes typing {
    0% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
    100% { transform: translateY(0); }
}

/* Error Indicator */
.error-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 0 3px rgba(0,0,0,0.3);
}

/* Pending Message State */
.pending-message {
    opacity: 0.7;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 80%;
    }
    
    .chat-input-area {
        padding: 10px;
    }
    
    #message-input {
        padding: 10px 12px;
    }
}