/**
 * MOJO Chat Component Styles
 * Supports two themes: 'compact' (default) and 'bubbles'
 */

/* ========================================
   Base Chat Container
   ======================================== */
.chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #fff;
}

.chat-input-wrapper {
    flex-shrink: 0;
}

/* ========================================
   Compact Theme (Option 4 - Default)
   Admin/Activity Feed Style
   ======================================== */
.chat-theme-compact .message-item {
    display: flex;
    padding: 12px;
    border-bottom: 1px solid #f1f3f5;
    transition: background-color 0.15s ease;
}

.chat-theme-compact .message-item:hover {
    background: #f8f9fa;
}

.chat-theme-compact .message-item:last-child {
    border-bottom: none;
}

.chat-theme-compact .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #6c757d;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-theme-compact .message-avatar .mojo-avatar-icon {
    width: 22px;
    height: 22px;
}

.chat-theme-compact .message-content {
    flex: 1;
    min-width: 0;
}

.chat-theme-compact .message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    gap: 8px;
}

.chat-theme-compact .message-author {
    font-weight: 600;
    font-size: 0.9rem;
    color: #212529;
}

.chat-theme-compact .message-time {
    font-size: 0.75rem;
    color: #6c757d;
    white-space: nowrap;
}

.chat-theme-compact .message-text {
    font-size: 0.9rem;
    color: #212529;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* System messages in compact theme */
.chat-theme-compact .chat-message-system {
    background: #f8f9fa;
    border-left: 3px solid #0d6efd;
    margin: 8px 0;
    padding: 8px 12px;
}

/* ========================================
   Bubbles Theme (Option 1)
   Modern Chat Bubbles Style
   ======================================== */
.chat-theme-bubbles .chat-message {
    margin-bottom: 12px;
}

.chat-theme-bubbles .message-bubble-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.chat-theme-bubbles .message-left .message-bubble-wrapper {
    align-items: flex-start;
}

.chat-theme-bubbles .message-right .message-bubble-wrapper {
    align-items: flex-end;
    margin-left: auto;
}

.chat-theme-bubbles .message-meta {
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 4px;
    padding: 0 4px;
}

.chat-theme-bubbles .message-right .message-meta {
    text-align: right;
}

.chat-theme-bubbles .message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    max-width: 100%;
}

.chat-theme-bubbles .message-left .message-bubble {
    background: #e9ecef;
    color: #212529;
}

.chat-theme-bubbles .message-right .message-bubble {
    background: #0d6efd;
    color: white;
}

.chat-theme-bubbles .message-text {
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* System messages in bubbles theme */
.chat-theme-bubbles .chat-message-system {
    max-width: 100%;
    margin: 16px auto;
}

/* ========================================
   Chat Input Area (Both Themes)
   ======================================== */
.chat-input-view {
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    width: 100%;
}

.chat-input-container {
    padding: 15px;
    position: relative;
    width: 100%;
}

.chat-input-container.drag-over {
    background: #e7f3ff;
    border-color: #0d6efd;
}

.chat-input-container.drag-active::before {
    content: "Drop files here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: #0d6efd;
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
}

.chat-input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input {
    flex: 1;
    resize: none;
    max-height: 150px;
    font-size: 0.9rem;
}

.chat-send-btn {
    flex-shrink: 0;
    min-width: 80px;
}

.chat-send-btn i,
.chat-send-btn .spinner-border {
    font-size: 1rem;
}

.chat-input-footer {
    margin-top: 8px;
    font-size: 0.85rem;
}

/* ========================================
   File Attachments
   ======================================== */
.chat-input-attachments {
    margin-bottom: 10px;
}

.attachment-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 8px;
    margin-right: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.attachment-preview.upload-complete {
    background: #d1e7dd;
}

.attachment-preview.upload-error {
    background: #f8d7da;
}

.attachment-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.attachment-name {
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-size {
    color: #6c757d;
    font-size: 0.75rem;
}

.attachment-progress {
    min-width: 100px;
}

.attachment-remove {
    padding: 0;
    margin: 0;
    line-height: 1;
}

/* File attachments in messages */
.message-text .file-attachment,
[data-container="attachments"] .file-attachment {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    transition: background-color 0.15s ease;
}

.message-text .file-attachment:hover,
[data-container="attachments"] .file-attachment:hover {
    background: rgba(0, 0, 0, 0.1);
}

.message-text .file-attachment i,
[data-container="attachments"] .file-attachment i {
    margin-right: 6px;
}

/* For bubbles theme, adjust file attachment styling */
.chat-theme-bubbles .message-right .file-attachment {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

/* ========================================
   System Messages
   ======================================== */
.chat-message-system {
    text-align: center;
    padding: 8px 12px;
    margin: 12px 0;
}

/* ========================================
   Scrollbar Styling
   ======================================== */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (max-width: 768px) {
    .chat-theme-bubbles .message-bubble-wrapper {
        max-width: 85%;
    }

    .chat-theme-compact .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

    .attachment-name {
        max-width: 150px;
    }
}

/* ========================================
   Utility Classes
   ======================================== */
.badge-sm {
    font-size: 0.7rem;
    padding: 2px 6px;
}

/* ========================================
   Dark theme overrides

   The base chat styles use hardcoded light-mode hex values (#fff, #f8f9fa,
   #6c757d, …). When data-bs-theme="dark" is active we re-skin the same
   surfaces using Bootstrap dark-mode tokens so the chat blends with the
   rest of the page.
   ======================================== */
[data-bs-theme="dark"] .chat-container {
    background: var(--bs-body-bg);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .chat-messages {
    background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .chat-theme-compact .message-item {
    border-bottom-color: var(--bs-border-color-translucent);
}

[data-bs-theme="dark"] .chat-theme-compact .message-item:hover {
    background: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .chat-theme-compact .message-author,
[data-bs-theme="dark"] .chat-theme-compact .message-text {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .chat-theme-compact .message-time,
[data-bs-theme="dark"] .chat-theme-bubbles .message-meta {
    color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .chat-theme-compact .chat-message-system {
    background: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .chat-theme-bubbles .message-left .message-bubble {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

/* `message-right` keeps `--bs-primary` from the base rule — looks correct
   in both themes since Bootstrap's primary is theme-aware. */

[data-bs-theme="dark"] .chat-input-view {
    background: var(--bs-tertiary-bg);
    border-top-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .chat-input-container.drag-over {
    background: rgba(13, 110, 253, 0.12);
}

[data-bs-theme="dark"] .attachment-preview {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .attachment-preview.upload-complete {
    background: var(--bs-success-bg-subtle);
}

[data-bs-theme="dark"] .attachment-preview.upload-error {
    background: var(--bs-danger-bg-subtle);
}

[data-bs-theme="dark"] .attachment-size {
    color: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .message-text .file-attachment,
[data-bs-theme="dark"] [data-container="attachments"] .file-attachment {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .message-text .file-attachment:hover,
[data-bs-theme="dark"] [data-container="attachments"] .file-attachment:hover {
    background: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .chat-messages::-webkit-scrollbar-track {
    background: var(--bs-tertiary-bg);
}

[data-bs-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
    background: var(--bs-secondary-color);
}

[data-bs-theme="dark"] .chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--bs-emphasis-color);
}
