/* === VARIABEL WARNA & TEMA DASAR === */
:root {
    --bg-primary: #121212;
    --bg-secondary: #1E1E1E;
    --bg-card: #252525;
    --bg-card-alt: #2a2a2a;
    --text-primary: #E0E0E0;
    --text-secondary: #A0A0A0;
    --accent-purple: #9D4EDF;
    --accent-lime: #D4FF00;
    --border-color: #333333;
    --danger: #FF4D4D;
    --success: #00C853;
}

[data-theme="light"] {
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-alt: #ECECEC;
    --text-primary: #1A1A1A;
    --text-secondary: #6B6B6B;
    --accent-purple: #7C3AED;
    --accent-lime: #5C8A00;
    --border-color: #E2E2E6;
    --danger: #DC2626;
    --success: #16A34A;
}


/* === RESET & BODY === */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    padding-bottom: 80px; /* Ruang untuk bottom nav */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; }
.text-muted { color: var(--text-secondary) !important; }
a { color: var(--accent-purple); text-decoration: none; }

/* === HEADER ATAS === */
.top-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: sticky; top: 0; z-index: 100;
}
.top-header h6 { color: var(--accent-lime) !important; }

/* ========== THEME TOGGLE BUTTON (FITUR BARU #1) ========== */
.theme-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
    background-color: var(--bg-card);
    transform: scale(1.05);
}

/* === BOTTOM NAVIGATION === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 15px rgba(0,0,0,0.3);
    z-index: 1000; display: flex; justify-content: space-around;
    padding: 10px 0 15px; backdrop-filter: blur(10px);
}
.nav-item-bottom {
    text-align: center; color: var(--text-secondary);
    text-decoration: none; font-size: 0.7rem; flex: 1;
    padding: 5px 0; transition: all 0.3s ease;
}
.nav-item-bottom i {
    font-size: 1.4rem; display: block; margin-bottom: 4px;
    transition: transform 0.2s ease;
}
.nav-item-bottom.active { color: var(--accent-lime); font-weight: 600; }
.nav-item-bottom.active i { transform: translateY(-3px); }

/* === CARDS & CONTAINERS === */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.shadow-sm { box-shadow: 0 4px 6px rgba(0,0,0,0.2) !important; }

/* Kartu Statistik Khusus */
.stat-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-alt) 100%);
    border: 1px solid var(--border-color);
}
.stat-card .stat-icon { font-size: 2.5rem; opacity: 0.8; }
.stat-card h3 { color: var(--accent-lime); font-weight: 700; }

/* Kartu Sambutan */
.welcome-card {
    background: linear-gradient(135deg, var(--accent-purple) 0%, #6a1bb3 100%);
    border: none; color: #fff !important;
}
.welcome-card h6, .welcome-card small { color: #fff !important; }

/* === FORMS & INPUTS === */
.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger) !important;
    background-image: none; /* hilangkan ikon default bootstrap yang susah kelihatan di dark mode */
}
.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(255, 77, 77, 0.25) !important;
}

.form-control, .form-select {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px; padding: 10px 15px;
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-primary);
    border-color: var(--accent-purple);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(157, 78, 223, 0.25);
}
.form-control::placeholder { color: #666; }
.form-label { color: var(--text-secondary); font-weight: 500; margin-bottom: 6px; }

/* === BUTTONS === */
.btn { border-radius: 10px; font-weight: 600; padding: 10px 20px; transition: all 0.2s ease; }
.btn:active { transform: scale(0.97); }
.btn-primary { background-color: var(--accent-purple); border-color: var(--accent-purple); color: #fff; }
.btn-primary:hover { background-color: #8a3ec9; border-color: #8a3ec9; }
.btn-success { background-color: var(--accent-lime); border-color: var(--accent-lime); color: #121212; }
.btn-success:hover { background-color: #c2f000; border-color: #c2f000; }
.btn-danger { background-color: var(--danger); border-color: var(--danger); color: #fff; }
.btn-outline-primary { border-color: var(--accent-purple); color: var(--accent-purple); }
.btn-outline-primary:hover { background-color: var(--accent-purple); color: #fff; }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); }

/* ========== MODAL KONFIRMASI (FITUR BARU #2) ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeInOverlay 0.2s ease;
}

.modal-box {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 24px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    animation: popInBox 0.25s ease;
}

.modal-box h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.modal-box p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-cancel {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background-color: var(--bg-secondary);
}

/* === PAGE SECTIONS === */
.page-section { display: none; padding: 20px 15px; animation: fadeIn 0.3s ease; }
.page-section.active-page { display: block; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === AUTH SECTION === */
#auth-section .card { background-color: var(--bg-secondary); border: 1px solid var(--border-color); }
#auth-section h3 { color: var(--accent-lime); }

/* === PRINT AREA (TETAP DIPERTAHANKAN UNTUK PDF) === */
#print-area { display: none; }
@media print {
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { 
        .preview-overlay {display: none !important;}
        .halaman-baru {page-break-before: always; margin-top: 20px;}
        display: block !important; position: absolute; left: 0; top: 0; 
        width: 100%; padding: 20px; color: #000 !important; background: #fff !important; 
        font-family: 'Times New Roman', Times, serif; font-size: 12pt; line-height: 1.5; 
    }
    .halaman-baru { page-break-before: always; margin-top: 20px; }
    .halaman-cover {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center; /* TENGAH VERTIKAL */
    align-items: center; /* TENGAH HORIZONTAL */
    text-align: center;
    page-break-after: always;
}

.halaman-cover img {
    margin-bottom: 30px;
}

.halaman-cover h1,
.halaman-cover h2 {
    margin: 10px 0;
}

    #print-area table { width: 100%; border-collapse: collapse; margin-top: 15px; }
    #print-area th, #print-area td { border: 1px solid #000; padding: 8px; text-align: left; font-size: 12pt; }
    #print-area th { background-color: #f2f2f2; font-weight: bold; text-align: center; }
    #print-area h1, #print-area h2, #print-area h3, #print-area p { color: #000 !important; }
}

/* ========== TOAST NOTIFICATION ========== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 90vw;
}
.toast-custom {
    min-width: 250px;
    max-width: 350px;
    padding: 14px 18px;
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInToast 0.3s ease, fadeOutToast 0.3s ease 2.7s forwards;
}
.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-warning { background: #f59e0b; color: #1a1a1a; }
.toast-info { background: #0ea5e9; }
.toast-custom i { font-size: 18px; flex-shrink: 0; }

@keyframes slideInToast {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOutToast {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(120%); }
}

/* ========== CONFIRM MODAL ========== */
.confirm-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInOverlay 0.2s ease;
    padding: 20px;
}
.confirm-box {
    background: #fff;
    border-radius: 18px;
    padding: 28px 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    animation: popInBox 0.25s ease;
}
.confirm-icon { font-size: 2.8rem; color: #dc2626; margin-bottom: 12px; }
.confirm-text { font-size: 15px; margin-bottom: 20px; color: #333; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { border-radius: 10px; font-weight: 600; }

@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }
@keyframes popInBox { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ========== SKELETON LOADING (ENHANCED - FITUR #3) ========== */
.skeleton {
    background: linear-gradient(
        90deg, 
        var(--bg-card) 25%, 
        var(--bg-card-alt) 50%, 
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 1.4s infinite;
    border-radius: 8px;
}

[data-theme="light"] .skeleton {
    background: linear-gradient(90deg, #e2e2e2 25%, #f0f0f0 50%, #e2e2e2 75%);
    background-size: 200% 100%;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-line { height: 12px; margin-bottom: 8px; border-radius: 6px; }
.skeleton-card { height: 70px; margin-bottom: 10px; border-radius: 12px; }

/* ========== CHART CONTAINER (FITUR #4) ========== */
.chart-container {
    position: relative;
    width: 100%;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.chart-container canvas {
    max-height: 250px;
}

.chart-container h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
    color: var(--text-primary);
}

/* ========== BADGE ACHIEVEMENT (FITUR #5) ========== */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.badge-item {
    text-align: center;
    padding: 16px 12px;
    border-radius: 12px;
    background: var(--bg-card-alt);
    border: 2px solid var(--border-color);
    opacity: 0.35;
    filter: grayscale(100%);
    transition: all 0.3s ease;
}

.badge-item.unlocked {
    opacity: 1;
    filter: grayscale(0%);
    background: linear-gradient(135deg, rgba(157, 78, 223, 0.15), rgba(212, 255, 0, 0.15));
    border-color: var(--accent-lime);
    transform: scale(1.02);
}

.badge-icon { 
    font-size: 2.2rem; 
    display: block;
    margin-bottom: 6px;
}

.badge-label { 
    font-size: 0.7rem; 
    color: var(--text-secondary); 
    font-weight: 500;
}

.badge-item.unlocked .badge-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* ========== PWA INSTALL PROMPT (FITUR #6 - OPTIONAL) ========== */
.pwa-install-banner {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 90%;
    z-index: 999;
    animation: slideUpBanner 0.3s ease;
}

.pwa-install-banner .icon {
    font-size: 1.5rem;
    color: var(--accent-purple);
}

.pwa-install-banner .content {
    flex: 1;
}

.pwa-install-banner .content p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.pwa-install-banner .btn-install {
    background: var(--accent-purple);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.pwa-install-banner .btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

@keyframes slideUpBanner {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ========== PROGRESS TRACKER ========== */
.progress-bar-track {
    width: 100%;
    height: 10px;
    background: var(--border-color, #e9ecef);
    border-radius: 10px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-lime), var(--accent-purple));
    border-radius: 10px;
    transition: width 0.6s ease;
}
.checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
    transition: color 0.2s;
}
.checklist-item.done { color: #16a34a; font-weight: 500; }
.checklist-item.pending { color: #9ca3af; }
.checklist-item i { font-size: 15px; flex-shrink: 0; }

/* ========== TEMPLATE SELECTOR ========== */
.template-option {
    text-align: center;
    cursor: pointer;
    padding: 8px 6px;
    border-radius: 12px;
    border: 2px solid transparent;
    transition: all 0.2s;
}
.template-option:hover { background: rgba(0,0,0,0.03); }
.template-option.selected {
    border-color: var(--accent-lime);
    background: rgba(163,230,53,0.1);
}
.template-preview {
    height: 55px;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid #ddd;
}
.template-formal-preview { background: linear-gradient(to bottom, #fff 0% 25%, #333 25% 30%, #fff 30% 100%); }
.template-modern-preview { background: linear-gradient(135deg, #6366f1, #a855f7); }
.template-minimal-preview { background: #f8f9fa; }
.template-option small { font-size: 11px; display: block; }

/* ========== PRINT TEMPLATE VARIANTS ========== */
.print-area-formal h2 {
    font-family: 'Times New Roman', serif !important;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
}
.print-area-modern h2 {
    font-family: 'Segoe UI', sans-serif !important;
    color: #6366f1;
    border-left: 5px solid #6366f1;
    padding-left: 14px;
    border-bottom: none !important;
}
.print-area-minimal h2 {
    font-family: Arial, sans-serif !important;
    font-weight: 300;
    border-bottom: 1px solid #ccc;
    letter-spacing: 1px;
}

/* ========== MOBILE OPTIMIZATION ========== */
@media (max-width: 480px) {
    .top-header { padding: 12px 16px !important; }
    .top-header h6 { font-size: 14px; }
    .top-header small { font-size: 11px; }
    .bottom-nav { padding: 6px 2px; }
    .nav-item-bottom { font-size: 9.5px; padding: 4px 2px; }
    .nav-item-bottom i { font-size: 17px; display: block; margin-bottom: 2px; }
    .card { padding: 14px !important; }
    .stat-icon { font-size: 1.7rem !important; }
    h5.fw-bold { font-size: 1.05rem; }
    h6.fw-semibold { font-size: 0.9rem; }
    .btn { font-size: 13.5px; padding: 10px 14px; }
    #toast-container { left: 10px; right: 10px; top: 10px; }
    .toast-custom { max-width: 100%; min-width: auto; }
    .confirm-box { padding: 22px 18px; }
    .template-preview { height: 45px; }
    .form-control, .form-select { font-size: 14px; }
    textarea.form-control { font-size: 13.5px; }
    
    /* Badge responsive */
    .badge-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .badge-item { padding: 12px 8px; }
    .badge-icon { font-size: 1.8rem; }
    .badge-label { font-size: 0.65rem; }
    
    /* Chart responsive */
    .chart-container { padding: 12px; }
    .chart-container canvas { max-height: 200px; }
    
    /* Theme toggle button responsive */
    .theme-toggle-btn { width: 36px; height: 36px; font-size: 1rem; }
}

/* ========== PREVIEW LIVE MODAL ========== */
.preview-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #ececec;
    z-index: 10000;
    display: flex;
    flex-direction: column;
}
.preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    flex-shrink: 0;
}
.preview-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.preview-modal-body .halaman-cover,
.preview-modal-body .halaman-baru {
    background: #fff;
    width: 100%;
    max-width: 700px;
    min-height: 500px;
    padding: 50px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border-radius: 4px;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .preview-modal-header { padding: 10px 14px; }
    .preview-modal-header h6 { font-size: 13px; }
    .preview-modal-header .btn { font-size: 12px; padding: 6px 10px; }
    .preview-modal-body { padding: 15px 10px; }
    .preview-modal-body .halaman-cover,
    .preview-modal-body .halaman-baru { padding: 20px; min-height: auto; }
}

/* ========== INITIAL LOADER (ikut tema) ========== */
#initial-loader {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-primary);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 99999;
}
#initial-loader .spinner-border { color: var(--accent-purple); width: 3rem; height: 3rem; }
#initial-loader p { color: var(--text-primary); margin-top: 15px; font-size: 14px; }

/* ========== HALAMAN DONASI ========== */
.donation-method {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.donation-method:hover {
    border-color: var(--accent-purple);
    background-color: var(--bg-secondary);
}

.donation-icon {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background-color: var(--accent-purple);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.faq-item {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.faq-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* ========== HALAMAN PROFIL ========== */
.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    border: 3px solid rgba(255, 255, 255, 0.5);
}

.profile-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.profile-info-row:last-of-type {
    border-bottom: none;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.settings-row:hover {
    opacity: 0.7;
}

.settings-row:last-child {
    border-bottom: none;
}
