/* Solo2 Component: Message Bubbles (Premium Geometry) */

.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 2px;
    animation: messageFadeIn 0.2s ease-out forwards;
}

.message-row.sent { justify-content: flex-end; }
.message-row.received { justify-content: flex-start; }

/* Espaciado contextual */
.message-row.different-sender { margin-top: 12px; }
.message-row.same-sender { margin-top: 4px; }

.message-bubble {
    max-width: 75%;
    padding: 8px 14px;
    position: relative;
    box-shadow: var(--shadow-sm);
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Burbuja Enviada */
.message-bubble.sent {
    background-color: var(--color-primary);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

/* Burbuja Recibida */
.message-bubble.received {
    background-color: var(--color-surface);
    color: var(--color-text);
    border-radius: 18px 18px 18px 4px;
}

/* Rabitos (Tails) */
.message-row.different-sender.sent .message-bubble::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 12px;
    height: 18px;
    background: var(--color-primary);
    clip-path: polygon(0 0, 0% 100%, 100% 100%);
}

.message-row.different-sender.received .message-bubble::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 12px;
    height: 18px;
    background: var(--color-surface);
    clip-path: polygon(100% 0, 0% 100%, 100% 100%);
}

/* Metadatos */
.msg-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 4px;
}

.msg-time { font-family: monospace; }

/* Viñeta: Umbral del Túnel */
#chat-area {
    position: relative;
}

#chat-area::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 60px 10px rgba(0,0,0,0.15);
    z-index: 5;
}

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

/* ========================================================================
   FILE BUBBLES
   ======================================================================== */

.file-bubble {
    padding: 8px;
    max-width: 280px;
}

/* File preview for images */
.file-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 6px;
}

.file-thumbnail {
    display: block;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

.file-thumbnail.clickable {
    cursor: pointer;
    transition: transform 0.15s ease;
}

.file-thumbnail.clickable:hover {
    transform: scale(1.02);
}

/* Progress overlay for images */
.file-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Progress ring (for images) */
.file-progress-ring {
    width: 60px;
    height: 60px;
    position: relative;
}

.file-progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.file-progress-ring .ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 3;
}

.file-progress-ring .ring-fill {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.2s ease;
}

.file-progress-ring .progress-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
}

/* File info */
.file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-size: 0.8rem;
    font-weight: 500;
    word-break: break-word;
    opacity: 0.9;
}

.file-size {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* Non-image file content */
.file-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px;
}

.file-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.file-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Progress bar (for non-images) */
.file-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.file-progress-bar .progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 0.2s ease;
}

/* Download button */
.file-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    text-decoration: none;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.file-download-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Error state */
.file-bubble.file-error {
    opacity: 0.7;
}

.file-error-icon {
    font-size: 1.5rem;
}

/* ========================================================================
   IMAGE VIEWER (fullscreen)
   ======================================================================== */

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-viewer-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.image-viewer-content img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.image-viewer-actions {
    display: flex;
    gap: 12px;
}

.image-viewer-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.15s ease;
}

.image-viewer-actions .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========================================================================
   DROP ZONE OVERLAY
   ======================================================================== */

#drop-zone-overlay {
    backdrop-filter: blur(4px);
    animation: dropZoneFadeIn 0.15s ease;
}

@keyframes dropZoneFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#drop-zone-overlay > div {
    animation: dropZoneScale 0.2s ease;
}

@keyframes dropZoneScale {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}