/* ========================================
   MODAL DE VISUALIZACIÓN DE FOTOS ESTILO INSTAGRAM
   ======================================== */

.photo-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    max-width: 1200px;
    max-height: 90vh;
    width: 100%;
    display: flex;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    font-size: 14px;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.modal-body {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Contenedor de imagen */
.modal-image-container {
    position: relative;
    flex: 1;
    height: 100%;
    min-height: 500px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f5f5f5;
    border-radius: 4px;
    display: block;
}

.modal-image-container img:not([src]) {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image-container img:not([src])::before {
    content: "📷";
    font-size: 48px;
    color: #ccc;
}

/* Indicador de carga para imágenes */
.modal-image-container img[src=""] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Botones de navegación */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
    z-index: 5;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.nav-prev {
    left: 15px;
}

.nav-next {
    right: 15px;
}

/* Panel de comentarios */
.modal-comments-panel {
    width: 400px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    border-left: 1px solid #dbdbdb;
    overflow: hidden;
}

/* Header del post */
.post-header {
    padding: 16px;
    border-bottom: 1px solid #dbdbdb;
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 600;
    font-size: 14px;
    color: #262626;
}

.post-location {
    font-size: 12px;
    color: #8e8e8e;
}

/* Sección de comentarios */
.comments-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
    min-height: 0; /* Permite que el flex funcione correctamente */
}

.comments-list {
    padding: 16px 0;
}

.comment-item {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    padding: 8px 12px;
    border-radius: 12px;
    transition: background-color 0.2s;
}

.comment-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid transparent;
    position: relative;
}

/* Iconos circulares para visitantes */
.comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, var(--trans-blue), var(--trans-pink));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
}

.comment-avatar.visitor-avatar::before {
    content: attr(data-initial);
}

/* Colores de la paleta para cada comentario */
.comment-item:nth-child(1) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
}

.comment-item:nth-child(2) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #4ecdc4, #6dd5ed);
}

.comment-item:nth-child(3) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #45b7d1, #96c7ed);
}

.comment-item:nth-child(4) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #f9ca24, #f0932b);
}

.comment-item:nth-child(5) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #6c5ce7, #a29bfe);
}

.comment-item:nth-child(6) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #fd79a8, #fdcb6e);
}

.comment-item:nth-child(7) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #00b894, #00cec9);
}

.comment-item:nth-child(8) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #e17055, #fdcb6e);
}

/* Colores alternativos para más comentarios */
.comment-item:nth-child(9) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #74b9ff, #0984e3);
}

.comment-item:nth-child(10) .comment-avatar.visitor-avatar {
    background: linear-gradient(45deg, #a29bfe, #6c5ce7);
}

.comment-content {
    flex: 1;
}

.comment-text {
    font-size: 14px;
    line-height: 1.4;
    color: #262626;
    margin-bottom: 4px;
}

.comment-username {
    font-weight: 600;
    margin-right: 8px;
}

.comment-actions {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #8e8e8e;
}

.comment-time {
    cursor: pointer;
}

.comment-reply {
    cursor: pointer;
    font-weight: 600;
}

/* Acciones del post */
.post-actions {
    padding: 8px 16px;
    display: flex;
    gap: 16px;
    border-bottom: 1px solid #dbdbdb;
}

.action-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #262626;
    transition: color 0.2s;
}

.action-btn:hover {
    color: #8e8e8e;
}

.action-btn.liked {
    color: #ed4956;
}

/* Contador de likes */
.likes-count {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #262626;
}

/* Fecha del post */
.post-date {
    padding: 0 16px 8px;
    font-size: 10px;
    color: #8e8e8e;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

/* Formulario de comentario */
.comment-form {
    padding: 16px;
    border-top: 1px solid #dbdbdb;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0; /* Evita que se reduzca */
    background: white;
}

#comment-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    color: #262626;
    background: transparent;
}

#comment-input::placeholder {
    color: #8e8e8e;
}

#comment-submit {
    background: none;
    border: none;
    color: #0095f6;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
    padding: 8px 12px;
    white-space: nowrap;
    min-width: 60px;
}

#comment-submit:not(:disabled) {
    opacity: 1;
}

#comment-submit:not(:disabled):hover {
    color: #00376b;
}

/* Asegurar que el botón siempre sea visible */
#comment-submit {
    position: relative;
    z-index: 5;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .modal-body {
        flex-direction: column;
    }
    
    .modal-image-container {
        width: 100%;
        max-height: 50vh;
    }
    
    .modal-comments-panel {
        width: 100%;
        max-height: 50vh;
    }
    
    .nav-btn {
        display: none;
    }
    
    /* Asegurar que el formulario de comentarios sea visible en móvil */
    .comment-form {
        position: sticky;
        bottom: 0;
        z-index: 10;
    }
    
    #comment-submit {
        min-width: 70px;
        padding: 10px 14px;
    }
}

/* Animaciones */
.photo-modal {
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    animation: slideIn 0.3s ease-out;
}

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

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

/* Estados de carga */
.loading-comments {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #8e8e8e;
    font-size: 14px;
}

.loading-comments i {
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
