@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
    --bg-color: #1a1a2e;
    --primary-color: #16213e;
    --secondary-color: #0f3460;
    --accent-color: #e94560;
    --text-color: #dcdcdc;
    --card-bg: #1e1e3f;
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

header {
    background-color: var(--primary-color);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

header h1 {
    color: var(--accent-color);
    font-size: 2.2rem; /* Slightly increased */
    cursor: pointer;
}

#search-form {
    display: flex;
}

#search-input {
    padding: 10px 15px;
    font-size: 1rem;
    border: none;
    border-radius: 20px 0 0 20px;
    background-color: var(--secondary-color);
    color: var(--text-color);
    outline: none;
    width: 250px; /* Adjusted for better responsiveness */
    max-width: 300px;
}

#search-form button {
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 0 20px 20px 0;
    background-color: var(--accent-color);
    color: white;
    cursor: pointer;
    font-weight: bold;
}

main {
    padding: 20px;
}

#search-results-container h2,
.anime-section h2 {
    font-size: 1.8rem;
    color: var(--accent-color);
    margin-bottom: 20px;
    padding-left: 10px;
    border-left: 5px solid var(--accent-color);
}

.anime-section {
    margin-bottom: 40px;
}

.anime-row {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 20px; /* For scrollbar */
}

/* Custom Scrollbar */
.anime-row::-webkit-scrollbar {
    height: 8px;
}
.anime-row::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 4px;
}
.anime-row::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

#results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Adjusted minmax */
    gap: 20px;
}

.anime-card {
    background-color: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease-in-out;
    cursor: pointer;
    flex-shrink: 0; /* Prevent cards from shrinking */
    width: 200px; /* Adjusted fixed width for horizontal scrolling */
    margin-right: 20px;
}


.anime-card:hover {
    transform: scale(1.05);
}

.anime-card img {
    width: 100%;
    height: 280px; /* Reduced height */
    object-fit: cover;
}

.anime-info {
    padding: 15px;
}

.anime-info h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.anime-info p {
    font-size: 0.9rem;
    color: #a0a0b0;
}

#loading {
    text-align: center;
    font-size: 1.5rem;
    padding: 40px;
}

/* Modal Styles */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#modal-content {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

#modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
}

.modal-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
}

.modal-grid img {
    width: 100%;
    border-radius: 10px;
}

.modal-info h2 {
    color: var(--accent-color);
    margin-bottom: 15px;
}

.modal-info .synopsis {
    margin: 20px 0;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 10px;
}

.modal-stats {
    display: flex;
    justify-content: space-around;
    background-color: var(--secondary-color);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.stat {
    text-align: center;
}

.stat span {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
}

.translate-button {
    background-color: #4CAF50; /* Green */
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 20px;
    transition: background-color 0.3s ease;
}

.translate-button:hover {
    background-color: #45a049;
}

/* Character Section Styles */
.modal-section-title { /* Added class for consistency */
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-top: 30px;
    margin-bottom: 15px;
    border-left: 5px solid var(--accent-color);
    padding-left: 10px;
}

.characters-row {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding-bottom: 10px;
    margin-bottom: 20px;
    /* Custom Scrollbar for characters-row */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--secondary-color);
}

.characters-row::-webkit-scrollbar {
    height: 8px;
}
.characters-row::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 4px;
}
.characters-row::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
}

.character-card {
    flex-shrink: 0;
    width: 110px; /* Reduced width */
    text-align: center;
    background-color: var(--secondary-color);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.character-card img {
    width: 65px; /* Reduced size */
    height: 65px; /* Reduced size */
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 5px;
    border: 2px solid var(--accent-color);
}

.character-card .character-name {
    font-size: 0.85rem; /* Slightly reduced */
    font-weight: bold;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.character-card .voice-actor {
    font-size: 0.75rem; /* Slightly reduced */
    color: #a0a0b0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.additional-info {
    margin-top: 20px;
    margin-bottom: 20px;
    background-color: var(--secondary-color);
    padding: 15px;
    border-radius: 8px;
}

.additional-info p {
    margin: 5px 0;
    font-size: 0.95rem;
    color: var(--text-color);
}

.additional-info strong {
    color: var(--accent-color);
}

/* YouTube Video Section Styles */
.youtube-videos-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 30px;
    padding-top: 10px;
    border-top: 1px solid var(--secondary-color);
}

.youtube-player-container {
    background-color: var(--secondary-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.youtube-player-container h4 {
    color: var(--accent-color);
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.youtube-player-container iframe {
    width: 100%;
    height: 180px; /* Adjust as needed */
    border-radius: 5px;
}

.youtube-player-container.no-video {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.youtube-player-container.no-video p {
    margin: 10px 0;
    text-align: center;
}

.youtube-player-container.no-video a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: bold;
}

.youtube-player-container.no-video a:hover {
    text-decoration: underline;
}


@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
    }
    #search-input {
        width: 100%;
        border-radius: 20px;
    }
    #search-form button {
        border-radius: 20px;
        margin-top: 10px;
        width: 100%;
    }
    #search-form {
        flex-direction: column;
        width: 100%;
    }
    .modal-grid {
        grid-template-columns: 1fr;
    }
    .modal-grid img {
        max-width: 250px;
        margin: 0 auto 20px;
    }
    .youtube-videos-section {
        grid-template-columns: 1fr;
    }
    .anime-card {
        width: 100%;
        margin-right: 0;
    }
    #results-grid {
        grid-template-columns: 1fr;
    }
    .news-list {
        grid-template-columns: 1fr;
    }
}