/* ============================================
   SHORT VIDEOS PLUGIN - STYLES
   ============================================ */

/* Banner de anuncios en reproductor */
.videos-ad-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-height: 50px;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

.videos-ad-banner .ad-space,
.videos-ad-banner ins {
    max-height: 90px;
}

/* El video ocupa 100% - el banner está por encima en fixed */

/* Tab de videos */
.videos-tab-btn {
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.videos-tab-btn .private-item {
    background: linear-gradient(135deg, #ff0050, #00f2ea);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.videos-tab-btn .private-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 0, 80, 0.4);
}

.videos-tab-btn.active .private-item {
    box-shadow: 0 0 20px rgba(255, 0, 80, 0.6);
}

.videos-tab-btn .pill {
    position: absolute;
    left: -10px;
    width: 4px;
    height: 0;
    background: #fff;
    border-radius: 0 4px 4px 0;
    transition: height 0.2s;
}

.videos-tab-btn.active .pill {
    height: 24px;
}

.videos-tab-btn .tab-label {
    display: block;
    font-size: 9px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    margin-top: 2px;
    white-space: nowrap;
    color: #fff;
}

/* Panel de videos - hereda estilos de sidebar-private */
.sidebar-videos {
    display: none;
    background: var(--tblr-bg-surface, #fff);
}

/* Forzar ancho mínimo del sidebar cuando My Videos está visible */
#sidebar-wrapper:has(#my-videos-panel[style*="block"]) {
    min-width: 240px !important;
}

/* Fallback para navegadores sin :has() - clase añadida por JS */
#sidebar-wrapper.videos-active {
    min-width: 240px !important;
}

/* Header con tabs */
.videos-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--tblr-border-color, rgba(98,105,118,.16));
    gap: 10px;
}

.videos-tabs {
    display: flex;
    flex: 1;
    gap: 5px;
}

.videos-tab-item {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--tblr-muted);
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.videos-tab-item i {
    font-size: 18px;
}

.videos-tab-item:hover {
    background: var(--tblr-bg-surface-secondary, #f1f5f9);
    color: var(--tblr-body-color);
}

.videos-tab-item.active {
    background: var(--tblr-primary);
    color: #fff;
}

.videos-upload-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* Contenedor de videos */
.videos-container {
    height: calc(100vh - 120px);
    overflow: hidden;
}

.videos-feed {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 10px;
}

.videos-feed.active {
    display: block;
}

.videos-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
}

/* Grid de videos en el sidebar */
.videos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.video-grid-item {
    position: relative;
    aspect-ratio: 9/16;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
}

.video-grid-item img,
.video-grid-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-grid-item .video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: #fff;
}

.video-grid-item .video-stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
}

.video-grid-item .video-stats i {
    margin-right: 2px;
}

.video-grid-item:hover .video-play-icon {
    opacity: 1;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.video-play-icon i {
    color: #000;
    font-size: 20px;
    margin-left: 3px;
}

/* Empty state */
.videos-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--tblr-muted);
}

.videos-empty i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 15px;
}

/* Header title para My Videos */
.videos-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.videos-header-title i {
    font-size: 20px;
}

/* My Videos Grid - 2 columnas con scroll */
.my-videos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
}

/* Card de video individual */
.my-video-card {
    background: var(--tblr-bg-surface, #fff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.my-video-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.12);
}

.my-video-thumb {
    position: relative;
    aspect-ratio: 9/16;
    cursor: pointer;
    overflow: hidden;
    background: #000;
}

.my-video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.my-video-card:hover .my-video-thumb img {
    transform: scale(1.05);
}

.my-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.my-video-card:hover .my-video-play {
    opacity: 1;
}

.my-video-play i {
    font-size: 24px;
    color: #1a1a1a;
    margin-left: 3px;
}

.my-video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.my-video-info {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.my-video-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--tblr-muted, #667085);
}

.my-video-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.my-video-stats i {
    font-size: 14px;
}

.my-video-status {
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.my-video-status.active {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.my-video-status.processing {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.my-video-status.pending {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.my-video-actions {
    display: flex;
    border-top: 1px solid var(--tblr-border-color, #e5e7eb);
}

.my-video-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.my-video-actions button:first-child {
    border-right: 1px solid var(--tblr-border-color, #e5e7eb);
}

.my-video-actions .btn-video-edit {
    color: #3b82f6;
}

.my-video-actions .btn-video-edit:hover {
    background: rgba(59, 130, 246, 0.1);
}

.my-video-actions .btn-video-delete {
    color: #ef4444;
}

.my-video-actions .btn-video-delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

.my-video-actions i {
    font-size: 18px;
}

/* Estilo antiguo para compatibilidad */
.video-grid-item {
    position: relative;
    aspect-ratio: 9/16;
    cursor: pointer;
    overflow: hidden;
    border-radius: 4px;
}

.video-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-grid-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff;
}

.video-grid-overlay .video-views {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================
   MODAL REPRODUCTOR FULLSCREEN
   ============================================ */

.videos-player-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 9999;
}

.videos-player-modal.active {
    display: flex;
}

.videos-player-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Swiper vertical - TikTok style (usando Swiper.js) */
.videos-swiper {
    width: 100%;
    height: 100%;
}

.videos-swiper .swiper-wrapper {
    height: 100%;
}

/* Cada slide de video - 100% viewport */
.video-slide {
    width: 100%;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport para móviles */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
}

.video-slide video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Móvil: llenar pantalla */
}

/* Desktop: mostrar video completo sin recortar */
@media (min-aspect-ratio: 1/1) {
    .video-slide video {
        width: auto;
        height: 100%;
        max-width: 100%;
        object-fit: contain;
    }
}

/* Información del video */
.video-info {
    position: absolute;
    bottom: 80px;
    left: 15px;
    right: 80px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.video-info .video-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.video-info .video-user img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.video-info .video-username {
    font-weight: 600;
    font-size: 15px;
}

.video-info .follow-btn {
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 4px;
    background: #fe2c55;
    color: #fff;
    border: none;
    cursor: pointer;
}

.video-info .follow-btn.following {
    background: transparent;
    border: 1px solid #fff;
}

.video-info .video-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
}

.video-info .video-description {
    font-size: 13px;
    opacity: 0.9;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Acciones laterales */
.video-actions {
    position: absolute;
    right: 10px;
    bottom: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.video-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #fff;
    background: none;
    border: none;
    cursor: pointer;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.video-action-btn i {
    font-size: 28px;
    transition: transform 0.2s;
}

.video-action-btn span {
    font-size: 11px;
    font-weight: 500;
}

.video-action-btn:hover i {
    transform: scale(1.1);
}

.video-action-btn.liked i {
    color: #fe2c55;
}

.video-action-btn.liked i::before {
    content: "\ed2a"; /* ti-heart-filled */
}

/* Botón cerrar */
.player-close-btn {
    position: fixed;
    top: 60px; /* Debajo del banner de anuncios */
    left: 15px;
    z-index: 10002; /* Por encima del banner */
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-close-btn:hover {
    background: rgba(0,0,0,0.7);
}

/* Progress bar */
.video-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.3);
}

.video-progress-bar {
    height: 100%;
    background: #fff;
    width: 0;
    transition: width 0.1s linear;
}

/* ============================================
   MODAL UPLOAD
   ============================================ */

.upload-dropzone {
    border: 2px dashed var(--tblr-border-color, #dee2e6);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.2s;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-dropzone.dragover {
    border-color: var(--tblr-primary);
    background: rgba(32, 107, 196, 0.05);
}

.dropzone-content i {
    font-size: 64px;
    color: var(--tblr-muted);
    margin-bottom: 15px;
}

.dropzone-content h4 {
    margin-bottom: 10px;
}

/* Progress circular */
.upload-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.upload-progress .upload-file-info {
    font-size: 0.875rem;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-circle {
    width: 120px;
    height: 120px;
    position: relative;
}

.progress-circle svg {
    transform: rotate(-90deg);
}

.progress-circle .progress-bg {
    fill: none;
    stroke: var(--tblr-border-color, #dee2e6);
    stroke-width: 8;
}

.progress-circle .progress-bar {
    fill: none;
    stroke: var(--tblr-primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 0.3s;
}

.progress-circle .progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 600;
}

/* Compressing state: hide progress circle, show spinner + "Compressing, please wait" */
.progress-circle .compressing-loading {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.progress-circle .compressing-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--tblr-border-color, #dee2e6);
    border-top-color: var(--tblr-primary, #206bc4);
    border-radius: 50%;
    flex-shrink: 0;
    animation: short-videos-spin 0.8s linear infinite;
}

.upload-progress.compressing .progress-circle-svg,
.upload-progress.compressing .progress-text {
    display: none;
}

.upload-progress.compressing .compressing-loading {
    display: flex;
}

@keyframes short-videos-spin {
    to { transform: rotate(360deg); }
}

/* Video preview */
.video-preview-container {
    aspect-ratio: 9/16;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    max-height: 400px;
}

.video-preview-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Video details form */
.video-details-form {
    padding-top: 15px;
}

/* ============================================
   MODAL COMENTARIOS
   ============================================ */

.comments-list {
    max-height: 400px;
    overflow-y: auto;
}

.comment-item {
    display: flex;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--tblr-border-color, #f1f3f5);
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.comment-content {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-username {
    font-weight: 600;
    font-size: 13px;
}

.comment-time {
    color: var(--tblr-muted);
    font-size: 11px;
}

.comment-text {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.comment-actions {
    display: flex;
    gap: 15px;
    margin-top: 6px;
}

.comment-action {
    font-size: 11px;
    color: var(--tblr-muted);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.comment-action:hover {
    color: var(--tblr-body-color);
}

.comment-input-container {
    display: flex;
    gap: 8px;
    width: 100%;
}

.comment-input-container input {
    flex: 1;
}

/* Empty comments */
.comments-empty {
    text-align: center;
    padding: 40px;
    color: var(--tblr-muted);
}

/* ============================================
   MODAL COMPARTIR / REPORT - Z-INDEX FIX
   ============================================ */

/* Asegurar que modales de Bootstrap aparezcan sobre el reproductor */
.videos-player-modal.active ~ .modal,
.modal.show {
    z-index: 10050 !important;
}

.videos-player-modal.active ~ .modal-backdrop,
.modal-backdrop.show {
    z-index: 10040 !important;
}

/* Confirm upload modal must appear above the upload modal */
#confirmUploadModal.show {
    z-index: 10060 !important;
}

/* Backdrop for confirm modal (sibling immediately after it in DOM when open) */
#confirmUploadModal.show + .modal-backdrop {
    z-index: 10055 !important;
}

/* Modal de comentarios dentro del reproductor */
#commentsModal.show,
#shareVideoModal.show,
#reportVideoModal.show {
    z-index: 10050 !important;
}

.share-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px;
    border: 1px solid var(--tblr-border-color);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.share-option:hover {
    background: var(--tblr-bg-surface-secondary, #f8f9fa);
    border-color: var(--tblr-primary);
}

.share-option i {
    font-size: 24px;
}

.share-option span {
    font-size: 12px;
}

.share-option[data-type="whatsapp"] i { color: #25d366; }
.share-option[data-type="twitter"] i { color: #1da1f2; }
.share-option[data-type="facebook"] i { color: #1877f2; }

/* ============================================
   DARK MODE
   ============================================ */

[data-bs-theme="dark"] .sidebar-videos {
    background: var(--tblr-bg-surface, #1a1d2e);
}

[data-bs-theme="dark"] .video-grid-item {
    background: #0f0f0f;
}

[data-bs-theme="dark"] .upload-dropzone {
    border-color: var(--tblr-border-color-dark, #3a3f5c);
}

[data-bs-theme="dark"] .share-option:hover {
    background: rgba(255,255,255,0.05);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .video-info {
        right: 70px;
        bottom: 100px;
    }
    
    .video-actions {
        right: 8px;
        bottom: 120px;
        gap: 15px;
    }
    
    .video-action-btn i {
        font-size: 24px;
    }
}
