/**
 * PHOTO COMMENTS - Estilos para sistema de comentarios
 */

.photo-comments-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10006;
    display: none;
    pointer-events: none;
}

.photo-comments-modal.active {
    display: block;
    pointer-events: all;
}

.photo-comments-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.photo-comments-modal.active .photo-comments-overlay {
    opacity: 1;
}

/* Panel de comentarios */
.photo-comments-panel {
    position: absolute;
    background: white;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.photo-comments-modal.active .photo-comments-panel {
    transform: translateY(0);
}

/* Desktop: Modal centrado */
@media (min-width: 769px) {
    .photo-comments-panel {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        width: 500px;
        max-height: 600px;
        border-radius: 16px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
    
    .photo-comments-modal.active .photo-comments-panel {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Mobile: Panel desde abajo */
@media (max-width: 768px) {
    .photo-comments-panel {
        bottom: 0;
        left: 0;
        right: 0;
        height: 65vh;
        max-height: 65vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    }
    
    /* Ajuste cuando el teclado está abierto */
    .photo-comments-modal.active .photo-comments-panel {
        /* Usar dvh (dynamic viewport height) si está disponible para adaptarse al teclado */
        height: 65dvh;
        max-height: 65dvh;
    }
    
    /* Asegurar que el input sea visible */
    .photo-comments-input-wrapper {
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 10;
    }
}

/* Header */
.photo-comments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.photo-comments-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.photo-comments-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.photo-comments-close:hover {
    background: #e5e7eb;
    color: #111827;
}

.photo-comments-close i {
    font-size: 20px;
}

/* Lista de comentarios */
.photo-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar personalizado */
.photo-comments-list::-webkit-scrollbar {
    width: 6px;
}

.photo-comments-list::-webkit-scrollbar-track {
    background: transparent;
}

.photo-comments-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.photo-comments-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Estados vacíos y de carga */
.photo-comments-empty,
.photo-comments-loader,
.photo-comments-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
}

.photo-comments-empty i,
.photo-comments-loader i,
.photo-comments-error i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.photo-comments-loader i {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.photo-comments-empty p,
.photo-comments-error p {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 4px 0;
    color: #374151;
}

.photo-comments-empty span,
.photo-comments-loader span {
    font-size: 14px;
    color: #9ca3af;
}

.photo-comments-error .btn-retry {
    margin-top: 12px;
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.photo-comments-error .btn-retry:hover {
    background: #2563eb;
}

/* Item de comentario */
.photo-comment-item {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.photo-comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.photo-comment-avatar.clickable {
    cursor: pointer;
}

.photo-comment-avatar.clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.photo-comment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-comment-avatar i {
    font-size: 20px;
    color: white;
}

.photo-comment-content {
    flex: 1;
    min-width: 0;
}

.photo-comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    position: relative;
}

.photo-comment-author {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    transition: color 0.2s ease;
}

.photo-comment-author.clickable {
    cursor: pointer;
}

.photo-comment-author.clickable:hover {
    color: #3b82f6;
    text-decoration: underline;
}

/* Asegurar que los links funcionen */
a.photo-comment-author {
    cursor: pointer;
}

a.photo-comment-author:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.photo-comment-date {
    font-size: 12px;
    color: #9ca3af;
    flex: 1;
}

.photo-comment-text {
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
    margin: 0;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.photo-comment-delete {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.photo-comment-delete:hover {
    background: #fee2e2;
    color: #ef4444;
}

.photo-comment-delete i {
    font-size: 16px;
}

/* Input de comentarios */
.photo-comments-input-wrapper {
    border-top: 1px solid #e5e7eb;
    padding: 16px 20px;
    flex-shrink: 0;
    background: white;
}

.photo-comments-login-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.photo-comments-login-prompt p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

.btn-login-comment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-login-comment:hover {
    background: #2563eb;
}

.btn-login-comment i {
    font-size: 16px;
}

.photo-comments-input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.photo-comments-textarea {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #111827;
    resize: none;
    transition: border-color 0.2s ease;
}

.photo-comments-textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.photo-comments-textarea:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.photo-comments-textarea::placeholder {
    color: #9ca3af;
}

.photo-comments-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.photo-comments-send:hover:not(:disabled) {
    background: #2563eb;
    transform: scale(1.05);
}

.photo-comments-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    opacity: 0.5;
}

.photo-comments-send i {
    font-size: 18px;
}

/* Animaciones */
.rotating {
    animation: rotate 1s linear infinite;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .photo-comments-header {
        padding: 16px;
    }
    
    .photo-comments-list {
        padding: 12px 16px;
    }
    
    .photo-comments-input-wrapper {
        padding: 12px 16px;
    }
}

/* Modal de confirmación de eliminación */
.delete-comment-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100003;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.delete-comment-modal.active {
    opacity: 1;
    pointer-events: all;
}

.delete-comment-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.delete-comment-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 32px 24px 24px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

.delete-comment-modal.active .delete-comment-content {
    transform: scale(1);
}

.delete-comment-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-comment-icon i {
    font-size: 28px;
    color: #ef4444;
}

.delete-comment-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px 0;
}

.delete-comment-content p {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 24px 0;
}

.delete-comment-actions {
    display: flex;
    gap: 12px;
}

.btn-delete-cancel,
.btn-delete-confirm {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete-cancel {
    background: #f3f4f6;
    color: #374151;
}

.btn-delete-cancel:hover {
    background: #e5e7eb;
}

.btn-delete-confirm {
    background: #ef4444;
    color: white;
}

.btn-delete-confirm:hover {
    background: #dc2626;
}


/* ========================================
   GRABADOR DE AUDIO - Comentarios de voz
   ======================================== */

/* Botón de micrófono */
.photo-comments-audio-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.photo-comments-audio-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.photo-comments-audio-btn.recording {
    background: #ef4444;
    color: white;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.photo-comments-audio-btn i {
    font-size: 18px;
}

/* Grabador de audio activo */
.photo-comments-audio-recorder {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 12px;
    margin-top: 12px;
}

/* Ondas de audio animadas */
.audio-recorder-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.audio-wave-bar {
    width: 3px;
    height: 8px;
    background: #f59e0b;
    border-radius: 2px;
    animation: wave-animation 0.8s ease-in-out infinite;
}

.audio-wave-bar:nth-child(1) { animation-delay: 0s; }
.audio-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.audio-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.audio-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.audio-wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave-animation {
    0%, 100% { height: 8px; }
    50% { height: 20px; }
}

.audio-recorder-time {
    font-size: 16px;
    font-weight: 600;
    color: #92400e;
    font-variant-numeric: tabular-nums;
    min-width: 32px;
}

.audio-recorder-limit {
    font-size: 12px;
    color: #b45309;
}

.audio-recorder-cancel,
.audio-recorder-stop {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-recorder-cancel {
    background: rgba(255, 255, 255, 0.8);
    color: #6b7280;
    margin-left: auto;
}

.audio-recorder-cancel:hover {
    background: white;
    color: #ef4444;
}

.audio-recorder-stop {
    background: #ef4444;
    color: white;
}

.audio-recorder-stop:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.audio-recorder-cancel i,
.audio-recorder-stop i {
    font-size: 18px;
}

/* Preview de audio grabado */
.photo-comments-audio-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    margin-top: 12px;
}

.audio-preview-play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #22c55e;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.audio-preview-play:hover {
    background: #16a34a;
    transform: scale(1.05);
}

.audio-preview-play i {
    font-size: 16px;
    margin-left: 2px;
}

.audio-preview-play.playing i::before {
    content: "\eb7e"; /* ri-pause-fill */
}

.audio-preview-waveform {
    flex: 1;
    height: 32px;
    background: #dcfce7;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.audio-preview-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
    border-radius: 4px;
    transition: width 0.1s linear;
}

/* Barras de waveform estáticas */
.audio-preview-waveform::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 8px;
    right: 8px;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        #86efac 0px,
        #86efac 2px,
        transparent 2px,
        transparent 6px
    );
    transform: translateY(-50%);
}

.audio-preview-time {
    font-size: 13px;
    font-weight: 500;
    color: #166534;
    font-variant-numeric: tabular-nums;
    min-width: 36px;
}

.audio-preview-delete,
.audio-preview-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-preview-delete {
    background: #fee2e2;
    color: #ef4444;
}

.audio-preview-delete:hover {
    background: #fecaca;
    transform: scale(1.05);
}

.audio-preview-send {
    background: #3b82f6;
    color: white;
}

.audio-preview-send:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.audio-preview-delete i,
.audio-preview-send i {
    font-size: 16px;
}

/* Comentario de audio en la lista */
.photo-comment-audio {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 20px;
    margin-top: 6px;
}

.comment-audio-play {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.comment-audio-play:hover {
    background: #2563eb;
}

.comment-audio-play i {
    font-size: 14px;
    margin-left: 2px;
}

.comment-audio-play.playing i::before {
    content: "\eb7e"; /* ri-pause-fill */
}

.comment-audio-play.loading {
    pointer-events: none;
    opacity: 0.7;
}

.comment-audio-play.loading i::before {
    content: "\f1ed"; /* ri-loader-4-line */
    animation: rotate 1s linear infinite;
    display: inline-block;
}

.comment-audio-waveform {
    flex: 1;
    height: 28px;
    background: #e5e7eb;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}

.comment-audio-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(59, 130, 246, 0.35);
    border-radius: 16px;
    z-index: 1;
}

/* Barras de waveform visuales */
.comment-audio-waveform .wave-bars {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    width: 100%;
    padding: 0 10px;
    z-index: 2;
    position: absolute;
    top: 0;
    left: 0;
}

.comment-audio-waveform .wave-bar {
    width: 3px;
    background: #9ca3af;
    border-radius: 2px;
    transition: background 0.15s ease;
}

/* Barras activas (reproducidas) */
.comment-audio-waveform .wave-bar.active {
    background: #3b82f6;
}

.comment-audio-time {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    min-width: 32px;
}

/* Indicador de carga de audio */
.audio-uploading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #eff6ff;
    border-radius: 12px;
    margin-top: 12px;
}

.audio-uploading i {
    font-size: 20px;
    color: #3b82f6;
    animation: rotate 1s linear infinite;
}

.audio-uploading span {
    font-size: 14px;
    color: #1d4ed8;
}

/* Mobile adjustments para audio */
@media (max-width: 768px) {
    .photo-comments-audio-recorder,
    .photo-comments-audio-preview {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .audio-recorder-cancel,
    .audio-recorder-stop,
    .audio-preview-play,
    .audio-preview-delete,
    .audio-preview-send {
        width: 32px;
        height: 32px;
    }
    
    .audio-recorder-cancel i,
    .audio-recorder-stop i,
    .audio-preview-play i,
    .audio-preview-delete i,
    .audio-preview-send i {
        font-size: 16px;
    }
}
