/* --- Global Styles & Variables --- */
:root {
    --bg-dark: #181A1B;
    --bg-secondary: #212529;
    --text-light: #f0f0f0;
    --text-muted: #888;
    --accent-blue: #007bff;
    --accent-green: #28a745;
    --accent-orange: #fd7e14;
    --border-color: #343a40;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-size: 14px;
}

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

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

.container {
    width: 95%;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Header --- */
header {
    background-color: var(--bg-secondary);
    padding: 10px 2%;
    border-bottom: 1px solid var(--border-color);
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.top-nav-left .btn {
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-weight: bold;
    margin-right: 5px;
    font-size: 0.9em;
}
.btn-green { background-color: var(--accent-green); }
.btn-blue { background-color: var(--accent-blue); }
.btn-orange { background-color: var(--accent-orange); }
.btn i { margin-right: 5px; }

.logo {
    font-size: 2.2em;
    font-weight: bold;
    color: white;
}
.logo::after {
    content: ".co";
    color: var(--accent-blue);
}

.search-form {
    display: flex;
}
.search-form input {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 8px 10px;
    border-radius: 5px 0 0 5px;
    outline: none;
}
.search-form button {
    background-color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    color: white;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 0 5px 5px 0;
}

.secondary-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 15px;
}
.secondary-nav a {
    background-color: var(--bg-dark);
    color: var(--text-light);
    padding: 8px 15px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s;
}
.secondary-nav a:hover {
    background-color: var(--accent-blue);
}

/* --- Main Content --- */
main {
    padding: 20px 2%;
    padding-bottom: 80px; /* Space for mobile nav */
}

/* MODIFIED: Updated .content-section h2 for flexbox layout */
.content-section h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--accent-blue);
    padding-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.content-section h2 i {
    margin-right: 10px;
}

/* NEW: Style for the "View All" button */
.btn-view-all {
    font-size: 0.6em; /* Makes the button text smaller than the title */
    font-weight: normal;
    color: var(--text-light);
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 5px;
    transition: background-color 0.2s;
}
.btn-view-all:hover {
    background-color: var(--accent-blue);
    color: white;
}


.comic-grid {
    display: grid;
    /* By increasing the minimum width from 150px to 170px, fewer cards will fit per row. */
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 20px;
}

.comic-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}
.comic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.2);
}
.comic-card .poster-container {
    position: relative;
}
.comic-card .poster-container img {
    width: 100%;
    display: block;
    aspect-ratio: 3 / 4;
    object-fit: cover;
}
.comic-card .type-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: var(--accent-blue);
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
}
.comic-card .chapter-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 20px 10px 10px 10px;
    font-size: 0.9em;
}
.comic-card-details {
    padding: 10px;
}
.comic-card-details .title {
    font-size: 1.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
  	color:white;
}
.comic-card-details .latest-chapter {
    font-size: 0.9em;
    color: #007bff;
}

.info-center {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--accent-orange);
    padding: 20px;
    margin: 30px 0;
    border-radius: 5px;
}
.info-center h3 {
    margin-bottom: 10px;
}
.info-center p {
    line-height: 1.6;
    color: var(--text-muted);
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9em;
}

/* --- Mobile Navigation --- */
.mobile-nav {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
}
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding: 8px 0;
    color: var(--text-muted);
    transition: color 0.2s;
}
.mobile-nav-item i {
    font-size: 1.4em;
    margin-bottom: 4px;
}
.mobile-nav-item span {
    font-size: 0.7em;
}
.mobile-nav-item.active,
.mobile-nav-item:hover {
    color: var(--accent-blue);
}

/* --- Single Comic Page Styles --- */
.single-container {
    background-color: var(--bg-secondary);
    padding: 20px;
    border-radius: 5px;
}
.comic-title {
    font-size: 2em;
    margin-bottom: 20px;
}
.comic-main-info {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}
.comic-poster {
    flex-basis: 200px;
    flex-grow: 1;
}
.comic-poster img {
    border-radius: 5px;
    width: 100%;
}
.comic-details {
    flex-basis: 300px;
    flex-grow: 999; /* Grow more than poster */
}
.metadata-table {
    width: 100%;
    border-spacing: 0 5px;
    font-size: 0.9em;
}
.metadata-table td:first-child {
    font-weight: bold;
    width: 100px;
}
.genres-container {
    margin-top: 15px;
}
.genre-tag {
    display: inline-block;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 20px;
    margin: 5px 5px 0 0;
    font-size: 0.85em;
    color: var(--text-light);
}
.comic-synopsis {
    margin-bottom: 30px;
}
.comic-synopsis h3, .chapter-list-container h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--accent-blue);
    padding-bottom: 5px;
}
.comic-synopsis p {
    line-height: 1.7;
    color: var(--text-muted);
}
.chapter-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
}
.chapter-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}
.chapter-item:last-child {
    border-bottom: none;
}
.chapter-item a {
    font-weight: bold;
}
.chapter-date {
    color: var(--text-muted);
    font-size: 0.9em;
}
.loading-container, .error-message {
    text-align: center;
    font-size: 1.2em;
    padding: 50px;
}

/* --- Chapter Page Styles --- */
.chapter-header, .chapter-footer {
    background-color: var(--bg-secondary);
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}
.chapter-footer {
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    margin-top: 20px;
}
.chapter-header h1 {
    font-size: 1.5em;
    margin-bottom: 15px;
}
.chapter-nav .btn {
    margin: 0 5px;
    padding: 10px 20px;
}
.btn.disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.6;
}
.chapter-content {
    text-align: center;
}
.comic-page {
    max-width: 100%;
    display: block;
    margin: 0 auto;
}

.chapter-bottom-nav {
    text-align: center;
    padding: 25px 0 15px 0;
    margin-top: 20px;
    border-top: 2px solid var(--border-color);
}
.chapter-bottom-nav .btn {
    margin: 0 5px;
}
.flag-badge {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 24px;  /* Set a specific width for the flag image */
    height: auto; /* Maintain aspect ratio */
  	padding: 0px 4px;
    background-color: #333; /* Optional: adds a dark background */
    border-radius: 3px; /* Optional: rounds the corners */
    box-shadow: 0 0 4px rgba(0,0,0,0.5); /* Optional: adds a shadow */
  	color: white;
}

/* --- Pagination Styles --- */
.pagination-container {
    text-align: center;
    margin-top: 30px;
}
.pagination-container .btn {
    margin: 0 5px;
    padding: 10px 20px;
    font-weight: bold;
    border-radius: 5px;
    display: inline-block;
  	color: white;
}
.pagination-container .btn.disabled {
    background-color: #555;
    cursor: not-allowed;
    opacity: 0.6;
}

/* --- Star Rating Styles --- */
.comic-card-details .rating-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
    height: 16px; /* Give a fixed height to prevent layout shifts */
}

.star-rating {
    font-size: 14px;
    color: #ffb400; /* Gold color for filled stars */
}

.star-rating i {
    margin-right: 1px;
}

.star-rating .fa-regular.fa-star {
    color: var(--border-color); /* Color for empty stars */
}

.chapter-item a.read {
    color: #888; /* Muted grey color */
    font-style: italic;
}

.chapter-item a.read::after {
    content: " (read)";
    color: #555;
    font-size: 0.9em;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .top-nav {
        flex-direction: column;
    }
    .top-nav-left, .top-nav-right {
        order: 2;
    }
    .logo-container {
        order: 1;
        margin-bottom: 10px;
    }
    .secondary-nav {
        font-size: 0.9em;
    }
    .mobile-nav {
        display: flex;
    }
}

@media (max-width: 480px) {
    .comic-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    .top-nav-left {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    .top-nav-left .btn {
       margin-bottom: 5px;
    }
    .secondary-nav a {
        padding: 6px 10px;
        font-size: 0.8em;
    }
}