:root {
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-surface: #FEF7FF;
    --md-sys-color-outline: #79747E;
    --md-sys-color-surface-variant: #E7E0EC;
}

body {
    margin: 0; padding: 16px;
    background-color: var(--md-sys-color-surface);
    font-family: 'Roboto', sans-serif;
    padding-bottom: 80px;
}

/* Grid System: 3 Kolom */
.comic-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* Card Style MD3 */
.comic-card {
    background: var(--md-sys-color-surface-variant);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s;
}

.comic-card img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
}

.comic-card .info {
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Tombol Favorite di Card */
.fav-btn {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(255,255,255,0.8);
    border: none; border-radius: 50%;
    width: 32px; height: 32px;
    cursor: pointer;
}


.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: var(--md-sys-color-surface);
    padding: 12px 0;
    box-shadow: 0 -1px 10px rgba(0,0,0,0.1);
}

/* Animasi sederhana untuk transisi SPA */
main {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

#searchInput, select {
    background: transparent;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    padding: 12px;
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
    outline: none;
}

#searchInput:focus {
    border: 2px solid var(--md-sys-color-primary);
}

.select-group {
    display: flex;
    gap: 8px;
}

.select-group select {
    flex: 1;
}

/* Badge Type di Card (Opsional) */
.type-badge {
    position: absolute;
    bottom: 40px; left: 8px;
    background: var(--md-sys-color-primary);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
}


.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px 0;
}

.page-btn {
    background-color: var(--md-sys-color-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px; /* Pill shape MD3 */
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.page-btn:disabled {
    background-color: var(--md-sys-color-outline);
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    color: var(--md-sys-color-outline);
    font-weight: 500;
}

/* Tambahkan sedikit margin bawah agar tidak tertutup Bottom Nav */
.comic-grid {
    min-height: 200px;
}

/* Detail Page */
.detail-page { padding: 16px; animation: fadeIn 0.3s; }
.detail-header { display: flex; gap: 16px; margin-top: 16px; }
.detail-thumb { width: 120px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.detail-info h2 { margin: 0 0 8px 0; color: var(--md-sys-color-primary); }
.detail-info p { margin: 4px 0; font-size: 14px; }

.chapter-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.chapter-list button { 
    padding: 12px; border: none; background: var(--md-sys-color-surface-variant); 
    border-radius: 8px; text-align: left; cursor: pointer;
}

/* Webtoon Reader */
.webtoon-container { display: flex; flex-direction: column; background: #000; }
.webtoon-container img { width: 100%; display: block; height: auto; }

.reader-header { 
    position: sticky; top: 0; background: var(--md-sys-color-surface); 
    padding: 12px; display: flex; align-items: center; gap: 12px; z-index: 10;
}

.reader-footer { 
    display: flex; justify-content: center; gap: 20px; padding: 20px; 
    background: var(--md-sys-color-surface); 
}

.back-btn { 
    background: none; border: 1px solid var(--md-sys-color-primary); 
    color: var(--md-sys-color-primary); border-radius: 20px; padding: 4px 12px;
}

/* Header Style */
header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--md-sys-color-surface);
    position: sticky;
    top: 0; z-index: 100;
}
.logo { font-size: 20px; font-weight: 700; color: var(--md-sys-color-primary); }
.logo span { color: var(--md-sys-color-outline); }

/* Continue Reading Card */
.continue-section { margin-bottom: 24px; }
.section-title { font-size: 16px; margin-bottom: 12px; }

.continue-card {
    display: flex;
    align-items: center;
    background: var(--md-sys-color-primary);
    color: white;
    padding: 12px;
    border-radius: 16px;
    gap: 12px;
    cursor: pointer;
}
.continue-card img { width: 50px; height: 50px; border-radius: 8px; object-fit: cover; }
.continue-info { flex: 1; display: flex; flex-direction: column; }
.continue-info .title { font-weight: bold; font-size: 14px; }
.continue-info .chapter { font-size: 12px; opacity: 0.8; }
.play-icon { font-size: 24px; margin-right: 8px; }

/* Reader Title Adjustment */
.reader-title { display: flex; flex-direction: column; }
.reader-title small { font-size: 10px; opacity: 0.7; }
.icon-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--md-sys-color-primary); }

/* Animasi Tombol Simpel */
button:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

/* Floating Chat Box */
.chat-window {
    position: fixed;
    bottom: 80px; right: 16px;
    width: 280px; height: 350px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 16px;
    display: flex; flex-direction: column;
    z-index: 1000; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.chat-content { flex: 1; overflow-y: auto; padding: 10px; font-size: 13px; }
.chat-input { display: flex; padding: 8px; border-top: 1px solid #eee; }
.chat-input input { flex: 1; border: none; padding: 4px; outline: none; }

/* Comment Section */
.comment-item {
    background: var(--md-sys-color-surface-variant);
    padding: 8px; border-radius: 8px; margin-bottom: 8px;
}

.chat-content div {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 12px;
    background: var(--md-sys-color-surface-variant);
    width: fit-content;
    max-width: 80%;
}

/* Membedakan pesan sendiri (opsional) */
.chat-content div b {
    color: var(--md-sys-color-primary);
    display: block;
    font-size: 11px;
}

.comment-input-box {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.comment-input-box input {
    flex: 1;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 8px;
    padding: 8px;
    background: transparent;
}

/* Tombol hapus di pojok pesan */
.del-msg {
    float: right;
    background: none;
    border: none;
    color: #ba1a1a; /* MD3 Error Color */
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

/* Animasi sederhana saat chat muncul */
.chat-item {
    animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-window {
    position: fixed;
    /* Posisi awal */
    bottom: 80px; 
    right: 16px;
    width: 300px;
    height: 400px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    touch-action: none; /* Penting untuk drag di HP */
    user-select: none;
}

.chat-header {
    cursor: move; /* Kursor berubah jadi tanda pindah */
    background: var(--md-sys-color-primary);
    color: white;
    padding: 12px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-window {
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); /* Animasi snap membal */
    max-height: 80vh; /* Agar tidak melebihi layar saat keyboard naik */
}

/* Matikan transisi saat sedang di-drag agar tidak delay */
.chat-window.dragging {
    transition: none;
}

.chat-input input:focus {
    border-top: 2px solid var(--md-sys-color-primary);
}
