:root {
    --primary: #047857;
    --primary-hover: #065f46;
    --primary-light: #d1fae5;
    --accent: #FCD34D;
    --text-main: #1f2937;
    --text-sub: #4b5563;
    --text-muted: #9ca3af;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --nav-height: 56px;
}

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

body { background-color: var(--bg-body); color: var(--text-main); display: flex; justify-content: center; min-height: 100vh; width: 100%; max-width: 100vw; overflow-x: hidden; }

.app-container { width: 100%; max-width: 100%; background: var(--bg-card); min-height: 100vh; display: flex; flex-direction: column; }
@media (min-width: 768px) { .app-container { max-width: 1200px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); } }

/* ==================== HEADER ==================== */
header { position: sticky; top: 0; background: rgba(4, 120, 87, 0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 1000; box-shadow: 0 2px 12px rgba(0,0,0,0.15); }
.header-inner { display: flex; justify-content: space-between; align-items: center; padding: 0 16px; height: var(--nav-height); max-width: 1200px; margin: 0 auto; }
@media (min-width: 768px) { .header-inner { padding: 0 32px; } }
.header-left { display: flex; align-items: center; gap: 10px; }
.avatar-circle { width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; cursor: pointer; transition: all 0.3s ease; flex-shrink: 0; border: 2px solid rgba(255, 255, 255, 0.3); }
.avatar-circle:hover { background: rgba(255, 255, 255, 0.35); border-color: #FCD34D; transform: scale(1.05); box-shadow: 0 0 12px rgba(252, 211, 77, 0.3); }
.user-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 0.85rem; color: white; cursor: pointer; transition: color 0.2s; }
.user-name:hover { color: #FCD34D; }
.user-role { font-size: 0.68rem; color: rgba(255, 255, 255, 0.7); font-weight: 400; }
.user-info.logged-in .user-role { display: none; }

.desktop-nav { display: none; list-style: none; align-items: center; gap: 4px; }
@media (min-width: 1024px) { .desktop-nav { display: flex; } }
.desktop-nav a { color: rgba(255, 255, 255, 0.85); text-decoration: none; font-size: 0.82rem; font-weight: 500; padding: 6px 12px; border-radius: 6px; transition: all 0.2s; white-space: nowrap; }
.desktop-nav a:hover { color: white; background: rgba(255, 255, 255, 0.12); }
.desktop-nav a.active { color: white; background: rgba(255, 255, 255, 0.18); font-weight: 600; }
.desktop-nav a i { margin-right: 4px; font-size: 0.75rem; }

.hamburger { display: flex; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 4px; z-index: 1002; }
.hamburger span { display: block; width: 20px; height: 2px; background: white; border-radius: 2px; transition: all 0.35s ease; }
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }
@media (min-width: 1024px) { .hamburger { display: none; } }

.nav-mobile { position: absolute; top: var(--nav-height); left: 0; width: 100%; background: rgba(4, 120, 87, 0.97); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); max-height: 0; overflow: hidden; transition: max-height 0.7s cubic-bezier(0.22, 1, 0.36, 1); z-index: 999; }
.nav-mobile.open { max-height: 400px; }
@media (min-width: 1024px) { .nav-mobile { display: none !important; } }
.nav-mobile ul { list-style: none; padding: 8px 16px; }
.nav-mobile li { opacity: 0; transform: translateX(-40px); transition: all 0.55s cubic-bezier(0.22, 1, 0.36, 1); }
.nav-mobile.open li { opacity: 1; transform: translateX(0); }
.nav-mobile.open li:nth-child(1) { transition-delay: 0.12s; }
.nav-mobile.open li:nth-child(2) { transition-delay: 0.22s; }
.nav-mobile.open li:nth-child(3) { transition-delay: 0.32s; }
.nav-mobile.open li:nth-child(4) { transition-delay: 0.42s; }
.nav-mobile a { display: flex; align-items: center; gap: 8px; color: rgba(255, 255, 255, 0.9); text-decoration: none; padding: 12px 8px; font-size: 0.9rem; font-weight: 500; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.nav-mobile a i { width: 20px; text-align: center; color: #FCD34D; }
.nav-mobile a.active { color: #FCD34D; font-weight: 600; }

/* ==================== MAIN ==================== */
main { padding: 16px; flex: 1; max-width: 1200px; margin: 0 auto; width: 100%; }
@media (min-width: 480px) { main { padding: 20px; } }
@media (min-width: 768px) { main { padding: 28px 32px; } }
@media (min-width: 1024px) { main { padding: 32px 40px; } }
@media (min-width: 1280px) { main { padding: 36px 48px; } }

/* ==================== WELCOME CARD ==================== */
.welcome-card { background: linear-gradient(135deg, #047857, #065f46); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; color: #fff; overflow: hidden; }
@media (min-width: 768px) { .welcome-card { padding: 28px; } }
.welcome-tag { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; background: rgba(255,255,255,0.15); padding: 4px 10px; border-radius: 20px; display: inline-block; margin-bottom: 10px; }
.welcome-card h1 { font-size: 1.2rem; margin-bottom: 6px; font-weight: 700; }
@media (min-width: 768px) { .welcome-card h1 { font-size: 1.5rem; } }
.welcome-card p { font-size: 0.78rem; color: #d1fae5; }

/* ==================== STATS ==================== */
.stats-grid { display: flex; gap: 10px; margin-bottom: 16px; }
.stat-item { flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; align-items: center; gap: 8px; background: var(--bg-body); }
.stat-icon-wrapper { width: 28px; height: 28px; border-radius: 6px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.stat-info { display: flex; flex-direction: column; }
.stat-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.stat-value { font-size: 0.85rem; font-weight: 700; }

/* ==================== SEARCH ==================== */
.search-row { display: flex; gap: 8px; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; }
.search-box > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.85rem; z-index: 1; }
.search-input { width: 100%; padding: 10px 36px 10px 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.82rem; outline: none; background: var(--bg-body); transition: all 0.2s; }
.search-input:focus { border-color: var(--primary); background: #fff; }

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--border);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sub);
    font-size: 0.65rem;
    line-height: 1;
    padding: 0;
    transition: all 0.2s;
    z-index: 2;
}
.search-clear-btn i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.search-clear-btn:hover { background: #d1d5db; color: var(--text-main); }

.filter-action-btn { display: flex; align-items: center; gap: 6px; background: var(--bg-body); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; cursor: pointer; color: var(--text-sub); font-size: 0.85rem; font-weight: 500; transition: all 0.2s; white-space: nowrap; -webkit-tap-highlight-color: transparent; user-select: none; }
.filter-action-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-action-btn:active { transform: scale(0.94); background: #d1fae5; }

/* ==================== DISPLAY CONTROLS ==================== */
.display-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }

/* ==================== LIMIT DROPDOWN ==================== */
.limit-dropdown { position: relative; z-index: 9999; }
.limit-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--bg-body); border: 1px solid var(--border); border-radius: 6px; font-size: 0.75rem; font-weight: 600; color: var(--text-sub); cursor: pointer; transition: all 0.2s; font-family: 'Poppins', sans-serif; z-index: 9999; -webkit-tap-highlight-color: transparent; user-select: none; }
.limit-btn:hover { border-color: var(--primary); color: var(--primary); }
.limit-btn:active { transform: scale(0.94); background: #d1fae5; }
.limit-btn i { font-size: 0.8rem; }
.limit-menu { position: absolute; top: calc(100% + 4px); left: 0; background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); min-width: 120px; padding: 4px 0; opacity: 0; visibility: hidden; transform: translateY(-4px); transition: all 0.2s ease; z-index: 99999; }
.limit-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.limit-menu-item { display: block; width: 100%; padding: 8px 16px; background: none; border: none; text-align: left; font-size: 0.8rem; font-weight: 500; color: var(--text-main); cursor: pointer; transition: all 0.15s; font-family: 'Poppins', sans-serif; }
.limit-menu-item:hover { background: var(--primary-light); color: var(--primary); }

/* ==================== VIEW TOGGLE ==================== */
.toggle-switch-group { border: 1px solid var(--border); border-radius: 6px; display: flex; padding: 2px; background: var(--bg-body); }
.toggle-unit { padding: 4px 8px; cursor: pointer; font-size: 0.8rem; color: var(--text-muted); border-radius: 4px; transition: all 0.15s; background: none; border: none; }
.toggle-unit.active { background: white; color: var(--primary); box-shadow: var(--shadow-sm); }

/* ==================== GRID VIEW ==================== */
.books-layout-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
@media (min-width: 480px) { .books-layout-grid { gap: 14px; } }
@media (min-width: 640px) { .books-layout-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .books-layout-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; } }
@media (min-width: 1280px) { .books-layout-grid { grid-template-columns: repeat(5, 1fr); gap: 20px; } }

.card-item { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; background: #fafafa; display: flex; flex-direction: column; transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); cursor: pointer; height: 100%; box-shadow: var(--shadow-md); overflow: hidden; }
.card-item:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
.card-item:active { transform: scale(0.98); }
.cover-art-container { width: 100%; aspect-ratio: 3/4; border-radius: var(--radius-sm); margin-bottom: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.cover-thumbnail { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.cover-text-preview { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; text-align: center; padding: 0 8px; }
.card-body { display: flex; flex-direction: column; flex: 1; }
.card-info { flex: 1; display: flex; flex-direction: column; }
.tag-badge { font-size: 0.62rem; color: var(--primary); font-weight: 700; margin-bottom: 6px; background: var(--primary-light); padding: 2px 8px; border-radius: 4px; display: inline-block; width: fit-content; }
.card-info .item-main-title { font-size: 0.82rem; font-weight: 700; line-height: 1.3; color: var(--text-main); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.2em; margin-bottom: 6px; }
.card-info .meta-text-line { font-size: 0.7rem; color: var(--text-sub); margin-bottom: 2px; min-height: 1.1em; }
.action-card-btn { margin-top: auto; width: 100%; padding: 8px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.2s; flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 4px; -webkit-tap-highlight-color: transparent; user-select: none; }
.action-card-btn:active { background: var(--primary-hover); transform: scale(0.95); }

/* ==================== LIST VIEW ==================== */
.books-layout-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
@media (min-width: 768px) { .books-layout-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; } }
@media (min-width: 1024px) { .books-layout-list { grid-template-columns: repeat(3, 1fr); } }
.list-item { display: flex; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: #fafafa; box-shadow: var(--shadow-md); transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); align-items: center; cursor: pointer; }
.list-item:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.list-item:active { background: #f0fdf4; }
.list-cover { width: 50px; height: 66px; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.55rem; font-weight: 700; text-transform: uppercase; text-align: center; overflow: hidden; }
.list-info { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.list-info .item-main-title { font-size: 0.8rem; margin-bottom: 2px; }
.list-info .meta-text-line { font-size: 0.68rem; margin-bottom: 0; }
.list-action { flex-shrink: 0; }
.list-action .action-card-btn { margin-top: 0; padding: 8px 14px; font-size: 0.75rem; width: auto; }

/* ==================== PAGINATION ==================== */
.paginator-box { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; background: var(--bg-body); display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 16px; }
.paginator-caption { font-size: 0.7rem; color: var(--text-sub); font-weight: 600; text-transform: uppercase; }
.paginator-row { display: flex; align-items: center; gap: 4px; }
.nav-step-btn { padding: 6px 12px; border: 1px solid var(--border); background: white; border-radius: 6px; font-size: 0.75rem; font-weight: 600; cursor: pointer; color: var(--text-sub); transition: all 0.15s; position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; }
.nav-step-btn::after { content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0; border-radius: 50%; background: rgba(4, 120, 87, 0.2); transform: translate(-50%, -50%); transition: width 0.4s, height 0.4s, opacity 0.4s; }
.nav-step-btn:active::after { width: 200px; height: 200px; opacity: 0; }
.nav-step-btn:active { transform: scale(0.93); background: #d1fae5; border-color: var(--primary); }
.nav-step-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.nav-step-btn.active { background: var(--primary); color: white; border-color: var(--primary); transform: scale(1); }
.nav-step-btn.active:active { transform: scale(0.93); background: var(--primary-hover); }

/* ==================== MODAL ==================== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: flex-end; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
@media (min-width: 768px) { .modal-overlay { align-items: center; } }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-sheet { background: white; width: 100%; max-width: 600px; max-height: 85vh; border-radius: 20px 20px 0 0; padding: 20px 24px 28px; overflow-y: auto; transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
@media (min-width: 768px) { .modal-sheet { border-radius: 20px; max-height: 90vh; max-width: 650px; } }
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-close-btn { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%; background: var(--bg-body); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-sub); font-size: 0.9rem; z-index: 10; }
.modal-handle { width: 32px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 14px; }
@media (min-width: 768px) { .modal-handle { display: none; } }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; }
.modal-cover { width: 100%; aspect-ratio: 16/10; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; overflow: hidden; }
.modal-info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
.modal-info-row span:first-child { color: var(--text-muted); font-weight: 500; }
.modal-info-row span:last-child { font-weight: 600; text-align: right; }
.modal-action-btn { width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 600; cursor: pointer; margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.modal-action-btn:active { background: var(--primary-hover); }
.profile-avatar { width: 70px; height: 70px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 2.5rem; color: var(--primary); }
.filter-group { margin-bottom: 16px; }
.filter-label { font-size: 0.75rem; font-weight: 600; color: var(--text-sub); margin-bottom: 6px; text-transform: uppercase; }
.filter-options { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-option { padding: 6px 14px; border-radius: 16px; border: 1px solid var(--border); font-size: 0.75rem; cursor: pointer; background: white; transition: all 0.2s; }
.filter-option.selected { background: var(--primary); color: white; border-color: var(--primary); }
.login-container { max-width: 400px; margin: 40px auto; text-align: center; }
.login-avatar { width: 80px; height: 80px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 2.5rem; color: var(--primary); }
.login-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 20px; }
.form-group { margin-bottom: 14px; text-align: left; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-sub); margin-bottom: 4px; display: block; }
.form-input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; outline: none; transition: all 0.2s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(4,120,87,0.1); }

/* ==================== LOADING SPINNER ==================== */
.loading-container { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; gap: 12px; }
.loading-spinner { width: 40px; height: 40px; border: 4px solid #e5e7eb; border-top-color: #047857; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 0.85rem; color: #9ca3af; font-weight: 500; }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 40px; color: #9ca3af; }

/* ==================== FONT AWESOME SPIN ==================== */
.fa-spin { animation: fa-spin 1s linear infinite; }
@keyframes fa-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==================== FOOTER ==================== */
footer { text-align: center; padding: 18px; font-size: 0.72rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: auto; }
.footer-social { display: flex; justify-content: center; gap: 12px; margin-top: 8px; }
.social-link { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-size: 0.85rem; text-decoration: none; transition: all 0.3s; }
.social-link:hover { background: var(--primary); color: white; transform: translateY(-2px); }

/* ==================== ANIMASI ==================== */
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
.slide-up { opacity: 0; animation: slideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.slide-up-delay-1 { animation-delay: 0.05s; }
.slide-up-delay-2 { animation-delay: 0.10s; }
.slide-up-delay-3 { animation-delay: 0.15s; }
.slide-up-delay-4 { animation-delay: 0.20s; }
.slide-up-delay-5 { animation-delay: 0.25s; }

/* ==================== UTILITY ==================== */
.hidden { display: none !important; }
.text-center { text-align: center; }
