* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --header-bg: rgba(255, 255, 255, 0.95);
    --header-text: #667eea;
    --card-bg: white;
    --card-text: #333;
    --card-info: #666;
    --modal-bg: white;
    --modal-text: #333;
    --episode-bg: #f5f5f5;
    --episode-hover: #667eea;
    --tab-bg: rgba(255, 255, 255, 0.9);
    --input-bg: white;
    --input-border: #667eea;
    --placeholder-bg: #f5f5f5;
    --placeholder-text: #999;
}

body[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --header-bg: rgba(30, 30, 46, 0.95);
    --header-text: #8b9cff;
    --card-bg: #2a2a3e;
    --card-text: #e0e0e0;
    --card-info: #b0b0b0;
    --modal-bg: #2a2a3e;
    --modal-text: #e0e0e0;
    --episode-bg: #1e1e2e;
    --episode-hover: #667eea;
    --tab-bg: rgba(30, 30, 46, 0.9);
    --input-bg: #1e1e2e;
    --input-border: #667eea;
    --placeholder-bg: #1e1e2e;
    --placeholder-text: #666;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--card-text);
    transition: background 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background: var(--header-bg);
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

header h1 {
    color: var(--header-text);
    text-align: left;
    flex: 1;
}

.theme-toggle {
    background: var(--episode-bg);
    border: 2px solid var(--input-border);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: var(--episode-hover);
    transform: scale(1.1);
}

.theme-icon {
    display: block;
}

.search-box {
    display: flex;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--input-border);
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    background: var(--input-bg);
    color: var(--card-text);
}

.search-box button {
    padding: 12px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 18px;
}

.search-box button:hover {
    background: #5568d3;
}

.tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: var(--tab-bg);
    flex-wrap: wrap;
}

.tab {
    padding: 12px 30px;
    background: var(--card-bg);
    border: 2px solid #667eea;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
    transition: all 0.3s;
}

.tab:hover {
    background: #f0f0f0;
}

.tab.active {
    background: #667eea;
    color: white;
}

.refresh-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.refresh-btn:hover {
    transform: scale(1.1) rotate(180deg);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.5);
}

.refresh-btn:active {
    transform: scale(0.95);
}

.loading {
    text-align: center;
    padding: 50px;
    font-size: 20px;
    color: white;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.card {
    background: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.3s;
}

.card:hover {
    transform: translateY(-5px);
}

.card-image {
    width: 100%;
    height: 350px;
    object-fit: cover;
    background: var(--placeholder-bg);
}

.card-body {
    padding: 15px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--card-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-info {
    font-size: 14px;
    color: var(--card-info);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 30px 0;
}

.pagination button {
    padding: 10px 20px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    color: #667eea;
}

.pagination button:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.modal-content {
    background: var(--modal-bg);
    margin: 30px auto;
    padding: 30px;
    border-radius: 15px;
    max-width: 1400px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    color: var(--modal-text);
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 35px;
    font-weight: bold;
    color: var(--card-info);
    cursor: pointer;
}

.close:hover {
    color: var(--card-text);
}

.modal-layout {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.video-section {
    flex: 2;
    min-width: 0;
}

.video-placeholder {
    background: var(--placeholder-bg);
    padding: 100px 20px;
    text-align: center;
    border-radius: 10px;
    color: var(--placeholder-text);
    font-size: 18px;
}

.episode-section {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
}

.episode-section h3 {
    color: var(--modal-text);
    font-size: 18px;
}

.episode-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

.episode-list::-webkit-scrollbar {
    width: 8px;
}

.episode-list::-webkit-scrollbar-track {
    background: var(--episode-bg);
    border-radius: 10px;
}

.episode-list::-webkit-scrollbar-thumb {
    background: var(--episode-hover);
    border-radius: 10px;
}

.episode-list::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.episode-card {
    background: var(--episode-bg);
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
    color: var(--modal-text);
}

.episode-card:hover {
    background: var(--episode-hover);
    color: white;
}

.episode-card.active {
    background: var(--episode-hover);
    color: white;
    border-color: #5568d3;
}

.video-player {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 500px;
    max-height: 70vh;
    border-radius: 10px;
    background: #000;
    object-fit: contain;
}

.video-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.video-controls h3 {
    margin: 0;
    flex: 1;
    min-width: 150px;
}

.video-controls-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 10;
}

.favorite-btn:hover {
    transform: scale(1.2);
}

.card {
    position: relative;
}

.nav-btn {
    background: var(--episode-bg);
    border: 2px solid var(--input-border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

.nav-btn:hover:not(:disabled) {
    background: var(--episode-hover);
    color: white;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.resume-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    animation: slideIn 0.3s ease;
}

.resume-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.resume-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.countdown-banner {
    background: #ff9800;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    animation: pulse 1s infinite;
}

.cancel-btn {
    background: white;
    color: #ff9800;
    border: none;
    padding: 6px 16px;
    border-radius: 15px;
    font-weight: 600;
    cursor: pointer;
}

.cancel-btn:hover {
    background: #f0f0f0;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.9;
    }
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    header {
        padding: 15px 0;
    }
    
    .header-content {
        flex-direction: row;
        gap: 10px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .search-box {
        flex-direction: row;
        max-width: 100%;
    }
    
    .search-box input {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .search-box button {
        padding: 10px 20px;
        font-size: 16px;
    }
    
    .tabs {
        padding: 15px 10px;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .tab {
        padding: 10px 20px;
        font-size: 14px;
        flex: 1;
        min-width: 120px;
        text-align: center;
    }
    
    .refresh-btn {
        padding: 10px 16px;
        font-size: 16px;
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
        padding: 15px 0;
    }
    
    .card-image {
        height: 220px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .card-title {
        font-size: 14px;
    }
    
    .card-info {
        font-size: 12px;
    }
    
    .favorite-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .modal-content {
        margin: 10px;
        padding: 20px;
        max-height: 95vh;
    }
    
    .modal-layout {
        flex-direction: column;
        gap: 15px;
    }
    
    .video-section {
        width: 100%;
    }
    
    .episode-section {
        max-width: 100%;
        min-width: 100%;
    }
    
    .episode-list {
        max-height: 250px;
    }
    
    .video-player {
        min-height: 250px;
        max-height: 50vh;
    }
    
    .nav-btn {
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .resume-banner {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 12px 15px;
    }
    
    .countdown-banner {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 10px 15px;
    }
    
    .pagination {
        padding: 20px 0;
        flex-wrap: wrap;
    }
    
    .pagination button {
        padding: 8px 16px;
        font-size: 14px;
    }
}

/* Tablet Optimization */
@media (min-width: 769px) and (max-width: 1024px) {
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 18px;
    }
    
    .card-image {
        height: 300px;
    }
    
    .modal-content {
        max-width: 95%;
    }
    
    .video-player {
        min-height: 400px;
    }
}

/* Large Desktop Optimization */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
    }
    
    .content-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .modal-content {
        max-width: 1600px;
    }
}
