* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: white;
    --bg-tertiary: #f8f9fa;
    --text-primary: #333;
    --text-secondary: #7f8c8d;
    --text-muted: #95a5a6;
    --border-color: #e1e8ed;
    --border-input: #d5dbdb;
    --shadow-color: rgba(0,0,0,0.08);
    --shadow-hover: rgba(0,0,0,0.12);
    --accent-color: #2d8628;
    --button-primary: #27ae60;
    --button-primary-hover: #229954;
    --modal-bg: rgba(0, 0, 0, 0.85);
    --close-btn-bg: rgba(255, 255, 255, 0.9);
    --close-btn-hover: #ffffff;
    --placeholder-bg: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
                      linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
                      linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #404040;
    --border-input: #505050;
    --shadow-color: rgba(0,0,0,0.3);
    --shadow-hover: rgba(0,0,0,0.4);
    --accent-color: #4caf50;
    --button-primary: #4caf50;
    --button-primary-hover: #45a049;
    --modal-bg: rgba(0, 0, 0, 0.9);
    --close-btn-bg: rgba(45, 45, 45, 0.9);
    --close-btn-hover: #2d2d2d;
    --placeholder-bg: linear-gradient(45deg, #404040 25%, transparent 25%),
                      linear-gradient(-45deg, #404040 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #404040 75%),
                      linear-gradient(-45deg, transparent 75%, #404040 75%);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: 999;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 20px var(--shadow-hover);
}

.theme-toggle i {
    transition: transform 0.3s ease;
}

.theme-toggle:hover i {
    transform: rotate(180deg);
}

.header {
    text-align: center;
    margin-bottom: 30px;
}
.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: var(--accent-color);
    font-weight: 600;
}
.header p {
    font-size: 1.1em;
    color: var(--text-secondary);
}
.controls {
    max-width: 1600px;
    margin: 0 auto 30px auto;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}
.search-bar {
    position: relative;
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}
.search-input {
    width: 100%;
    padding: 12px 50px 12px 20px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1em;
    outline: none;
    transition: border-color 0.2s ease;
}
.search-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1em;
}
.sort-dropdown {
    position: relative;
}
.sort-select {
    padding: 12px 40px 12px 15px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1em;
    cursor: pointer;
    outline: none;
    appearance: none;
    transition: border-color 0.2s ease;
    background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23666' d='M2 0L0 2h4zm0 5L0 3h4z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
}
.sort-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}
/* Enhanced Responsive Grid */
.gallery {
    display: grid;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
    grid-template-columns: repeat(8, 1fr);
}
.video-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all 0.2s ease;
}
.video-card:hover {
    box-shadow: 0 4px 16px var(--shadow-hover);
    transform: translateY(-2px);
}
.thumbnail {
    width: 100%;
    height: 140px;
    position: relative;
    overflow: hidden;
    background: var(--bg-tertiary);
}
.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(4px);
    transition: filter 0.3s ease;
}
.thumbnail img.loaded {
    filter: blur(0px);
}
.video-card:hover .thumbnail img.loaded {
    filter: blur(0px);
}
.thumbnail .placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--placeholder-bg);
    background-size: 15px 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 24px;
}
.play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.play-overlay:hover {
    background: rgba(0,0,0,0.9);
    transform: translate(-50%, -50%) scale(1.1);
}
.card-content {
    padding: 12px;
}
.video-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.6em;
}
.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.75em;
}
.quality-badge {
    background: #3498db;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}
.file-size {
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 3px;
}
.download-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.7em;
    color: var(--text-muted);
}
.stat {
    display: flex;
    align-items: center;
    gap: 3px;
}
.download-button {
    width: 100%;
    background: var(--button-primary);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}
.download-button:hover {
    background: var(--button-primary-hover);
    transform: translateY(-1px);
}
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 40px auto;
    flex-wrap: wrap;
}
.pagination button {
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
}
.pagination button:hover:not(:disabled) {
    background: #3498db;
    color: white;
    border-color: #3498db;
}
.pagination button:disabled {
    background: #3498db;
    color: white;
    border-color: #3498db;
    cursor: not-allowed;
}
.pagination .page-info {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
}
.loading {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.2em;
    margin: 100px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}
.loading i {
    font-size: 2em;
    animation: spin 2s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.empty-gallery {
    text-align: center;
    color: var(--text-secondary);
    margin: 100px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.empty-gallery i {
    font-size: 4em;
    color: var(--text-muted);
}
.empty-gallery h2 {
    font-size: 1.8em;
    margin-bottom: 10px;
    color: var(--accent-color);
}
.expiry-warning {
    color: #e74c3c;
    font-size: 0.7em;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
}
/* Handle landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 90vh;
    }

    .modal video {
        max-height: 80vh;
    }
}

/* Responsive Breakpoints */
/* Extra Large Screens (1600px+) - 8 items per row */
@media (min-width: 1600px) {
    .gallery {
        grid-template-columns: repeat(8, 1fr);
        gap: 18px;
    }
    .thumbnail {
        height: 160px;
    }
    .card-content {
        padding: 15px;
    }
}
/* Large Screens (1200px - 1599px) - 6 items per row */
@media (max-width: 1599px) and (min-width: 1200px) {
    .gallery {
        grid-template-columns: repeat(6, 1fr);
        gap: 18px;
    }
    .thumbnail {
        height: 150px;
    }
}
/* Medium-Large Screens (900px - 1199px) - 5 items per row */
@media (max-width: 1199px) and (min-width: 900px) {
    .gallery {
        grid-template-columns: repeat(5, 1fr);
        gap: 16px;
    }
    .thumbnail {
        height: 140px;
    }
}
/* Medium Screens (768px - 899px) - 4 items per row */
@media (max-width: 899px) and (min-width: 768px) {
    .gallery {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
    .thumbnail {
        height: 130px;
    }
    .card-content {
        padding: 10px;
    }
    .video-title {
        font-size: 0.85em;
    }
}
/* Small Screens (480px - 767px) - 3 items per row */
@media (max-width: 767px) and (min-width: 480px) {
    body {
        padding: 15px;
    }
    .controls {
        flex-direction: column;
    }
    .search-bar {
        min-width: 100%;
    }
    .gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    .thumbnail {
        height: 120px;
    }
    .card-content {
        padding: 8px;
    }
    .video-title {
        font-size: 0.8em;
        margin-bottom: 6px;
    }
    .video-meta {
        font-size: 0.7em;
        margin-bottom: 8px;
    }
    .download-stats {
        font-size: 0.65em;
        margin-bottom: 8px;
    }
    .download-button {
        font-size: 0.75em;
        padding: 6px;
    }
    .header h1 {
        font-size: 2em;
    }
}
/* Extra Small Screens (below 480px) - 2 items per row */
@media (max-width: 479px) {
    body {
        padding: 10px;
    }
    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .thumbnail {
        height: 100px;
    }
    .card-content {
        padding: 6px;
    }
    .video-title {
        font-size: 0.75em;
        margin-bottom: 4px;
    }
    .video-meta {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
        font-size: 0.65em;
        margin-bottom: 6px;
    }
    .download-stats {
        flex-direction: column;
        gap: 2px;
        align-items: flex-start;
        font-size: 0.6em;
        margin-bottom: 6px;
    }
    .download-button {
        font-size: 0.7em;
        padding: 5px;
    }
    .header h1 {
        font-size: 1.8em;
    }
    .header p {
        font-size: 1em;
    }
}
.site-footer {
    width: 100%;
    background: #333;
    color: white;
    padding: 20px 0;
    text-align: center;
    font-size: 14px;
    margin: 0;
    border: none;
}

.site-footer p {
    margin: 0;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-footer i {
    color: #ffa500;
    margin-right: 8px;
}

@media (max-width: 768px) {
    .site-footer {
        font-size: 13px;
        padding: 15px 0;
    }
}
