/* =============================================================================
   RutaTurismo360 - Global Chat Template Styles
   =============================================================================

   Estilos del chat interno (/chat) con prefijo rt360-chat-*.

   Prefijo: rt360-chat-*
   Última actualización: Octubre 2026
   Versión: 1.0.0

   ÍNDICE:
   -------
   1. Layout (bandeja + conversación)
   2. Bandeja de conversaciones
   3. Conversación y burbujas de mensaje
   4. Caja de escritura
   5. Diálogos (lista de contactos)
   5b. Editar y eliminar mensajes propios
   6. Responsive
   7. Dark Mode
   ============================================================================= */


/* =============================================================================
   1. LAYOUT
   ============================================================================= */

.rt360-chat-wrapper {
    display: flex;
    gap: 1rem;
    height: calc(100vh - 260px);
    min-height: 480px;
}

.rt360-chat-sidebar,
.rt360-chat-main {
    background: var(--rz-base-background-color, #fff);
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.rt360-chat-sidebar {
    width: 320px;
    flex-shrink: 0;
}

.rt360-chat-main {
    flex: 1;
    min-width: 0;
}


/* =============================================================================
   2. BANDEJA
   ============================================================================= */

.rt360-chat-list {
    flex: 1;
    overflow-y: auto;
}

.rt360-chat-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-bottom: 1px solid var(--rz-border-color, #eee);
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.rt360-chat-list-item:hover {
    background: var(--rz-base-100, #f5f5f5);
}

.rt360-chat-list-item--active {
    background: var(--rz-primary-lighter, #ede7f6);
}

.rt360-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--rz-primary-lighter, #ede7f6);
    color: var(--rz-primary, #6a1b9a);
    font-weight: 600;
}

.rt360-chat-list-body {
    flex: 1;
    min-width: 0;
}

.rt360-chat-list-title {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt360-chat-list-preview {
    display: block;
    font-size: 0.8rem;
    color: var(--rz-text-secondary-color, #757575);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt360-chat-list-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: var(--rz-text-secondary-color, #757575);
}

.rt360-chat-unread {
    background: var(--rz-danger, #e53935);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    text-align: center;
}

.rt360-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    text-align: center;
    color: var(--rz-text-secondary-color, #757575);
}


/* =============================================================================
   3. CONVERSACIÓN
   ============================================================================= */

.rt360-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--rz-border-color, #eee);
}

.rt360-chat-header-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt360-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--rz-base-50, #fafafa);
}

.rt360-chat-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 75%;
}

.rt360-chat-message--mine {
    align-self: flex-end;
    align-items: flex-end;
}

.rt360-chat-sender {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--rz-primary, #6a1b9a);
    margin-bottom: 0.15rem;
}

.rt360-chat-bubble {
    padding: 0.5rem 0.75rem;
    border-radius: 12px 12px 12px 4px;
    background: var(--rz-base-background-color, #fff);
    border: 1px solid var(--rz-border-color, #e0e0e0);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
}

.rt360-chat-message--mine .rt360-chat-bubble {
    border-radius: 12px 12px 4px 12px;
    background: var(--rz-primary, #6a1b9a);
    border-color: var(--rz-primary, #6a1b9a);
    color: #fff;
}

.rt360-chat-time {
    font-size: 0.68rem;
    color: var(--rz-text-secondary-color, #9e9e9e);
    margin-top: 0.15rem;
}


/* =============================================================================
   4. CAJA DE ESCRITURA
   ============================================================================= */

.rt360-chat-composer {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--rz-border-color, #eee);
}

.rt360-chat-input {
    flex: 1;
    min-width: 0;
}


/* Adjuntar: el <InputFile> queda invisible dentro de un label con forma de botón */
.rt360-chat-attach-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--rz-text-secondary-color, #757575);
    flex-shrink: 0;
}

.rt360-chat-attach-button:hover {
    background: var(--rz-base-100, #f5f5f5);
    color: var(--rz-primary, #6a1b9a);
}

.rt360-chat-attach-button--disabled {
    pointer-events: none;
    opacity: 0.5;
}

.rt360-chat-file-input {
    display: none;
}

/* Archivo elegido y todavía no enviado */
.rt360-chat-pending-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem;
    padding: 0.4rem 0.75rem;
    border: 1px dashed var(--rz-border-color, #ccc);
    border-radius: 8px;
    font-size: 0.85rem;
}

/* Adjunto dentro de una burbuja */
.rt360-chat-attachment {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: inherit;
    text-decoration: none;
}

.rt360-chat-attachment:hover {
    text-decoration: underline;
}

.rt360-chat-message--mine .rt360-chat-attachment {
    background: rgba(255, 255, 255, 0.18);
}

.rt360-chat-attachment-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt360-chat-attachment-size {
    font-size: 0.72rem;
    opacity: 0.75;
    white-space: nowrap;
}

.rt360-chat-attachment-image {
    display: block;
    max-width: 240px;
    max-height: 240px;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    object-fit: cover;
}


/* Menciones con @ dentro de la burbuja */
.rt360-chat-mention {
    font-weight: 600;
    color: var(--rz-primary, #6a1b9a);
}

.rt360-chat-mention--me {
    padding: 0 3px;
    border-radius: 4px;
    background: rgba(255, 193, 7, 0.35);
    color: inherit;
}

.rt360-chat-message--mine .rt360-chat-mention {
    color: #fff;
    text-decoration: underline;
}

/* Selector que aparece al escribir @ */
.rt360-chat-mention-picker {
    display: flex;
    flex-direction: column;
    margin: 0 1rem;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--rz-border-color, #e0e0e0);
    border-radius: 8px;
    background: var(--rz-base-background-color, #fff);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.rt360-chat-mention-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
}

.rt360-chat-mention-option:hover,
.rt360-chat-mention-option:first-child {
    background: var(--rz-base-100, #f5f5f5);
}

.rt360-chat-mention-option .rt360-chat-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}


/* =============================================================================
   5. DIÁLOGOS
   ============================================================================= */

.rt360-chat-contact-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--rz-border-color, #eee);
    border-radius: 8px;
}


/* =============================================================================
   5b. EDITAR Y ELIMINAR MENSAJES PROPIOS
   ============================================================================= */

/* Burbuja con sus acciones al lado (solo en mensajes propios) */
.rt360-chat-bubble-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
}

/* Las acciones aparecen al pasar el mouse; en pantallas táctiles quedan siempre visibles */
.rt360-chat-message-actions {
    display: flex;
    gap: 0.1rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.rt360-chat-message:hover .rt360-chat-message-actions,
.rt360-chat-message-actions:focus-within {
    opacity: 1;
}

@media (hover: none) {
    .rt360-chat-message-actions {
        opacity: 1;
    }
}

/* Mensaje eliminado: ocupa su lugar sin mostrar contenido */
.rt360-chat-bubble.rt360-chat-deleted,
.rt360-chat-message--mine .rt360-chat-bubble.rt360-chat-deleted {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-style: italic;
    background: transparent;
    border: 1px dashed var(--rz-border-color, #e0e0e0);
    color: var(--rz-text-secondary-color, #757575);
}

.rt360-chat-deleted .rzi {
    font-size: 1rem;
}

/* Marca "editado" junto a la hora */
.rt360-chat-edited {
    font-style: italic;
}

/* Edición en línea */
.rt360-chat-edit {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: min(320px, 70vw);
}

.rt360-chat-edit-input {
    width: 100%;
}

.rt360-chat-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
}


/* =============================================================================
   6. RESPONSIVE: en móvil se ve la bandeja o la conversación, nunca ambas
   ============================================================================= */

@media (max-width: 768px) {
    .rt360-chat-wrapper {
        height: calc(100vh - 200px);
    }

    .rt360-chat-sidebar {
        width: 100%;
    }

    .rt360-chat-wrapper .rt360-chat-main {
        display: none;
    }

    .rt360-chat-wrapper--open .rt360-chat-sidebar {
        display: none;
    }

    .rt360-chat-wrapper--open .rt360-chat-main {
        display: flex;
    }

    .rt360-chat-message {
        max-width: 90%;
    }
}

/* El botón "volver" solo tiene sentido en móvil */
.rt360-chat-back {
    display: none;
}

@media (max-width: 768px) {
    .rt360-chat-back {
        display: inline-flex;
    }
}


/* =============================================================================
   7. DARK MODE
   ============================================================================= */

html[data-theme="dark"] .rt360-chat-sidebar,
html[data-theme="dark"] .rt360-chat-main {
    background: var(--rz-base-background-color, #1e1e2e);
    border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .rt360-chat-list-item,
html[data-theme="dark"] .rt360-chat-header,
html[data-theme="dark"] .rt360-chat-composer,
html[data-theme="dark"] .rt360-chat-contact-list {
    border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .rt360-chat-list-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .rt360-chat-list-item--active {
    background: rgba(149, 117, 205, 0.18);
}

html[data-theme="dark"] .rt360-chat-avatar {
    background: rgba(149, 117, 205, 0.2);
    color: #b39ddb;
}

html[data-theme="dark"] .rt360-chat-list-preview,
html[data-theme="dark"] .rt360-chat-list-meta,
html[data-theme="dark"] .rt360-chat-time,
html[data-theme="dark"] .rt360-chat-empty {
    color: rgba(255, 255, 255, 0.55);
}

html[data-theme="dark"] .rt360-chat-messages {
    background: rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] .rt360-chat-bubble {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

html[data-theme="dark"] .rt360-chat-attach-button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #b39ddb;
}

html[data-theme="dark"] .rt360-chat-pending-file {
    border-color: rgba(255, 255, 255, 0.2);
}

html[data-theme="dark"] .rt360-chat-attachment {
    background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .rt360-chat-sender {
    color: #b39ddb;
}

html[data-theme="dark"] .rt360-chat-mention {
    color: #b39ddb;
}

html[data-theme="dark"] .rt360-chat-mention--me {
    background: rgba(255, 193, 7, 0.25);
    color: inherit;
}

html[data-theme="dark"] .rt360-chat-mention-picker {
    background: var(--rz-base-background-color, #1e1e2e);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
}

html[data-theme="dark"] .rt360-chat-mention-option:hover,
html[data-theme="dark"] .rt360-chat-mention-option:first-child {
    background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .rt360-chat-bubble.rt360-chat-deleted,
html[data-theme="dark"] .rt360-chat-message--mine .rt360-chat-bubble.rt360-chat-deleted {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
}
