:root {
    --color-white: #fff;
    --color-gray-light: #eee;
    --color-gray-dark: #333;
    --color-highlight: #7d1bd1; /* Primary highlight color */
    --color-text: #333;
}

/* Base & Mobile First */
body {
    font-family: Arial, sans-serif;
    background-color: var(--color-white);
    color: var(--color-text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

/* --- Header & Logo Centering --- */
header {
    display: flex;
    justify-content: center; /* Center logo horizontally */
    align-items: center;
    padding: 15px 20px;
    background-color: var(--color-gray-light);
    border-bottom: 2px solid var(--color-highlight);
    position: relative; /* Anchor for absolute buttons */
}

.logo-link {
    display: flex;
}

.logo {
    height: 35px; /* Slightly smaller for mobile */
    transition: transform 0.2s;
}

.logo:hover {
    transform: scale(1.05);
}

/* --- Header Buttons (Absolute Positioning) --- */
.header-button {
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
    transition: background-color 0.3s;
    font-size: 0.9em;
    position: absolute;
    z-index: 10;
}

.top-left {
    left: 20px;
    /* Vertically align with the logo */
    top: 50%;
    transform: translateY(-50%);
}

.top-right {
    right: 20px;
    /* Vertically align with the logo */
    top: 50%;
    transform: translateY(-50%);
}
/* ------------------------------------------- */


/* Button Styling (Shared) */
.highlight {
    background-color: var(--color-highlight);
    color: var(--color-white);
    cursor: pointer;
    border: none;
    transition: background-color 0.3s;
}

.highlight:hover:not(:disabled) {
    background-color: #9b4bd1;
}

/* Controls (Sorting and Search) */
.controls {
    display: flex;
    flex-direction: column; /* Stack controls on mobile */
    gap: 15px;
    margin: 20px auto;
    padding: 15px;
    background-color: var(--color-gray-light);
    border-radius: 8px;
    max-width: 1200px;
}

.sort-container, .search-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

label {
    font-weight: bold;
    white-space: nowrap;
    color: var(--color-text);
}

select, input[type="text"], button {
    padding: 10px;
    border: 1px solid var(--color-highlight);
    border-radius: 4px;
    background-color: var(--color-white);
    color: var(--color-text);
    flex-grow: 1;
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); /* Better mobile fit */
    gap: 20px;
    padding: 0 10px;
    max-width: 1200px;
    margin: 0 auto 30px;
}

.video-card {
    background-color: var(--color-gray-light);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Subtle shadow for white bg */
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.video-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 10px rgba(125, 27, 209, 0.2);
}

/* *** UPDATED: Style video element as thumbnail *** */
.video-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover; /* Ensures the video frame scales to fit without distortion */
    display: block;
    /* Purple fallback background */
    background-color: var(--color-highlight);
    background-image: linear-gradient(135deg, #7d1bd1 0%, #9b4bd1 100%);
    /* Prevent video controls from showing */
    pointer-events: none;
}

/* No video fallback state */
.video-thumbnail.no-video {
    background-color: var(--color-highlight);
    background-image: linear-gradient(135deg, #7d1bd1 0%, #9b4bd1 100%);
}

.video-info {
    padding: 15px;
}

.video-info h3 {
    color: var(--color-highlight);
    margin: 0 0 5px 0;
    font-size: 1.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-info p {
    margin: 0;
    font-size: 0.9em;
    color: var(--color-gray-dark);
}

/* Pagination Centering */
.pagination {
    display: flex;
    justify-content: center; /* Centered as requested */
    align-items: center;
    margin-top: 20px;
    gap: 15px;
    padding-bottom: 20px;
}

.pagination button {
    flex-grow: 0;
    width: auto;
    min-width: 80px;
}

.pagination span {
    font-weight: bold;
    white-space: nowrap;
    color: var(--color-text);
}

.pagination button:disabled {
    background-color: #ccc;
    color: #666;
    border-color: #ccc;
}

/* Media Query for larger screens */
@media (min-width: 768px) {
    .logo {
        height: 40px;
    }
    .controls {
        flex-direction: row; /* Controls side-by-side on desktop */
        max-width: 90%;
    }
    .sort-container {
        width: 40%;
    }
    .search-container {
        width: 60%;
    }
    .video-grid {
        grid-template-columns: repeat(4, 1fr); /* 4 columns on desktop */
        max-width: 90%;
    }
}