/**
 * School Multimedia Management System - Custom Styles
 * Version: 1.0
 * Author: SMMS Team
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    /* Custom colors */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-video: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-audio: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-button: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    
    /* Shadows */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 8px 25px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --transition-fast: all 0.2s ease-in-out;
    --transition-normal: all 0.3s ease;
    --transition-slow: all 0.5s ease;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
body {
    background-color: var(--light-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

.container-content {
    min-height: calc(100vh - 200px);
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* ==========================================================================
   Navigation Styles
   ========================================================================== */
.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    transition: var(--transition-fast);
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.nav-link {
    transition: var(--transition-fast);
    border-radius: 0.375rem;
    margin: 0 0.25rem;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* ==========================================================================
   Card Styles
   ========================================================================== */
.card {
    border: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    border-radius: 15px;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.media-card {
    height: 100%;
    transition: var(--transition-normal);
    border-radius: 15px;
    overflow: hidden;
}

.media-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.card-img-top {
    transition: var(--transition-normal);
}

.media-card:hover .card-img-top {
    transform: scale(1.05);
}

/* ==========================================================================
   Media Thumbnails
   ========================================================================== */
.media-thumbnail {
    height: 200px;
    object-fit: cover;
    border-radius: 15px 15px 0 0;
    transition: var(--transition-normal);
}

.video-thumbnail {
    background: var(--gradient-video);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.audio-thumbnail {
    background: var(--gradient-audio);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.video-thumbnail i,
.audio-thumbnail i {
    transition: var(--transition-fast);
}

.media-card:hover .video-thumbnail i,
.media-card:hover .audio-thumbnail i {
    transform: scale(1.2);
}

/* ==========================================================================
   Button Styles
   ========================================================================== */
.btn-load-more {
    background: var(--gradient-button);
    border: none;
    padding: 12px 30px;
    font-weight: 600;
    border-radius: 25px;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.btn-load-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.btn {
    transition: var(--transition-fast);
    border-radius: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
}

/* ==========================================================================
   Filter Section
   ========================================================================== */
.filter-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.form-select,
.form-control {
    border-radius: 0.5rem;
    transition: var(--transition-fast);
    border: 1px solid #dee2e6;
}

.form-select:focus,
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    transform: translateY(-1px);
}

/* ==========================================================================
   Global Loader
   ========================================================================== */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    display: none;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: var(--shadow-sm);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Alert System
   ========================================================================== */
.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    max-width: 400px;
}

.alert-custom {
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease-out;
    border: none;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==========================================================================
   Select2 Customization
   ========================================================================== */
.select2-container--bootstrap-5 .select2-selection {
    min-height: calc(2.25rem + 2px);
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    transition: var(--transition-fast);
}

.select2-container--bootstrap-5 .select2-selection:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding-left: 0;
    padding-right: 20px;
    line-height: 1.5;
    color: #495057;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: calc(2.25rem + 2px);
    right: 3px;
}

.select2-dropdown {
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid #dee2e6;
}

.select2-results__option {
    padding: 0.5rem 0.75rem;
    transition: var(--transition-fast);
}

.select2-results__option--highlighted {
    background-color: var(--primary-color);
    color: white;
}

/* ==========================================================================
   Badge Styles
   ========================================================================== */
.badge {
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
}

/* ==========================================================================
   Footer Styles
   ========================================================================== */
.footer {
    background: var(--dark-color);
    color: white;
    padding: 40px 0 20px;
    margin-top: 50px;
}

.footer h5, .footer h6 {
    color: white;
    margin-bottom: 1rem;
}

.footer a {
    color: #adb5bd;
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer a:hover {
    color: white;
    transform: translateX(3px);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.jumbotron {
    background: var(--gradient-primary) !important;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
}

.jumbotron::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="50" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.1;
}

.jumbotron * {
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   Media Detail Page
   ========================================================================== */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 2rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--secondary-color);
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-fast);
}

.breadcrumb-item a:hover {
    color: var(--dark-color);
    transform: translateX(2px);
}

/* ==========================================================================
   Audio player container
   ========================================================================== */
.audio-player-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Playlist Styles
   ========================================================================== */
.playlist-container {
    border-radius: 15px;
    overflow: hidden;
}

.current-player {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
}

.playlist-controls .btn {
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.playlist-controls .btn-lg {
    width: 55px;
    height: 55px;
}

.playlist-controls .btn:hover {
    transform: scale(1.1);
    background-color: rgba(255, 255, 255, 0.2);
}

.playlist-item {
    transition: var(--transition-fast);
    cursor: pointer;
}

.playlist-item:hover {
    background-color: #f8f9fa;
}

.playlist-item.active {
    background-color: #e3f2fd;
    border-left: 4px solid var(--primary-color);
}

.playlist-item.playing {
    background-color: #e8f5e8;
}

.playlist-item.playing .track-index {
    display: none;
}

.playlist-item.playing .play-icon {
    display: inline-block !important;
    color: var(--primary-color);
    animation: pulse 1.5s infinite;
}

.playlist-item:not(.playing) .play-icon,
.playlist-item:not(.playing) .pause-icon {
    display: none !important;
}

.track-number {
    width: 30px;
    text-align: center;
    font-weight: 600;
    color: #666;
}

.track-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.track-meta {
    font-size: 0.85rem;
}

.progress:hover {
    cursor: pointer;
}

.progress-bar {
    transition: width 0.1s ease;
}

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

.btn.active {
    background-color: rgba(255, 255, 255, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* ==========================================================================
   Professional Color Scheme Override
   ========================================================================== */
:root {
    --primary-color: #1d9dd7 !important;
    --bs-primary: #1d9dd7 !important;
    --bs-primary-rgb: 29, 157, 215 !important;
}

.btn-primary {
    background-color: #1d9dd7 !important;
    border-color: #1d9dd7 !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: #1586b8 !important;
    border-color: #1586b8 !important;
}

.text-primary {
    color: #1d9dd7 !important;
}

.bg-primary {
    background-color: #1d9dd7 !important;
}

.border-primary {
    border-color: #1d9dd7 !important;
}

.spinner-border.text-primary {
    color: #1d9dd7 !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    .alert-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
    
    .container-content {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    .display-4 {
        font-size: 2rem;
    }
    
    .fs-1 {
        font-size: 2.5rem !important;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .media-thumbnail {
        height: 150px;
    }
    
    .filter-section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .playlist-controls .btn {
        width: 40px;
        height: 40px;
        margin: 0 0.25rem;
    }
    
    .playlist-controls .btn-lg {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 576px) {
    .jumbotron {
        padding: 2rem 1rem !important;
    }
    
    .display-4 {
        font-size: 1.75rem;
    }
    
    .lead {
        font-size: 1rem;
    }
    
    .media-thumbnail {
        height: 120px;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-primary {
    background: var(--gradient-primary);
}

.shadow-custom {
    box-shadow: var(--shadow-lg);
}

.border-radius-lg {
    border-radius: 15px;
}

.transition-fast {
    transition: var(--transition-fast);
}

.transition-normal {
    transition: var(--transition-normal);
}

/* ==========================================================================
   Loading States
   ========================================================================== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .navbar,
    .footer,
    .btn,
    .alert-container,
    .global-loader {
        display: none !important;
    }
    
    .container-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* ==========================================================================
   Modern Year Blocks Styles
   ========================================================================== */
.hero-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

.hero-stats {
    margin-top: 2rem;
}

.stat-item {
    padding: 1rem;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.2);
    transition: var(--transition-normal);
}

.stat-item:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.3);
}

.search-stat {
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.search-stat:hover {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-5px) scale(1.05);
}

.search-stat.active {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-5px) scale(1.05);
}

.search-form-container {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-form-container .form-control {
    border-radius: 50px 0 0 50px;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    box-shadow: var(--shadow-sm);
}

.search-form-container .btn {
    border-radius: 0 50px 50px 0;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
    border-left: none;
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
}

.search-container .form-control {
    border-radius: 50px;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
}

.search-container .input-group-text {
    border-radius: 50px 0 0 50px;
    padding: 1rem 1.5rem;
}

/* Year Block Cards */
.year-block-card {
    background: #fff;
    border-radius: 20px;
    padding: 2rem;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-md);
    height: 100%;
    min-height: 300px;
    position: relative;
    overflow: hidden;
}

.year-block-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: var(--transition-normal);
}

.year-block-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-xl);
}

.year-block-card:hover::before {
    opacity: 1;
}

/* Year block variants */
.year-current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.year-current .year-title {
    color: white;
}

.year-recent {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.year-recent .year-title {
    color: white;
}

/* .year-archive::before {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
} */

.year-block-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.year-title {
    font-size: 3rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, var(--primary-color), #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.year-current .year-title,
.year-recent .year-title {
    background: none;
    -webkit-text-fill-color: white;
    color: white;
}

.year-stats {
    margin-top: 0.5rem;
}

.total-count {
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.8;
}

.year-block-content {
    margin-bottom: 2rem;
}

.media-type-counts {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
}

.year-current .media-type-counts,
.year-recent .media-type-counts {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
}

.type-stat {
    text-align: center;
    opacity: 0.5;
    transition: var(--transition-fast);
}

.type-stat.has-content {
    opacity: 1;
    transform: scale(1.1);
}

.type-stat i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.type-stat span {
    font-weight: 600;
    font-size: 1.1rem;
}

.preview-content {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    padding: 1rem;
    border-left: 4px solid var(--primary-color);
}

.year-current .preview-content,
.year-recent .preview-content {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.media-icon {
    font-size: 2rem;
    opacity: 0.7;
}

.media-icon.video {
    color: #f5576c;
}

.media-icon.audio {
    color: #00f2fe;
}

.media-icon.image {
    color: #ffc107;
}

.preview-text {
    flex: 1;
}

.preview-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.preview-category {
    font-size: 0.9rem;
    opacity: 0.7;
}

.year-block-footer {
    position: absolute;
    bottom: 1.5rem;
    left: 2rem;
    right: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.latest-upload {
    font-size: 0.9rem;
    opacity: 0.7;
}

.latest-upload i {
    margin-right: 0.5rem;
}

.explore-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
    transition: var(--transition-fast);
}

.year-current .explore-btn,
.year-recent .explore-btn {
    color: rgba(255, 255, 255, 0.9);
}

.year-block-card:hover .explore-btn {
    transform: translateX(5px);
}

/* Modern Media Cards in Modal */
.modern-card {
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-sm);
    height: 100%;
}

.modern-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.media-preview {
    position: relative;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.media-card-video .media-preview {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.media-card-audio .media-preview {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.media-card-image .media-preview {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
}

.media-preview .media-icon {
    font-size: 3rem;
    color: white;
    opacity: 0.8;
}

.media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition-fast);
}

.modern-card:hover .media-overlay {
    opacity: 1;
}

.media-info {
    padding: 1rem;
}

.media-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.media-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    opacity: 0.7;
}

.media-category {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
}

/* Modal Enhancements */
.modal-xl {
    max-width: 1200px;
}

#mediaTypeTabs .nav-link {
    border-radius: 25px;
    margin: 0 0.25rem;
    font-weight: 600;
    transition: var(--transition-fast);
}

#mediaTypeTabs .nav-link:hover {
    transform: translateY(-2px);
}

#mediaTypeTabs .nav-link.active {
    background: var(--gradient-primary);
    border-color: transparent;
}

/* Responsive Design */
@media (max-width: 768px) {
    .year-block-card {
        padding: 1.5rem;
        min-height: 250px;
    }
    
    .year-title {
        font-size: 2.5rem;
    }
    
    .media-type-counts {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .year-block-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .search-container .form-control {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
}
