/* Variables para los colores */
:root {
    --background-color: #f0f2f5;
    --text-color: #333;
    --card-background: #fff;
    --header-footer-background: #fff;
    --menu-background: #e9ecef;
    --link-color: #007bff;
    --background-image-clear: url('https://w.forfun.com/fetch/51/51f8d93a74312061e38c92a2a7cf8f4b0.jpeg');
    --background-image-dark: none;
    --background-image-opacity: 0.1;
    --background-color-rgb: 240, 242, 245;
    --subtitle-color: #6c757d;
}

body.dark-mode {
    --background-color: #121212;
    --text-color: #e0e0e0;
    --card-background: #1e1e1e;
    --header-footer-background: #1e1e1e;
    --menu-background: #2c2c2c;
    --link-color: #1a73e8;
    --background-image-clear: none;
    --background-image-dark: url('https://fondosmil.com/fondo/18163.jpg');
    --background-color-rgb: 18, 18, 18;
    --subtitle-color: #a0a0a0;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0 2rem;
    background-size: cover;
    background-attachment: fixed;
    transition: background-color 0.5s, color 0.5s;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--background-image-clear);
    background-size: cover;
    background-attachment: fixed;
    opacity: var(--background-image-opacity);
    z-index: -1;
}

body.dark-mode::before {
    background-image: var(--background-image-dark);
}

header, main, footer {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 1;
}

header {
    background-color: var(--header-footer-background);
    color: var(--text-color);
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

header h1 {
    margin: 0;
    font-size: 2rem;
}

nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    border-top: 1px solid var(--menu-background);
    padding-top: 1rem;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    transition: background-color 0.3s;
    font-size: 1.1rem;
    font-weight: bold;
}

nav a:hover {
    background-color: var(--menu-background);
}

.search-and-toggle-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-container-header {
    display: flex;
    gap: 0.5rem;
}

#search-input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    background-color: var(--card-background);
    color: var(--text-color);
}

#search-input::placeholder {
    color: #888;
}

#search-button {
    background-color: var(--link-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

#search-button:hover {
    background-color: #0056b3;
}

#dark-mode-toggle {
    background-color: var(--card-background);
    color: var(--text-color);
    border: 1px solid var(--text-color);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}

#dark-mode-toggle:hover {
    background-color: var(--text-color);
    color: var(--card-background);
}

main {
    padding: 2rem 0;
    min-height: calc(100vh - 250px);
}

main.layout-3col {
    display: flex;
    gap: 20px;
}

.main-content-section {
    flex: 1;
}

.ad-container {
    flex: 0 0 200px;
    background-color: var(--card-background);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

#proximas-temporadas-section, #daily-menu-section, #search-results-section, #populares-section, #proximos-donghuas-section, .anime-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.anime-card {
    position: relative;
    background-color: var(--card-background);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.anime-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.anime-card img {
    width: 100%;
    height: 350px;
    object-fit: cover;
}

.anime-info {
    padding: 1rem;
}

.anime-info h3 {
    margin-top: 0;
    color: var(--text-color);
}

.anime-info h3 a {
    color: inherit;
    text-decoration: none;
}

.anime-info h3 a:hover {
    text-decoration: underline;
}

.card-link {
    display: block;
    text-decoration: none;
}


#loading-message, #loading-featured, #loading-crunchyroll, #status-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: var(--text-color);
}

footer {
    background-color: var(--header-footer-background);
    color: var(--text-color);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}

#menu-dia-link {
    background-color: #ffc107;
    color: #212529;
    font-weight: bold;
    border: 1px solid #e0a800;
}

#menu-dia-link:hover {
    background-color: #e0a800;
    color: #212529;
}

.star-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 10px;
}

.star-rating .star {
    width: 20px;
    height: 20px;
    fill: #ffc107;
}

.star-rating span {
    font-size: 0.9em;
    font-weight: bold;
    color: var(--text-color);
}

.sort-options {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--menu-background);
}

.sort-options span {
    font-weight: bold;
}

.sort-options button {
    border: 1px solid var(--link-color);
    background-color: transparent;
    color: var(--link-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: background-color 0.3s, color 0.3s;
}

.sort-options button:hover {
    background-color: var(--menu-background);
}

.sort-options button.active {
    background-color: var(--link-color);
    color: white;
}

.alphabet-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-bottom: 1.5rem;
    padding-top: 1rem;
}

.alphabet-container button {
    border: 1px solid #ccc;
    background-color: var(--card-background);
    color: var(--text-color);
    font-weight: bold;
    cursor: pointer;
    width: 35px;
    height: 35px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

.alphabet-container button:hover {
    background-color: var(--menu-background);
    border-color: var(--text-color);
}

.alphabet-container button.active {
    background-color: var(--link-color);
    color: white;
    border-color: var(--link-color);
}

/* --- Estilos para la Página de Detalles --- */
#detail-main {
    --banner-height: 175px;
}
.detail-banner {
    height: var(--banner-height);
    background-image: linear-gradient(to top, rgba(var(--background-color-rgb), 1) 0%, rgba(var(--background-color-rgb), 0.7) 40%, rgba(var(--background-color-rgb), 0.3) 100%), var(--banner-image);
    background-size: cover;
    background-position: center;
    margin: -2rem 0 0 0;
}
.detail-content {
    display: flex;
    gap: 2rem;
    padding: 0 2rem;
    margin-top: calc(-1 * var(--banner-height) / 2);
}
.detail-cover {
    width: 150px;
    height: 225px; /* Proporción 2:3 basada en el ancho */
    object-fit: cover;
    object-position: center top;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    flex-shrink: 0;
}
.detail-info {
    flex-grow: 1;
}
.detail-info h1 {
    margin-top: 0;
    font-size: 2.5em;
}
.detail-info .subtitle {
    margin-top: -1rem;
    font-size: 1.2em;
    color: var(--subtitle-color);
}
.detail-meta {
    display: flex;
    gap: 20px;
    margin: 1rem 0;
    font-size: 0.9em;
    color: var(--subtitle-color);
}
.detail-synopsis {
    line-height: 1.6;
}
.detail-trailer {
    margin-top: 2rem;
}
.detail-trailer iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
}

/* --- Estilos para la Paginación --- */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}
.pagination-container button {
    border: 1px solid var(--link-color);
    background-color: var(--card-background);
    color: var(--link-color);
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}
.pagination-container button:hover {
    background-color: var(--menu-background);
}
.pagination-container button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}
.pagination-container span {
    font-weight: bold;
}

/* ================================================================= */
/* NUEVA SECCIÓN: DISEÑO ADAPTABLE PARA MÓVILES (RESPONSIVE)        */
/* ================================================================= */
@media (max-width: 768px) {
    body {
        padding: 0 1rem;
    }

    header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-top-row {
        flex-direction: column;
        gap: 1rem;
    }

    nav {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
    
    nav a {
        width: 100%;
        text-align: center;
    }

    main.layout-3col {
        flex-direction: column;
    }

    .ad-container {
        display: none;
    }

    .detail-content {
        flex-direction: column;
        align-items: center;
        margin-top: -100px;
    }

    .detail-info h1 {
        font-size: 2em;
        text-align: center;
    }

    .detail-info .subtitle {
        text-align: center;
    }
}