/* Base styles */
:root {
    --bg-color: #121212;
    --header-bg: #1a1a1a;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-color: #9c27b0;
    --accent-hover: #7b1fa2;
    --card-bg: #1e1e1e;
    --border-color: #333;
    --success-color: #4caf50;
    --error-color: #f44336;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    color: var(--text-color);
    text-decoration: none;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* Header */
header {
    background-color: var(--header-bg);
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent-color);
}

/* Search Box */
.search-container {
    display: flex;
    gap: 0.5rem;
}

.search-input {
    width: 250px;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    font-size: 0.9rem;
}

.search-button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-button:hover {
    background-color: var(--accent-hover);
}

/* Carousel Section */
.carousel-section {
    padding: 2rem 0;
}

.carousel-section h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

.anime-carousel {
    position: relative;
    height: 300px;
    overflow: hidden;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    background-color: var(--card-bg);
}

.carousel-item.active {
    opacity: 1;
    z-index: 10;
}

.carousel-poster {
    position: relative;
    height: 100%;
    overflow: hidden;
}

.carousel-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
}

.carousel-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.carousel-meta {
    margin-bottom: 0.5rem;
}

.carousel-rating {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    margin-right: 0.5rem;
    font-size: 0.9rem;
    color: var(--accent-color);
}

.carousel-synopsis {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Anime List */
.anime-list {
    padding: 3rem 0;
}

.anime-list h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

.anime-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for mobile by default */
    gap: 1.5rem;
}

.anime-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.anime-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.anime-poster {
    height: 0;
    padding-bottom: 140%; /* Maintain aspect ratio for poster */
    position: relative;
    overflow: hidden;
}

.anime-poster img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.anime-info-card {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.anime-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.anime-synopsis-short {
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    margin-bottom: auto;
}

.loading, .no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Admin Panel */
.admin-panel {
    padding: 3rem 0;
}

.admin-panel h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.admin-tabs {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.tab-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.tab-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-button.active, .tab-button:hover {
    color: var(--accent-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-content h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Login Form */
.login-form {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    margin: 0 auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.button-secondary {
    background-color: #555;
}

.button-secondary:hover {
    background-color: #444;
}

/* Edit Forms */
.poster-preview {
    margin-top: 1rem;
    max-width: 300px;
}

.poster-preview img {
    width: 100%;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.episodes-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 1rem;
}

.episode-edit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    gap: 1rem;
}

.episode-edit-number {
    font-weight: bold;
    color: var(--accent-color);
    min-width: 60px;
}

.episode-edit-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.edit-button:hover {
    background-color: var(--accent-hover);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

input, textarea, select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-size: 1rem;
}

textarea {
    resize: vertical;
}

small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.button:hover {
    background-color: var(--accent-hover);
}

.button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.message-success {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.message-error {
    background-color: rgba(244, 67, 54, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* Anime Details Page */
.anime-details {
    padding: 2rem 0;
}

.anime-details-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.anime-poster-large img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.anime-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.anime-info h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.anime-synopsis-full {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.episodes-section {
    margin-top: 3rem;
}

.episodes-section h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

.episodes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.episode-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
}

.episode-card:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.episode-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    min-width: 30px;
    text-align: center;
}

.episode-info {
    flex: 1;
}

.episode-title {
    font-size: 1rem;
    font-weight: 500;
}

/* Episode Player Page */
.episode-player {
    padding: 2rem 0;
}

.episode-player h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.episode-info-header {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.episode-number-large {
    font-size: 1.1rem;
    color: var(--accent-color);
}

.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.episode-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

.nav-button {
    padding: 0.5rem 1rem;
    background-color: var(--card-bg);
    border-radius: 4px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-button:hover {
    background-color: var(--accent-color);
}

.nav-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Episode Tabs */
.episode-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 2rem 0;
    justify-content: center;
}

.episode-tab {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 40px;
    height: 40px;
    background-color: var(--card-bg);
    border-radius: 4px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s;
    padding: 0 0.75rem;
    font-weight: 500;
}

.episode-tab:hover {
    background-color: var(--accent-hover);
}

.episode-tab.active {
    background-color: var(--accent-color);
}

/* Footer */
footer {
    background-color: var(--header-bg);
    padding: 2rem 0;
    text-align: center;
    margin-top: 3rem;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (min-width: 576px) {
    .anime-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns for small tablets */
    }
}

@media (min-width: 768px) {
    .anime-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns for tablets */
    }
    
    /* Make anime details side by side on larger screens */
    .anime-details-container {
        grid-template-columns: 300px 1fr;
    }
    
    .anime-info h1 {
        font-size: 2rem;
    }
    
    .episode-player h1 {
        font-size: 1.8rem;
    }
    
    .anime-list h2, .ranking-list h2 {
        font-size: 1.8rem;
    }
}

@media (min-width: 992px) {
    .anime-grid {
        grid-template-columns: repeat(4, 1fr); /* 4 columns for desktops */
    }
    
    .anime-carousel {
        height: 400px;
    }
}

@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-container {
        width: 100%;
    }
    
    .search-input {
        width: 100%;
    }
    
    /* Reduced font sizes for mobile */
    .anime-title, .carousel-title {
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 1.3rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    .episode-number-large {
        font-size: 0.9rem;
    }
    
    /* Make sure anime details stack vertically on mobile */
    .anime-details-container {
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .search-container {
        flex-direction: column;
    }
    
    .search-button {
        width: 100%;
    }
    
    /* Further reduce title size for very small screens */
    .anime-title {
        font-size: 0.9rem;
    }
}

/* New section for rankings */
.ranking-list {
    padding: 2rem 0;
}

.ranking-list h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
}

.ranking-number {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: var(--accent-color);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 1;
}

/* Delete buttons for admin */
.delete-button {
    background-color: var(--error-color);
    color: white;
    border: none;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
    margin-left: 0.5rem;
}

.delete-button:hover {
    background-color: #d32f2f;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Confirmation modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
}

.modal h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.modal-confirm {
    background-color: var(--error-color);
}

.modal-cancel {
    background-color: var(--border-color);
}

/* Episode badge on anime poster */
.episode-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 2;
}

.anime-poster {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 150%; /* 2:3 aspect ratio */
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
