/* ============================================
   General Layout & Page Structure
============================================ */
body, html {
    height: 100%;
}

.card-header {
    position: sticky;
    top: 0;
    z-index: 1020;
}

.card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.messages-box {
    flex: 1;
    overflow-y: auto;
}

/* Custom Scrollbar */
.messages-box::-webkit-scrollbar { width: 8px; }
.messages-box::-webkit-scrollbar-track { background: #f8f9fa; }
.messages-box::-webkit-scrollbar-thumb { background: #ced4da; border-radius: 4px; }
.messages-box::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

/* ============================================
   Messages & Chat Bubbles
============================================ */
.messages-list {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    list-style: none;
    padding-left: 0;
}

.message {
    display: flex;
    margin-bottom: 15px;
}

.message-text {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.message.sent { justify-content: flex-end; }
.message.sent .message-text {
    background-color: #007bff;
    color: white;
}
.message.sent .message-sender b {
    color: rgba(255, 255, 255, 0.85);
}

.message.received { justify-content: flex-start; }
.message.received .message-text {
    background-color: #e9ecef;
    color: #343a40;
}
.message.received .message-sender b {
    color: #6c757d;
}

.message-sender {
    font-size: 0.8rem;
    margin-bottom: 5px;
}

/* ============================================
   Message Input Area
============================================ */
.message-form {
    padding: 1rem;
    background-color: #ffffff;
    border-top: 1px solid #dee2e6;
}

.message-form .input-group {
    display: flex;
    flex-wrap: wrap !important;
    align-items: stretch !important;
}

/* Upload label button */
#lbl-file-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    cursor: pointer;
}

#file-upload {
    display: none;
}

/* ============================================
   Quill Editor
============================================ */
#rich-editor {
    flex: 1 1 100% !important;
    width: 100% !important;
    display: block !important;
    min-height: 140px !important;
    height: auto !important;
    margin: 0.5rem 0 !important;
}

#rich-editor .ql-container {
    flex: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
}

#rich-editor .ql-editor {
    width: 100% !important;
    min-height: 140px !important;
    padding-bottom: 10px;
    box-sizing: border-box;
}

/* Placeholder text */
#rich-editor .ql-editor.ql-blank::before {
    white-space: normal !important;
    line-height: 1.4;
    opacity: 0.6;
}

@media (max-width: 768px) {
    #rich-editor,
    #rich-editor .ql-container,
    #rich-editor .ql-editor {
        min-height: 160px !important;
    }
}

/* ============================================
   Send Button (full-width row)
============================================ */
.message-form .btn-send {
    border-radius: 8px !important;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Utility & Link Styles
============================================ */
a { color: blue; text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: blue; }

#logout,
#logout:visited {
    color: yellow;
}

.red-text { color: red; font-weight: bold; }
.green-text { color: green; font-weight: bold; }
.hidden { display: none; }

/* ============================================
   Typing Indicator
============================================ */
.typing-indicator .message-content {
    display: flex;
    align-items: center;
    padding: 5px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #6c757d;
    border-radius: 50%;
    opacity: 0.4;
    animation: typing-pulse 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-pulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}
