/**
 * CDRRMO Video Library Widget Styles
 * Inspired by Bulacan PDRRMO video content design
 *
 * @version 1.0.0
 */

/* ============================================================
   CONTAINER
   ============================================================ */

.video-library-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.95), rgba(15, 23, 42, 0.98));
    border-radius: 12px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.video-library-section {
    background: rgba(30, 41, 59, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.video-library-section .section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.2), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.video-library-section .section-icon {
    font-size: 1.5rem;
}

.video-library-section .header-text {
    flex: 1;
}

.video-library-section .header-text h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #f1f5f9;
}

.video-library-section .subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ============================================================
   CONTROLS
   ============================================================ */

.video-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-box input {
    width: 250px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    outline: none;
}

.search-box input:focus {
    border-color: rgba(168, 85, 247, 0.5);
}

.filter-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-box label {
    font-size: 0.8rem;
    color: #94a3b8;
}

.filter-box select {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    outline: none;
}

/* ============================================================
   CONTENT
   ============================================================ */

.video-content {
    padding: 1rem;
}

/* ============================================================
   FEATURED SECTION
   ============================================================ */

.featured-section {
    margin-bottom: 1.5rem;
}

.featured-section h4,
.categories-section h4 {
    font-size: 0.95rem;
    color: #e2e8f0;
    margin: 0 0 0.75rem 0;
}

.featured-videos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* ============================================================
   CATEGORY GRID
   ============================================================ */

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    border-left: 3px solid #a855f7;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-card:hover {
    background: rgba(168, 85, 247, 0.15);
    transform: translateX(4px);
}

.category-icon {
    font-size: 1.5rem;
}

.category-info {
    flex: 1;
}

.category-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #f1f5f9;
}

.category-count {
    font-size: 0.7rem;
    color: #94a3b8;
}

.category-arrow {
    color: #a855f7;
    font-size: 1.2rem;
}

/* ============================================================
   VIDEO CARD
   ============================================================ */

.video-card {
    background: rgba(15, 23, 42, 0.7);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(168, 85, 247, 0.3);
}

.video-card.featured {
    border-color: rgba(234, 179, 8, 0.3);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: rgba(30, 41, 59, 0.8);
    cursor: pointer;
    overflow: hidden;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(59, 130, 246, 0.2));
}

.play-icon {
    font-size: 2.5rem;
    color: rgba(255, 255, 255, 0.8);
    transition: transform 0.2s ease;
}

.video-thumbnail:hover .play-icon {
    transform: scale(1.2);
    color: #a855f7;
}

.video-duration {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.7rem;
    border-radius: 4px;
}

.video-info {
    padding: 0.75rem;
}

.video-title {
    margin: 0 0 0.4rem 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.3;
    cursor: pointer;
}

.video-title:hover {
    color: #a855f7;
}

.video-description {
    margin: 0 0 0.5rem 0;
    font-size: 0.75rem;
    color: #94a3b8;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.video-views {
    font-size: 0.7rem;
    color: #64748b;
}

.video-language {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    border-radius: 3px;
    font-weight: 600;
}

.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.video-tags .tag,
.player-tags .tag {
    font-size: 0.6rem;
    padding: 0.1rem 0.3rem;
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border-radius: 2px;
}

/* ============================================================
   CATEGORY VIEW
   ============================================================ */

.category-view,
.search-results {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.category-header,
.results-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.back-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    background: rgba(30, 41, 59, 0.8);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
}

.category-header h4,
.results-header h4 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    color: #f1f5f9;
}

.video-count {
    font-size: 0.75rem;
    color: #94a3b8;
}

.category-description {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 0 1rem 0;
}

.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* ============================================================
   VIDEO PLAYER MODAL
   ============================================================ */

.video-player-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-player-modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: rgba(30, 41, 59, 0.98);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    background: rgba(15, 23, 42, 0.8);
    color: #94a3b8;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(220, 38, 38, 0.3);
    color: #f87171;
}

.video-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

.video-player iframe {
    width: 100%;
    height: 100%;
}

.player-info {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.player-info h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: #f1f5f9;
}

.player-info p {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.5;
}

.player-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.75rem;
}

.player-tags {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ============================================================
   NO VIDEOS
   ============================================================ */

.no-videos {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #64748b;
    font-size: 0.9rem;
}

/* ============================================================
   ERROR STATE
   ============================================================ */

.video-library-section.error .error-content {
    text-align: center;
    padding: 2rem;
}

.video-library-section.error .error-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.video-library-section.error p {
    color: #94a3b8;
    margin-bottom: 1rem;
}

.video-library-section.error .retry-btn {
    padding: 0.5rem 1rem;
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 4px;
    cursor: pointer;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .video-library-container {
        padding: 0.5rem;
        border-radius: 8px;
    }

    .video-controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .search-box input {
        width: 100%;
    }

    .featured-videos,
    .videos-grid {
        grid-template-columns: 1fr;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .category-header,
    .results-header {
        flex-wrap: wrap;
    }

    .back-btn {
        order: -1;
        width: 100%;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .video-card,
    .category-card {
        transition: none;
    }

    .category-view,
    .search-results {
        animation: none;
    }
}

/* ============================================================
   VIDEO SOURCE TOGGLE (Local vs YouTube)
   ============================================================ */

.video-source-toggle {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.source-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: rgba(30, 41, 59, 0.8);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.source-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    color: #e2e8f0;
}

.source-btn.active {
    background: rgba(168, 85, 247, 0.3);
    color: #a855f7;
    border-color: rgba(168, 85, 247, 0.5);
}

/* Local video player styling */
.video-player.local-player video {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 0;
}

.video-player.local-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
}

/* Offline available badge */
.local-badge {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Video card offline indicator */
.video-card .offline-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(34, 197, 94, 0.9);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    z-index: 2;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    .video-library-container {
        display: none;
    }
}
