:root {
    --bg-color: #000000;
    --text-color: #f8f8f8;
    --text-muted: #888888;
    --primary: #f59e0b; /* Amber for a premium contrast on black */
    --primary-hover: #d97706;
    --glass-bg: rgba(15, 15, 15, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --nav-height: 60px;
    --danger: #ef4444;
    --success: #10b981;
    --ongoing: #f59e0b;
    --completed: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Typography */
h1, h2, h3 { font-weight: 700; margin-bottom: 0.5rem; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }

/* Layout */
.app-container {
    max-width: 768px; /* Mobile first, capped for desktop */
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-height) + 20px);
}

.content-area {
    padding: 20px;
    padding-top: calc(var(--nav-height) + 20px);
}

.pb-100 { padding-bottom: 100px; }
.mb-2 { margin-bottom: 0.5rem; }

/* Glassmorphism utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    border-top: 1px solid var(--glass-border);
}

/* Header */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 20px;
    max-width: 768px;
    margin: 0 auto;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 100;
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 768px;
    margin: 0 auto;
    border-top: 1px solid var(--glass-border);
    border-bottom: none;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    gap: 4px;
    transition: color 0.3s ease;
}

.nav-item ion-icon { font-size: 1.5rem; }
.nav-item.active, .nav-item:hover { color: var(--primary); }

/* Search & Filters */
.search-bar-container {
    display: flex;
    flex: 1;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 8px 15px;
    gap: 10px;
}

.search-input {
    background: none;
    border: none;
    color: white;
    flex: 1;
    outline: none;
    font-size: 1rem;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.filter-group::-webkit-scrollbar { display: none; }

.glass-select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 12px;
    outline: none;
    appearance: none;
    font-size: 0.9rem;
}
.glass-select option { background: var(--bg-color); }

/* Comic Grid */
.comic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.comic-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.comic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.cover-wrapper {
    position: relative;
    padding-top: 140%; /* 3:4 aspect ratio */
}

.cover-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comic-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.comic-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 5px;
}
.status-ongoing { background: var(--ongoing); color: white; }
.status-completed { background: var(--completed); color: white; }
.type { background: rgba(255,255,255,0.1); color: #ccc; }

.comic-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto;
}

/* Spinner */
.loading-indicator {
    display: flex;
    justify-content: center;
    padding: 20px;
}
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Detail Page */
.detail-container {
    margin: -20px;
    padding-bottom: 20px;
}

.detail-hero {
    position: relative;
    padding: 20px;
    padding-top: calc(var(--nav-height) + 20px);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.detail-cover-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.3);
    z-index: 1;
}

.detail-cover-content {
    position: relative;
    z-index: 2;
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.detail-cover-img {
    width: 120px;
    height: 160px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.detail-info { flex: 1; }
.detail-title { font-size: 1.4rem; line-height: 1.2; }
.detail-author { font-size: 0.9rem; color: #ccc; margin-bottom: 10px; }

.genre-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
    background: rgba(255,255,255,0.15);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.detail-actions {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    z-index: 3;
    position: relative;
}

.btn {
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.3s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.full-width { flex: 1; }
.btn-icon { background: rgba(255,255,255,0.1); color: white; padding: 12px; display: flex; align-items: center; justify-content: center; }
.btn-icon ion-icon { font-size: 1.2rem; }

.detail-section {
    margin: 20px;
    padding: 20px;
    border-radius: 16px;
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

.synopsis-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #ccc;
}

.chapter-item {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: white;
}
.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover { background: rgba(255,255,255,0.05); }

/* Reader Page */
.reader-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    padding: 0 15px;
    justify-content: space-between;
    z-index: 100;
    max-width: 768px;
    margin: 0 auto;
    transition: transform 0.3s;
}
.reader-nav.hidden-nav { transform: translateY(-100%); }

.reader-title { text-align: center; flex: 1; }
.comic-name { font-size: 0.8rem; color: var(--text-muted); }
.chapter-name { font-weight: 600; font-size: 1rem; }

.reader-controls.bottom {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 100;
    max-width: 768px;
    margin: 0 auto;
    transition: transform 0.3s;
}
.reader-controls.hidden-nav { transform: translateY(100%); }

.reader-container {
    margin: -20px;
    padding-top: 0;
    background: #000;
    min-height: 100vh;
}

.reader-images {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.lazy-wrapper {
    position: relative;
    width: 100%;
    max-width: 768px;
    min-height: 300px;
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lazy-wrapper::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 0;
}

.reader-img {
    width: 100%;
    max-width: 768px;
    display: block;
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.reader-img.loaded {
    opacity: 1;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
    font-weight: 600;
}
.nav-btn.disabled { color: #555; pointer-events: none; }

/* Admin */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 70vh;
}
.login-box, .admin-panel, .form-panel {
    width: 100%;
    padding: 25px;
    border-radius: 16px;
}
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 0.9rem; color: #ccc; }
.glass-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 8px;
    color: white;
    outline: none;
    font-size: 1rem;
}
.glass-input:focus { border-color: var(--primary); }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.table-responsive { overflow-x: auto; }
.truncate {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 6px; }
.btn-outline { border: 1px solid var(--text-muted); background: transparent; color: white; }

/* Library List View */
.comic-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.comic-list-item {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    padding: 10px;
    gap: 15px;
}
.comic-list-cover { width: 80px; height: 110px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.comic-list-info { flex: 1; display: flex; flex-direction: column; }
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
}
