/* ===========================
   Modern Sleek Theme
   =========================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f0f0f5;
    --text-secondary: #8b8b9e;
    --text-muted: #5c5c72;
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.25);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-fast: 180ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* General Body Styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header Styles */
header {
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle) !important;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Navbar Brand Styles */
.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary) !important;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-fast);
}
.navbar-brand:hover {
    opacity: 0.8;
}
@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.2rem;
        max-width: 60vw;
        white-space: normal;
        word-break: break-word;
        text-align: left;
    }
}

/* Navigation Link Styles */
.nav-link {
    color: var(--text-secondary) !important;
    transition: color var(--transition-fast);
    position: relative;
    padding-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.nav-link:hover {
    color: var(--text-primary) !important;
}
.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 1px;
    transition: width var(--transition-smooth);
}
.nav-link:hover::after {
    width: 100%;
}

/* Search Input */
#search-input {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
#search-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    outline: none;
}
#search-input::placeholder {
    color: var(--text-muted);
}

/* Player Section Styles */
#player-section {
    width: 100%;
}

.video-player-container {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.video-details {
    background: var(--bg-secondary);
}

.video-details h2 {
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}

.video-details hr {
    border-color: var(--border-subtle);
    opacity: 0.5;
}

.video-js {
    width: 100%;
    height: 100%;
}

/* Player Buttons */
#share-video-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
#share-video-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

#embed-video-btn {
    border-color: var(--border-hover);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
    transition: all var(--transition-fast);
}
#embed-video-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

#close-player-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
    transition: all var(--transition-fast);
}
#close-player-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* In-player quality control */
.video-js .vjs-quality-control {
    display: flex;
    align-items: center;
    width: auto;
    padding: 0 0.25rem;
}

.video-js .vjs-quality-select {
    background: rgba(12, 12, 18, 0.92);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.2;
    padding: 0.2rem 1.35rem 0.2rem 0.45rem;
    min-width: 5.4rem;
    height: 1.9rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position: calc(100% - 11px) calc(50% - 2px), calc(100% - 6px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.video-js .vjs-quality-select:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 2px rgba(162, 155, 254, 0.25);
}

.video-js .vjs-quality-select option {
    background: #101018;
    color: #f0f0f5;
}

@media (max-width: 768px) {
    .video-js .vjs-quality-select {
        min-width: 4.8rem;
        font-size: 0.72rem;
        padding-left: 0.4rem;
        padding-right: 1.2rem;
    }
}

/* Category Navigation */
#category-filters {
    justify-content: center;
    gap: 0.4rem;
}

#category-filters .nav-links {
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.45rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

#category-filters .nav-links.active,
#category-filters .nav-links:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-color: transparent;
    box-shadow: 0 2px 12px var(--accent-glow);
}

/* Form selects (sort, per-page, category dropdown) */
.form-select {
    background-color: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Global dark-mode defaults for all dropdown menus */
select,
.form-select {
    color-scheme: dark;
}

select option,
.form-select option,
select optgroup,
.form-select optgroup {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Video Grid & Card Styles */
.content-section {
    margin-bottom: 2rem;
}

.section-header {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    justify-content: center;
}

/* Desktop: force 5 columns and center the grid */
@media (min-width: 992px) {
    .video-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        justify-content: center;
        max-width: calc(5 * 260px + 4 * 1.5rem);
        margin-left: auto;
        margin-right: auto;
    }
    .video-card {
        max-width: 260px;
    }
}

.video-card {
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding-bottom: 20px;
    border-radius: var(--radius-md);
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

.video-card:hover {
    transform: translateY(-6px) scale(1.02);
}

/* Hover/focus effect */
.video-card:focus,
.video-card:focus-visible,
.video-card:hover,
.video-card:active {
    transform: translateY(-6px) scale(1.02);
    z-index: 30;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-hover);
}

.video-card:focus .thumbnail-img,
.video-card:hover .thumbnail-img,
.video-card:active .thumbnail-img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Title overlay on hover */
.video-card:focus .card-title,
.video-card:hover .card-title,
.video-card:active .card-title {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    top: 0;
    display: -webkit-box;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    -webkit-box-orient: vertical;
    white-space: normal;
    overflow: auto;
    max-height: 6rem;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 40;
    color: var(--text-primary);
}

/* Smooth transitions for the pop-out */
.video-card,
.thumbnail-img,
.video-card .card-title {
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1), filter 280ms ease, opacity 280ms ease;
    transform-origin: center center;
}

.thumbnail-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--bg-secondary);
}

.thumbnail-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1), filter 280ms ease;
}

.video-card .card-body {
    padding-top: 0.75rem !important;
    position: relative;
}

.video-card .card-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    position: relative;
    letter-spacing: -0.01em;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    max-width: 100%;
}

.video-card .card-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

/* Hide view count and date on hover */
.video-card:focus .card-text,
.video-card:hover .card-text,
.video-card:active .card-text {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
}

/* Custom accessible tooltip */
.custom-tooltip {
    display: none;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.825rem;
    line-height: 1.3;
    max-width: 320px;
    word-wrap: break-word;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    z-index: 1000;
}
.custom-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(10, 10, 15, 0.95) transparent transparent transparent;
}

.ratio::before {
    padding-top: 0;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle) !important;
}
footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Pagination (if generated by JS) */
.pagination .page-link {
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    margin: 0 2px;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}
.pagination .page-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
    color: var(--text-primary);
}
.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-glow);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Selection */
::selection {
    background: var(--accent);
    color: #fff;
}

/* Embed Modal */
.embed-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.embed-modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.embed-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.embed-modal-header h5 {
    margin: 0;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
}

.embed-modal-body textarea {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.825rem;
    resize: vertical;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.embed-modal-body textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.embed-modal-body .btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.embed-preview-frame {
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}

.embed-preview-frame iframe {
    display: block;
    border: none;
    border-radius: var(--radius-sm);
}