@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-color: #0d1117;
    --surface: #161b22;
    --surface-hover: #21262d;
    --primary: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --text-main: #f0f6fc;
    --text-muted: #8b949e;
    --border: #30363d;
    --glass-bg: rgba(22, 27, 34, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

h1, h2, h3, h4, .brand-logo {
    font-family: 'Outfit', sans-serif;
}

/* Navbar */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    height: 70px;
}

.brand-logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    text-decoration: none;
}

.search-container {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.3rem 1rem;
    transition: all 0.3s ease;
}

.search-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.search-container input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    padding: 0.5rem;
    width: 250px;
    font-family: 'Inter', sans-serif;
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}

.search-btn:hover {
    color: var(--primary);
}

/* Nav Tabs */
.nav-tabs {
    display: flex;
    gap: 0.4rem;
}

.nav-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

.nav-tab.active, .nav-tab:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Read sources grid */
.read-sources {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.read-source-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.9rem;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.read-source-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59,130,246,0.3);
}

/* Reader iframe */
#reader-iframe-container {
    width: 100%;
    height: calc(100vh - 130px);
    border: none;
}

#reader-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Main Container */
main {
    margin-top: 90px;
    padding: 0 5%;
    min-height: calc(100vh - 90px);
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Section Header */
.section-header {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-main);
    position: relative;
    display: inline-block;
}

.section-header::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

/* Grid Layout */
.manga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

/* Manga Card */
.manga-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
    position: relative;
}

.manga-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 0 15px rgba(59, 130, 246, 0.2);
}

.manga-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background-color: var(--surface-hover);
}

.manga-info {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

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

.manga-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto;
    text-transform: capitalize;
}

/* Detail View */
.detail-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    background: var(--surface);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.detail-cover {
    width: 250px;
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.detail-info {
    flex-grow: 1;
}

.detail-title {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}

.detail-author {
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 1rem;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tag {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.detail-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

/* Chapter List */
.chapter-list-container {
    background: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.chapter-list {
    list-style: none;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom Scrollbar */
.chapter-list::-webkit-scrollbar {
    width: 6px;
}
.chapter-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 10px;
}
.chapter-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.chapter-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
    cursor: pointer;
}

.chapter-item:hover {
    background: var(--surface-hover);
}

.chapter-item:last-child {
    border-bottom: none;
}

.chapter-title {
    font-weight: 500;
    color: var(--text-main);
}

.chapter-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Reader View */
#reader-view {
    max-width: 800px;
    margin: 0 auto;
    background: #000;
    min-height: 100vh;
}

.reader-header {
    position: sticky;
    top: 70px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 90;
    border-bottom: 1px solid var(--glass-border);
}

.reader-title {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.reader-controls {
    display: flex;
    gap: 1rem;
}

.btn {
    background: var(--surface-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn.primary {
    background: var(--primary-gradient);
    border: none;
}

.reader-images {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 4rem;
}

.reader-images img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 0px; /* Seamless reading */
}

/* Loading Spinner */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error/Empty State */
.message-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .detail-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .detail-tags {
        justify-content: center;
    }

    .search-container input {
        width: 150px;
    }
}
