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

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --background-color: #ffffff;
    --surface-color: #f8fafc;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: all 0.3s ease;
}

/* Header Styles */
.header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.nav-brand h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 700;
}

.nav-search {
    display: flex;
    gap: 0.5rem;
    flex: 0 1 400px;
}

.nav-search input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--background-color);
    color: var(--text-color);
}

.nav-search button {
    padding: 0.75rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

section {
    margin-bottom: 3rem;
}

section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-color);
}

/* Manga Grid */
.manga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.manga-card {
    background-color: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.manga-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

.manga-cover {
    width: 100%;
    height: 280px;
    object-fit: cover;
}

.manga-info {
    padding: 1rem;
}

.manga-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.manga-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    background-color: var(--background-color);
    margin: 2% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Reader Styles */
.reader-modal .modal-content {
    max-width: 100%;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    background-color: #000;
}

.reader-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.reader-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
}

.reader-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

#readerContainer {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

.reader-page {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Loading Spinner */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav-search {
        flex: none;
        width: 100%;
    }
    
    .manga-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .manga-cover {
        height: 220px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 1rem;
    }
}


.manga-detail-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.detail-cover {
    width: 200px;
    height: 280px;
    object-fit: cover;
    border-radius: 8px;
}

.detail-info {
    flex: 1;
}

.detail-info h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.detail-description {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.detail-meta {
    display: flex;
    gap: 2rem;
    color: var(--text-secondary);
}

.chapters-section h3 {
    margin-bottom: 1rem;
}

.chapters-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}

.chapter-item {
    padding: 0.75rem 1rem;
    background-color: var(--surface-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-align: center;
}

.chapter-item:hover {
    background-color: var(--primary-color);
    color: white;
}

@media (max-width: 768px) {
    .manga-detail-header {
        flex-direction: column;
    }
    
    .detail-cover {
        align-self: center;
    }
    
    .chapters-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}
