/* General layout */
body {
    font-family: 'Noto Sans JP', Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: #212121;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #fff176;
    background-image: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 50%), linear-gradient(to top, rgba(211, 47, 47, 0.3) 0%, rgba(211, 47, 47, 0) 20%);
    background-attachment: fixed;
    background-position: center center;
    background-repeat: no-repeat;
}

body.dark-mode {
    color: #e0e0e0;
    background: #1c0b2b;
    background-image: radial-gradient(circle at center, rgba(0, 255, 255, 0.2) 0%, rgba(0, 255, 255, 0) 50%), linear-gradient(to top, rgba(239, 83, 80, 0.3) 0%, rgba(239, 83, 80, 0) 20%);
    background-attachment: fixed;
    background-position: center center;
    background-repeat: no-repeat;
}

/* Header */
header {
    padding: 1.5rem 0;
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
    width: 100%;
    max-width: 1200px;
}

body.dark-mode header {
    border-bottom: 1px solid #424242;
}

.header-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    width: 80px;
    height: 80px;
    border-radius: 8px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #212121;
    margin: 0;
}

body.dark-mode h1 {
    color: #e0e0e0;
}

.dark-mode-toggle {
    font-size: 0.9rem;
    padding: 8px 16px;
}

body.dark-mode .dark-mode-toggle {
    background-color: #424242;
    border-color: #e0e0e0;
}

body.dark-mode .dark-mode-toggle:hover {
    background-color: #616161;
}

/* Main content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Search bar and buttons */
.input-group {
    max-width: 700px;
    margin: 0 auto 2.5rem;
    width: 100%;
}

.input-group .form-control {
    border: 2px solid #212121;
    border-radius: 25px 0 0 25px;
    padding: 10px 15px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-group .form-control:focus {
    border-color: #d32f2f;
    box-shadow: 0 0 6px rgba(211, 47, 47, 0.4);
}

body.dark-mode .input-group .form-control {
    border-color: #424242;
    background-color: #212121;
    color: #e0e0e0;
}

body.dark-mode .input-group .form-control:focus {
    border-color: #ef5350;
    box-shadow: 0 0 6px rgba(239, 83, 80, 0.4);
}

.input-group-text {
    background-color: #212121;
    color: #ffffff;
    border: 2px solid #212121;
    border-right: none;
    border-radius: 25px 0 0 25px;
}

body.dark-mode .input-group-text {
    background-color: #424242;
    border-color: #424242;
}

.btn-primary {
    background-color: #d32f2f;
    border: 2px solid #212121;
    border-radius: 0;
    padding: 10px 20px;
    font-weight: 700;
    transition: background-color 0.3s, transform 0.2s;
}

.btn-primary:hover {
    background-color: #b71c1c;
    transform: translateY(-2px);
}

body.dark-mode .btn-primary {
    background-color: #ef5350;
    border-color: #424242;
}

body.dark-mode .btn-primary:hover {
    background-color: #e53935;
}

.btn-success {
    background-color: #388e3c;
    border: 2px solid #212121;
    border-radius: 12px;
    font-weight: 700;
    transition: background-color 0.3s, transform 0.2s;
}

.btn-success:hover {
    background-color: #2e7d32;
    transform: translateY(-2px);
}

body.dark-mode .btn-success {
    background-color: #43a047;
    border-color: #424242;
}

body.dark-mode .btn-success:hover {
    background-color: #388e3c;
}

.btn-danger {
    background-color: #d32f2f;
    border: 2px solid #212121;
    border-radius: 12px;
    font-weight: 700;
    transition: background-color 0.3s, transform 0.2s;
}

.btn-danger:hover {
    background-color: #b71c1c;
    transform: translateY(-2px);
}

body.dark-mode .btn-danger {
    background-color: #ef5350;
    border-color: #424242;
}

body.dark-mode .btn-danger:hover {
    background-color: #e53935;
}

.btn-secondary {
    background-color: #616161;
    border: 2px solid #212121;
    border-radius: 0 25px 25px 0;
    padding: 10px 20px;
    font-weight: 700;
    transition: background-color 0.3s, transform 0.2s;
}

body.dark-mode .btn-secondary {
    background-color: #757575;
    border-color: #424242;
}

body.dark-mode .btn-secondary:hover {
    background-color: #616161;
}

/* Suggestions dropdown */
#suggestions {
    max-height: 400px;
    overflow-y: auto;
    background-color: #ffffff;
    border: 2px solid #212121;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

body.dark-mode #suggestions {
    background-color: #212121;
    border-color: #424242;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

#suggestions .list-group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

body.dark-mode #suggestions .list-group-item {
    border-bottom: 1px solid #424242;
}

#suggestions .list-group-item:hover {
    background-color: #f5f5f5;
}

body.dark-mode #suggestions .list-group-item:hover {
    background-color: #424242;
}

#suggestions .suggestion-img {
    width: 48px;
    height: 72px;
    object-fit: cover;
    border: 1px solid #212121;
    border-radius: 4px;
}

body.dark-mode #suggestions .suggestion-img {
    border-color: #424242;
}

#suggestions .blacklist-btn {
    margin-left: auto;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 8px;
}

/* Blacklist modal */
#blacklist .list-group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
}

body.dark-mode #blacklist .list-group-item {
    border-bottom: 1px solid #424242;
}

#blacklist .blacklist-img {
    width: 48px;
    height: 72px;
    object-fit: cover;
    border: 1px solid #212121;
    border-radius: 4px;
}

body.dark-mode #blacklist .blacklist-img {
    border-color: #424242;
}

#blacklist .remove-blacklist-btn {
    margin-left: auto;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 8px;
}

/* Loading indicator */
#loading {
    color: #616161;
    font-style: italic;
    font-size: 0.95rem;
    text-align: center;
    max-width: 700px;
    margin: 0 auto;
}

body.dark-mode #loading {
    color: #9e9e9e;
}

/* Series gallery */
#seriesGallery {
    --card-width: 280px;
    --card-height: 392px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

#seriesGallery .row {
    row-gap: 2rem;
    --bs-gutter-x: 0.75rem; /* Reduced gap for 5 columns */
    display: flex;
    justify-content: center;
}

#seriesGallery .col {
    flex: 0 0 calc(20% - 0.6rem); /* 5 columns, accounting for gap */
    max-width: calc(20% - 0.6rem);
    animation: fadeIn 0.5s ease-in-out;
}

#seriesGallery .card {
    background-color: #ffffff;
    border: 2px solid #212121;
    border-radius: 12px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    width: 100%;
    height: var(--card-height);
    display: flex;
    flex-direction: column;
}

body.dark-mode #seriesGallery .card {
    background-color: #212121;
    border-color: #424242;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

#seriesGallery .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode #seriesGallery .card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6);
}

#seriesGallery .card-img-container {
    height: calc(var(--card-height) * 0.8); /* 80% for image */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border-bottom: 2px solid #212121;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

body.dark-mode #seriesGallery .card-img-container {
    background-color: #212121;
    border-bottom: 2px solid #424242;
}

#seriesGallery .card-img-top {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#seriesGallery .card-body {
    padding: 0.5rem;
    text-align: center;
    flex: 0 0 auto; /* Fixed height for title area */
    height: calc(var(--card-height) * 0.2); /* 20% for title */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.dark-mode #seriesGallery .card-body {
    color: #e0e0e0;
}

#seriesGallery .card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #212121;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.dark-mode #seriesGallery .card-title {
    color: #e0e0e0;
}

#seriesGallery .card-text {
    font-size: 0.85rem;
    color: #616161;
    margin: 0;
}

body.dark-mode #seriesGallery .card-text {
    color: #9e9e9e;
}

/* Volume modal */
.manga-modal {
    border: 2px solid #212121;
    border-radius: 12px;
    background-color: #ffffff;
}

body.dark-mode .manga-modal {
    border-color: #424242;
    background-color: #212121;
    color: #e0e0e0;
}

.modal-dialog {
    max-width: 600px;
    margin: 1.75rem auto;
}

#volumeList .list-group-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
}

body.dark-mode #volumeList .list-group-item {
    border-bottom: 1px solid #424242;
}

#volumeList input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #d32f2f;
}

body.dark-mode #volumeList input[type="checkbox"] {
    accent-color: #ef5350;
}

#seriesInfo {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    color: #212121;
}

body.dark-mode #seriesInfo {
    color: #e0e0e0;
}

/* Stats display */
#stats {
    font-size: 1rem;
    color: #212121;
    background-color: #ffffff;
    border: 2px solid #d32f2f;
    border-radius: 12px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    padding: 1rem;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    white-space: nowrap;
    max-width: 1200px;
    margin: 0 auto 2rem;
    width: 100%;
}

body.dark-mode #stats {
    color: #e0e0e0;
    background-color: #212121;
    border-color: #ef5350;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

#stats i {
    margin-right: 0.5rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive tweaks */
@media (max-width: 768px) {
    .logo {
        width: 64px;
        height: 64px;
    }
    h1 {
        font-size: 2rem;
    }
    .input-group {
        max-width: 500px;
    }
    #suggestions {
        max-width: 500px;
    }
    #seriesGallery {
        --card-width: 220px;
        --card-height: 308px;
    }
    #seriesGallery .col {
        flex: 0 0 calc(20% - 0.6rem);
        max-width: calc(20% - 0.6rem);
    }
    #stats {
        font-size: 0.95rem;
        gap: 1rem;
        padding: 0.75rem;
    }
}

@media (max-width: 576px) {
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }
    .logo {
        width: 48px;
        height: 48px;
    }
    h1 {
        font-size: 1.8rem;
    }
    .dark-mode-toggle {
        font-size: 0.85rem;
        padding: 6px 12px;
    }
    .input-group .form-control {
        font-size: 0.9rem;
        padding: 8px;
    }
    .btn {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    #suggestions .list-group-item {
        font-size: 0.85rem;
        padding: 8px;
    }
    #suggestions .suggestion-img {
        width: 40px;
        height: 60px;
    }
    #suggestions .blacklist-btn {
        font-size: 0.75rem;
        padding: 3px 6px;
    }
    #blacklist .list-group-item {
        font-size: 0.85rem;
        padding: 8px;
    }
    #blacklist .blacklist-img {
        width: 40px;
        height: 60px;
    }
    #blacklist .remove-blacklist-btn {
        font-size: 0.75rem;
        padding: 3px 6px;
    }
    #seriesGallery {
        --card-width: 180px;
        --card-height: 252px;
    }
    #seriesGallery .col {
        flex: 0 0 calc(20% - 0.6rem);
        max-width: calc(20% - 0.6rem);
    }
    #seriesGallery .card-title {
        font-size: 0.9rem;
    }
    #seriesGallery .card-text {
        font-size: 0.8rem;
    }
    #volumeList .list-group-item {
        font-size: 0.85rem;
        padding: 8px;
    }
    #stats {
        font-size: 0.85rem;
        gap: 0.75rem;
        padding: 0.5rem;
    }
}