/**
 * YouTubeFeed - Frontend Styles
 * 
 * CSS responsive mobile-first per la visualizzazione dei video
 */

/* ========================================
   RESET & BASE
   ======================================== */

.ytf-container {
    width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

.ytf-container * {
    box-sizing: border-box;
}

/* ========================================
   GRID LAYOUT
   ======================================== */

.ytf-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: 1fr;
}

/* Mobile First */
@media (min-width: 480px) {
    .ytf-grid.ytf-grid-cols-2,
    .ytf-grid.ytf-grid-cols-3,
    .ytf-grid.ytf-grid-cols-4,
    .ytf-grid.ytf-grid-cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet */
@media (min-width: 768px) {
    .ytf-grid.ytf-grid-cols-3,
    .ytf-grid.ytf-grid-cols-4,
    .ytf-grid.ytf-grid-cols-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .ytf-grid.ytf-grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ytf-grid.ytf-grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .ytf-grid.ytf-grid-cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .ytf-grid.ytf-grid-cols-6 {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ========================================
   VIDEO CARD
   ======================================== */

.ytf-video-card {
    background: var(--ytf-card-bg, #ffffff);
    border-radius: var(--ytf-border-radius, 12px);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ytf-video-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ytf-hover-shadow, 0 12px 24px rgba(0, 0, 0, 0.15));
}

/* ========================================
   THUMBNAIL
   ======================================== */

.ytf-thumbnail-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Ratio 16:9 */
    overflow: hidden;
    background: #000;
}

.ytf-thumbnail-wrapper a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.ytf-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.ytf-video-card:hover .ytf-thumbnail {
    transform: scale(1.05);
}

/* ========================================
   PLAY OVERLAY
   ======================================== */

.ytf-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.ytf-thumbnail-wrapper:hover .ytf-play-overlay {
    opacity: 1;
}

.ytf-play-overlay .ytf-icon-play {
    width: 64px;
    height: 64px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.ytf-play-overlay .ytf-icon-play circle {
    fill: rgba(255, 0, 0, 0.9);
}

/* ========================================
   DURATION BADGE
   ======================================== */

.ytf-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    z-index: 10;
}

/* ========================================
   SOURCE BADGE (Debug)
   ======================================== */

.ytf-badge-source {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
    line-height: 1;
}

.ytf-badge-rss {
    background: rgba(59, 130, 246, 0.9);
    color: #fff;
}

.ytf-badge-api {
    background: rgba(16, 185, 129, 0.9);
    color: #fff;
}

/* ========================================
   CONTENT
   ======================================== */

.ytf-content {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========================================
   TITLE
   ======================================== */

.ytf-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ytf-title-color, #1f2937);
}

.ytf-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ytf-title a:hover {
    color: var(--ytf-title-hover-color, #ef4444);
}

/* ========================================
   DESCRIPTION
   ======================================== */

.ytf-description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ytf-description-color, #6b7280);
    margin: 0;
    flex: 1;
}

/* ========================================
   META & STATS
   ======================================== */

.ytf-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: var(--ytf-meta-color, #9ca3af);
}

.ytf-stats {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.ytf-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ytf-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   ICONS
   ======================================== */

.ytf-icon {
    width: 16px;
    height: 16px;
    color: var(--ytf-icon-color, #9ca3af);
}

/* ========================================
   EMPTY STATE & ERRORS
   ======================================== */

.ytf-empty-state,
.ytf-error {
    text-align: center;
    padding: 60px 20px;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px dashed #d1d5db;
}

.ytf-empty-icon {
    margin-bottom: 20px;
    color: #9ca3af;
}

.ytf-empty-state h3 {
    margin: 0 0 12px;
    font-size: 20px;
    color: #374151;
}

.ytf-empty-state p {
    margin: 0 0 20px;
    color: #6b7280;
}

.ytf-error p {
    margin: 0;
    color: #dc2626;
    font-weight: 500;
}

/* ========================================
   LIGHTBOX / MODAL
   ======================================== */

.ytf-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ytf-lightbox-overlay.ytf-active {
    opacity: 1;
    visibility: visible;
}

.ytf-lightbox-content {
    position: relative;
    width: 100%;
    max-width: 1200px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ytf-lightbox-overlay.ytf-active .ytf-lightbox-content {
    transform: scale(1);
}

.ytf-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: transform 0.2s ease;
}

.ytf-lightbox-close:hover {
    transform: scale(1.1);
}

.ytf-lightbox-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Mobile lightbox adjustments */
@media (max-width: 768px) {
    .ytf-lightbox-overlay {
        padding: 0;
    }
    
    .ytf-lightbox-content {
        max-width: 100%;
        border-radius: 0;
    }
    
    .ytf-lightbox-close {
        top: 10px;
        right: 10px;
        background: rgba(0, 0, 0, 0.7);
        border-radius: 50%;
        font-size: 24px;
    }
}

/* ========================================
   LOADING / SKELETON
   ======================================== */

.ytf-loading {
    text-align: center;
    padding: 40px 20px;
}

.ytf-skeleton {
    animation: ytf-pulse 1.5s ease-in-out infinite;
}

@keyframes ytf-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.ytf-skeleton .ytf-thumbnail {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: ytf-shimmer 1.5s infinite;
}

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

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

@media (max-width: 767px) {
    .ytf-container {
        padding: 16px 0;
    }
    
    .ytf-grid {
        gap: 16px;
    }
    
    .ytf-content {
        padding: 12px;
        gap: 8px;
    }
    
    .ytf-title {
        font-size: 15px;
    }
    
    .ytf-description {
        font-size: 13px;
    }
    
    .ytf-meta {
        font-size: 12px;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .ytf-video-card {
        background: var(--ytf-card-bg, #1f2937);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .ytf-video-card:hover {
        box-shadow: var(--ytf-hover-shadow, 0 12px 24px rgba(0, 0, 0, 0.5));
    }
    
    .ytf-title {
        color: var(--ytf-title-color, #f9fafb);
    }
    
    .ytf-description {
        color: var(--ytf-description-color, #d1d5db);
    }
    
    .ytf-empty-state {
        background: #1f2937;
        border-color: #374151;
    }
    
    .ytf-empty-state h3 {
        color: #f9fafb;
    }
    
    .ytf-empty-state p {
        color: #d1d5db;
    }
}

/* ========================================
   LOAD MORE BUTTON
   ======================================== */

.ytf-load-more-wrapper {
    text-align: center;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.ytf-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--ytf-button-bg, #3b82f6);
    color: #fff;
    border: none;
    padding: 12px 32px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.ytf-load-more-btn:hover {
    background: var(--ytf-button-hover-bg, #2563eb);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.ytf-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ytf-load-more-btn.ytf-loading {
    pointer-events: none;
}

.ytf-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ytf-spin 0.6s linear infinite;
}

.ytf-load-more-info {
    font-size: 14px;
    color: var(--ytf-meta-color, #6b7280);
    text-align: center;
}

.ytf-loaded-count,
.ytf-total-count {
    font-weight: 600;
    color: var(--ytf-title-color, #1f2937);
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .ytf-play-overlay,
    .ytf-lightbox-overlay {
        display: none !important;
    }
    
    .ytf-video-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.ytf-video-link:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.ytf-lightbox-close:focus {
    outline: 2px solid #fff;
    outline-offset: 4px;
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ytf-video-card,
    .ytf-thumbnail,
    .ytf-play-overlay,
    .ytf-lightbox-overlay,
    .ytf-lightbox-content {
        transition: none;
        animation: none;
    }
}

/* Screen reader only */
.ytf-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

