/* ============================================
   COMMENTS SYSTEM - REDESIGN v2.0
   Solid, Professional Design for RewindMTV
   ============================================ */

/* === Variables Locales === */
:root {
    --comments-bg: #111827;
    --comments-bg-secondary: #0d1117;
    --comments-border: #1e293b;
    --comments-border-light: #2d3748;
    --comments-text: rgba(255, 255, 255, 0.9);
    --comments-text-muted: rgba(255, 255, 255, 0.5);
    --comments-accent: #fbbf24;
    --comments-accent-hover: #f59e0b;
    --comments-gradient: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
    --comments-like-color: #ef4444;
    --comments-reply-indent: 48px;
}

/* === Contenedor Principal === */
.comments-section {
    width: 100%;
    max-width: 800px;
    margin: 2rem auto 5rem auto;
    border-radius: 16px;
    background: var(--comments-bg);
    border: 1px solid var(--comments-border);
    padding: 0;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 10px 20px -5px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    overflow: visible !important;
    min-height: min-content !important;
    flex-shrink: 0 !important;
}

/* === Header de Comentarios === */
.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--comments-border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
}

.comments-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.title-main {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.title-main i {
    color: var(--comments-accent);
    font-size: 1rem;
}

.comments-count {
    font-size: 0.85rem;
    color: var(--comments-text-muted);
    font-weight: 400;
}

.comments-channel-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--comments-accent);
    background: rgba(251, 191, 36, 0.08);
    padding: 3px 12px;
    border-radius: 8px;
    border: 1px solid rgba(251, 191, 36, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: 'Space Grotesk', 'Outfit', sans-serif;
}

/* === Controles de Ordenamiento === */
.comments-sort-controls {
    display: flex;
    gap: 0.5rem;
}

.sort-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    color: var(--comments-text-muted);
    padding: 8px 16px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: none;
    letter-spacing: normal;
}

.sort-btn:hover {
    border-color: var(--comments-border-light);
    color: var(--comments-text);
    background: rgba(255, 255, 255, 0.08);
}

.sort-btn.active {
    border-color: var(--comments-accent);
    color: var(--comments-accent);
    background: rgba(251, 191, 36, 0.08);
}

.sort-btn i {
    font-size: 0.85rem;
}

/* === Formulario de Comentario / Login Prompt === */
.comment-form-container {
    padding: 0;
    background: var(--comments-bg-secondary);
    border-bottom: 1px solid var(--comments-border);
}

.comment-login-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 2rem;
    background: rgba(0, 0, 0, 0.15);
    border: 2px dashed rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin: 1.5rem;
    text-align: center;
    gap: 1.5rem;
}

.comment-login-prompt p {
    color: var(--comments-text-muted);
    font-size: 1rem;
    max-width: 450px;
    line-height: 1.5;
    margin: 0;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment-input-wrapper {
    position: relative;
}

.comment-textarea {
    width: 100%;
    min-height: 90px;
    max-height: 200px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--comments-border);
    border-radius: 10px;
    padding: 1rem;
    padding-right: 3.5rem;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    transition: all 0.2s ease;
}

.comment-textarea::placeholder {
    color: var(--comments-text-muted);
}

.comment-textarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--comments-accent);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);
}

.char-counter {
    position: absolute;
    bottom: 0.75rem;
    right: 1rem;
    font-size: 0.7rem;
    color: var(--comments-text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.char-counter.limit {
    color: #ef4444;
    font-weight: 600;
}

.comment-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* === Emoji Picker === */
.emoji-container {
    position: relative;
    display: inline-block;
}

.emoji-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--comments-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--comments-border-light);
    transform: scale(1.05);
}

.emoji-modal {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: #1a1a2e;
    border: 1px solid var(--comments-border);
    border-radius: 12px;
    padding: 12px;
    display: none;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    min-width: 200px;
}

.emoji-modal.show {
    display: grid;
}

.emoji-item {
    font-size: 1.3rem;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    text-align: center;
}

.emoji-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.15);
}

/* === Botón Comentar === */
.btn-comment {
    background: var(--comments-gradient);
    color: #000;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.25);
}

.btn-comment:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.8);
    box-shadow: none;
}

.btn-comment:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.35);
}

.btn-comment:active:not(:disabled) {
    transform: translateY(0);
}

.btn-comment i {
    font-size: 0.8rem;
}

/* === Auth Prompt === */
.comment-auth-prompt {
    padding: 1.5rem !important;
    text-align: center;
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px dashed var(--comments-border) !important;
    border-radius: 10px !important;
}

.comment-auth-prompt p {
    margin-bottom: 1rem;
    color: var(--comments-text-muted);
    font-size: 0.9rem;
}

/* === Lista de Comentarios === */
.comments-list {
    display: flex;
    flex-direction: column;
}

.comments-list-inner {
    padding: 0;
}

/* === Comentario Individual === */
.comment-item {
    display: flex;
    flex-direction: row;
    gap: 12px;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--comments-border);
    animation: commentFadeIn 0.4s ease both;
    transition: background 0.2s ease;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-item:hover {
    background: rgba(255, 255, 255, 0.015);
}

/* Wrapper para comentario con sus respuestas */
.comment-thread {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--comments-border);
}

.comment-thread:last-child {
    border-bottom: none;
}

.comment-thread>.comment-item {
    border-bottom: none;
}

@keyframes commentFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Avatar === */
.comment-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--comments-border);
    flex-shrink: 0;
    transition: border-color 0.2s ease;
}

.comment-item:hover .comment-avatar {
    border-color: var(--comments-border-light);
}

/* === Contenido del Comentario === */
.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.comment-username {
    font-weight: 600;
    color: #fff;
    font-size: 0.9rem;
}

/* === Badges === */
.comment-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-admin {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.badge-author {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #fff;
}

.badge-verified {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
}

.comment-time {
    font-size: 0.75rem;
    color: var(--comments-text-muted);
}

/* === Video Info (Mini Card) === */
.comment-video-info {
    margin: 6px 0 8px 0;
}

.video-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--comments-border);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    max-width: 100%;
}

.video-link:hover {
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.3);
}

.video-link-icon {
    width: 24px;
    height: 24px;
    background: var(--comments-accent);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.video-link-icon i {
    color: #000;
    font-size: 0.6rem;
}

.video-link-text {
    font-size: 0.75rem;
    color: var(--comments-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-link:hover .video-link-text {
    color: var(--comments-accent);
}

/* === Texto del Comentario === */
.comment-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--comments-text);
    word-break: break-word;
    margin: 4px 0;
}

/* === Acciones del Comentario === */
.comment-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

.comment-action-btn {
    background: none;
    border: none;
    color: var(--comments-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
    transition: all 0.2s ease;
}

.comment-action-btn:hover {
    color: var(--comments-text);
}

.comment-action-btn i {
    font-size: 0.85rem;
}

/* Like Button */
.btn-like-comment {
    transition: all 0.2s ease;
}

.btn-like-comment:hover {
    color: var(--comments-like-color);
}

.btn-like-comment.liked {
    color: var(--comments-like-color);
}

.btn-like-comment.liked i {
    animation: heartPulse 0.3s ease;
}

@keyframes heartPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }
}

.like-count {
    font-weight: 600;
    font-size: 0.85rem;
}

/* Reply Button */
.btn-reply-comment:hover {
    color: var(--comments-accent);
}

/* Report Button */
.btn-report {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.comment-item:hover .btn-report {
    opacity: 1;
}

.btn-report:hover {
    color: #ef4444 !important;
}

/* === Hilos de Respuestas (Threads) === */
.comment-replies {
    margin-left: var(--comments-reply-indent);
    margin-top: 0;
    border-left: 2px solid var(--comments-border);
    display: flex;
    flex-direction: column;
}

.comment-replies .comment-item {
    display: flex;
    flex-direction: row;
    padding-left: 1rem;
    background: rgba(0, 0, 0, 0.15);
}

.comment-replies .comment-item:first-child {
    border-top: none;
}

.comment-replies .comment-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.comment-replies .comment-content {
    flex: 1;
    min-width: 0;
}

.comment-replies .comment-text {
    font-size: 0.9rem;
}

/* Reply Form */
.reply-form-container {
    margin-left: var(--comments-reply-indent);
    padding: 1rem 1rem 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-left: 2px solid var(--comments-accent);
    display: none;
}

.reply-form-container.active {
    display: block;
    animation: replySlideIn 0.3s ease;
}

@keyframes replySlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reply-form {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.reply-textarea {
    flex: 1;
    min-height: 60px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--comments-border);
    border-radius: 8px;
    padding: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
}

.reply-textarea:focus {
    outline: none;
    border-color: var(--comments-accent);
}

.reply-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-send-reply {
    background: var(--comments-accent);
    color: #000;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-send-reply:hover {
    background: var(--comments-accent-hover);
}

.btn-cancel-reply {
    background: transparent;
    color: var(--comments-text-muted);
    border: 1px solid var(--comments-border);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel-reply:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--comments-text);
}

/* Show/Hide Replies Toggle */
.toggle-replies {
    background: none;
    border: none;
    color: var(--comments-accent);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 1.5rem;
    padding-left: calc(var(--comments-reply-indent) + 1.5rem);
    transition: all 0.2s ease;
    text-align: left;
}

.toggle-replies:hover {
    color: var(--comments-accent-hover);
    background: rgba(251, 191, 36, 0.05);
}

.toggle-replies i {
    transition: transform 0.2s ease;
    font-size: 0.7rem;
}

.toggle-replies.expanded i {
    transform: rotate(180deg);
}

/* === Load More === */
.load-more-container {
    padding: 1.25rem;
    text-align: center;
    border-top: 1px solid var(--comments-border);
}

.btn-load-more {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--comments-border);
    color: var(--comments-text);
    padding: 10px 28px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-load-more:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--comments-border-light);
}

/* === Skeleton Loaders === */
.skeleton-comment {
    display: flex;
    gap: 12px;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--comments-border);
}

.skeleton-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(90deg, #1a1a2e 25%, #252545 50%, #1a1a2e 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    flex-shrink: 0;
}

.skeleton-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #1a1a2e 25%, #252545 50%, #1a1a2e 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
}

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

    100% {
        background-position: -200% 0;
    }
}

/* === Empty State === */
.comments-empty {
    padding: 3rem 1.5rem;
    text-align: center;
}

.comments-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.comments-empty-text {
    color: var(--comments-text-muted);
    font-size: 0.95rem;
}

.comments-empty-subtext {
    color: var(--comments-text-muted);
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* Desktop Large (1440px+) */
@media (min-width: 1440px) {
    .comments-section {
        max-width: 850px;
    }

    .comment-item {
        padding: 1.5rem 2rem;
    }

    .comment-form-container {
        padding: 2rem;
    }
}

/* Desktop Medium (1200px - 1439px) */
@media (min-width: 1200px) and (max-width: 1439px) {
    .comments-section {
        max-width: 780px;
    }
}

/* Desktop Small / Laptop (992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .comments-section {
        max-width: 700px;
    }

    .comments-header {
        padding: 1rem 1.25rem;
    }

    .comment-item {
        padding: 1rem 1.25rem;
    }

    .comment-avatar {
        width: 38px;
        height: 38px;
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .comments-section {
        max-width: 100%;
        margin: 1.5rem 1rem 4rem 1rem;
        border-radius: 12px;
    }

    .comments-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem 1.25rem;
    }

    .comments-sort-controls {
        width: 100%;
    }

    .sort-btn {
        flex: 1;
        justify-content: center;
    }
}

/* Mobile (max 767px) */
@media (max-width: 767px) {
    .comments-section {
        margin: 0;
        padding: 0;
        border-radius: 0;
        max-width: 100%;
        border-left: none;
        border-right: none;
        background: var(--comments-bg);
        box-shadow: none;
    }

    .comments-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .comments-title {
        font-size: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .title-main {
        font-size: 1.1rem;
    }

    .comments-channel-badge {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    .comments-sort-controls {
        width: 100%;
    }

    .sort-btn {
        flex: 1;
        justify-content: center;
        padding: 8px 10px;
    }

    .comment-form-container {
        padding: 1rem;
    }

    .comment-textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 1rem;
        min-height: 100px;
    }

    .btn-comment {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .comment-form-footer {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .emoji-container {
        width: 100%;
    }

    .emoji-trigger {
        width: 100%;
        justify-content: center;
    }

    .emoji-modal {
        grid-template-columns: repeat(6, 1fr);
        width: calc(100vw - 2rem);
        left: 50%;
        transform: translateX(-50%);
    }

    .comment-item {
        padding: 1rem;
        gap: 10px;
    }

    .comment-avatar {
        width: 36px;
        height: 36px;
    }

    .comment-text {
        font-size: 0.9rem;
    }

    .comment-actions {
        gap: 12px;
    }

    .btn-report {
        opacity: 1;
    }

    /* Threads on mobile */
    .comment-replies {
        margin-left: 24px;
    }

    .reply-form-container {
        margin-left: 24px;
        padding: 0.75rem;
    }

    .reply-form {
        flex-direction: column;
    }

    .reply-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .video-link {
        max-width: 100%;
    }

    .video-link-text {
        max-width: 200px;
    }
}

/* === Utilidades === */
.text-muted {
    color: var(--comments-text-muted);
}

.text-center {
    text-align: center;
}

.py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* Fix para animación de loading */
.fa-spin {
    animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}