/* === CSS Reset & Variables === */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

:root {
    --primary: #0f766e; 
    --primary-dark: #115e59; 
    --primary-light: #14b8a6;
    --primary-bg: #f0fdfa; 
    --secondary: #f59e0b; 
    --danger: #ef4444; 
    --success: #10b981;
    --bg: #f8fafc; 
    --card: #ffffff; 
    --text: #1e293b; 
    --text-light: #64748b; 
    --border: #e2e8f0;
}

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.5; 
    overflow-x: hidden; 
    padding-bottom: 90px; 
}

/* === App Header === */
.header { 
    background: var(--card); 
    padding: 16px 20px; 
    position: sticky; 
    top: 0; 
    z-index: 50; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
}

.header-title { 
    font-size: 1.25rem; 
    font-weight: 700; 
    color: var(--primary-dark); 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.header-icon { 
    width: 32px; 
    height: 32px; 
    background: var(--primary-bg); 
    color: var(--primary); 
    border-radius: 10px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 1.1rem; 
}

.container { 
    max-width: 600px; 
    margin: 0 auto; 
    padding: 16px; 
}

.section { 
    display: none; 
    animation: fadeIn 0.3s ease; 
} 

.section.active { 
    display: block; 
}

@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* === Bottom Navigation === */
.bottom-nav { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    background: var(--card); 
    display: flex; 
    justify-content: space-around; 
    padding: 12px 10px; 
    padding-bottom: 12px; /* Fallback untuk browser lawas */
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); 
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05); 
    z-index: 100; 
    border-top: 1px solid var(--border); 
}

.nav-item { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 4px; 
    color: var(--text-light); 
    font-size: 0.75rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: color 0.3s; 
    flex: 1; 
    background: none; 
    border: none; 
}

.nav-item-icon { 
    font-size: 1.4rem; 
    transition: transform 0.2s; 
}

.nav-item.active { 
    color: var(--primary); 
}

.nav-item.active .nav-item-icon { 
    transform: scale(1.1); 
}

/* === Cards & Utilities === */
.card { 
    background: var(--card); 
    border-radius: 20px; 
    padding: 20px; 
    margin-bottom: 16px; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.02); 
    border: 1px solid rgba(226, 232, 240, 0.8); 
}

.section-title { 
    font-size: 1.1rem; 
    font-weight: 700; 
    margin-bottom: 12px; 
    color: var(--text); 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

/* === Dashboard Stats === */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 12px; 
    margin-bottom: 20px; 
}

.stat-card { 
    background: var(--card); 
    padding: 16px; 
    border-radius: 20px; 
    text-align: left; 
    border: 1px solid var(--border); 
    position: relative; 
    overflow: hidden; 
}

.stat-card::before { 
    content: ''; 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 4px; 
    height: 100%; 
    background: var(--primary); 
    border-radius: 4px 0 0 4px; 
}

.stat-value { 
    font-size: 1.75rem; 
    font-weight: 800; 
    color: var(--text); 
    margin-bottom: 2px; 
}

.stat-label { 
    font-size: 0.8rem; 
    font-weight: 500; 
    color: var(--text-light); 
}

.stat-card.accent-2::before { background: var(--secondary); }
.stat-card.accent-3::before { background: var(--success); }

/* === Inputs & Forms === */
.form-group { margin-bottom: 16px; }

.form-label { 
    display: block; 
    font-weight: 600; 
    margin-bottom: 8px; 
    font-size: 0.85rem; 
    color: var(--text-light); 
}

.form-input, .form-select { 
    width: 100%; 
    padding: 14px 16px; 
    border: 1px solid var(--border); 
    border-radius: 14px; 
    font-size: 0.95rem; 
    background: #f8fafc; 
    color: var(--text); 
    outline: none; 
    transition: all 0.2s; 
    font-family: inherit; 
    font-weight: 500; 
    appearance: none; 
    -webkit-appearance: none;
}

.form-input:focus, .form-select:focus { 
    border-color: var(--primary); 
    background: #ffffff; 
    box-shadow: 0 0 0 4px var(--primary-bg); 
}

.form-select { 
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIGZpbGw9J25vbmUnIHZpZXdCb3g9JzAgMCAyNCAyNCcgc3Ryb2tlPScjNjQ3NDhiJz48cGF0aCBzdHJva2UtbGluZWNhcD0ncm91bmQnIHN0cm9rZS1saW5lam9pbj0ncm91bmQnIHN0cm9rZS13aWR0aD0nMicgZD0nTTE5IDlsLTcgNy03LTcnPjwvcGF0aD48L3N2Zz4="); 
    background-repeat: no-repeat; 
    background-position: right 16px center; 
    background-size: 16px; 
    padding-right: 40px; 
}

/* === Buttons === */
.btn { 
    width: 100%; 
    padding: 14px; 
    border: none; 
    border-radius: 14px; 
    font-size: 0.95rem; 
    font-weight: 600; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    font-family: inherit; 
    transition: transform 0.1s, opacity 0.2s; 
}

.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-danger-soft { background: #fee2e2; color: var(--danger); }
.btn-sm { padding: 8px 12px; font-size: 0.8rem; border-radius: 10px; width: auto; }

.fab { 
    position: fixed; 
    bottom: 90px; 
    right: 20px; 
    width: 56px; 
    height: 56px; 
    background: var(--primary); 
    color: white; 
    border-radius: 20px; 
    border: none; 
    font-size: 1.8rem; 
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.3); 
    z-index: 90; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
}

/* === Search & Lists === */
.search-container { position: relative; margin-bottom: 16px; }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; opacity: 0.5; }
.search-input { padding-left: 44px; }

.list-item { 
    background: var(--card); 
    border-radius: 16px; 
    padding: 16px; 
    margin-bottom: 12px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border: 1px solid var(--border); 
}

.list-item-content h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.list-item-content p { font-size: 0.8rem; color: var(--text-light); }

/* === Folder Grid (Jenjang & Kelas) === */
.folder-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.folder-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
.folder-icon { width: 48px; height: 48px; background: var(--primary-bg); color: var(--primary); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 12px; }
.folder-card.alt .folder-icon { background: #fef3c7; color: var(--secondary); }
.folder-title { font-weight: 600; font-size: 0.95rem; }
.folder-subtitle { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; }

/* === Breadcrumb === */
.breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; font-size: 0.85rem; font-weight: 500; color: var(--text-light); overflow-x: auto; white-space: nowrap; padding-bottom: 4px; }
.breadcrumb-item { padding: 6px 10px; background: var(--border); border-radius: 8px; cursor: pointer; }
.breadcrumb-item.home { background: var(--primary-bg); color: var(--primary); }
.breadcrumb-separator { font-size: 0.8rem; opacity: 0.5; }

/* === Segmented Control === */
.segmented-control { display: flex; background: #e2e8f0; border-radius: 14px; padding: 4px; margin-bottom: 20px; }
.segment-btn { flex: 1; padding: 10px; text-align: center; border-radius: 10px; font-size: 0.85rem; font-weight: 600; color: var(--text-light); border: none; background: transparent; transition: all 0.2s; cursor: pointer; }
.segment-btn.active { background: var(--card); color: var(--text); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* === Matrix Grid UI === */
.matrix-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.badge { padding: 4px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: 700; background: var(--primary-bg); color: var(--primary-dark); }
.badge-warning { background: #fef3c7; color: #92400e; }

.matrix-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 20px; }
.matrix-box { aspect-ratio: 1; border: 2px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--card); position: relative; padding: 4px; text-align: center; transition: all 0.2s; cursor: pointer; }
.matrix-box.checked { background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 4px 10px rgba(15, 118, 110, 0.2); }

.matrix-box.ujian { border-color: var(--secondary); background: #fffbeb; grid-column: span 5; aspect-ratio: auto; padding: 16px; flex-direction: row; justify-content: space-between; }
.matrix-box.ujian.checked { background: var(--secondary); border-color: var(--secondary); }

.matrix-box-number { font-size: 0.85rem; font-weight: 700; }
.matrix-box-name { font-size: 0.6rem; line-height: 1.2; font-weight: 500; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 2px; }
.matrix-box-kategori { font-size: 0.55rem; opacity: 0.9; margin-top: 2px; background: rgba(0,0,0,0.15); padding: 2px 4px; border-radius: 4px; display: inline-block; white-space: nowrap; overflow: hidden; max-width: 90%; text-overflow: ellipsis;}
.matrix-box.checked .matrix-box-name { opacity: 0.9; }

.matrix-box-nilai { position: absolute; top: -6px; right: -6px; font-size: 0.65rem; font-weight: 700; background: var(--card); color: var(--text); padding: 2px 6px; border-radius: 8px; border: 1px solid var(--border); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.matrix-box.checked .matrix-box-nilai { color: var(--primary); border-color: var(--primary-bg); }

.matrix-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 0.75rem; color: var(--text-light); font-weight: 500; justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-box { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--border); }
.legend-box.checked { background: var(--primary); border-color: var(--primary); }

/* === Bottom Sheet Modals === */
.overlay-bg { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.4); z-index: 1000; backdrop-filter: blur(2px); opacity: 0; transition: opacity 0.3s; }
.overlay-bg.active { display: block; opacity: 1; }
.bottom-sheet { position: fixed; bottom: -100%; left: 0; width: 100%; background: var(--card); border-radius: 28px 28px 0 0; padding: 24px; z-index: 1001; transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 -10px 40px rgba(0,0,0,0.1); max-height: 90vh; overflow-y: auto; }
.bottom-sheet.active { bottom: 0; }
.sheet-drag-handle { width: 40px; height: 5px; background: var(--border); border-radius: 10px; margin: 0 auto 20px auto; }
.sheet-title { font-size: 1.25rem; font-weight: 700; text-align: center; margin-bottom: 4px; color: var(--text); }
.sheet-subtitle { font-size: 0.85rem; color: var(--text-light); text-align: center; margin-bottom: 24px; }

/* === Slider Input Nilai === */
.popup-nilai-display { text-align: center; font-size: 3.5rem; font-weight: 800; color: var(--primary); margin: 10px 0; font-variant-numeric: tabular-nums; }
.nilai-slider { width: 100%; margin: 20px 0; -webkit-appearance: none; height: 8px; border-radius: 4px; background: var(--border); outline: none; }
.nilai-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); border: 4px solid white; cursor: pointer; box-shadow: 0 2px 8px rgba(15, 118, 110, 0.4); }
.nilai-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 30px; }

/* === Alerts & Empty states === */
.inline-alert { padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; font-weight: 600; font-size: 0.85rem; display: none; align-items: center; gap: 8px; animation: slideDown 0.3s ease; }
.inline-alert.show { display: flex; }
.inline-alert.success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.inline-alert.warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { color: var(--text-light); font-size: 0.9rem; font-weight: 500; }

/* === Loading Overlay Animation === */
.loading-overlay { 
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    background: var(--bg); 
    z-index: 9999; 
    display: none; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    animation: fadeIn 0.3s ease; 
}
.loading-overlay.active { display: flex; }
.spinner { 
    width: 50px; height: 50px; 
    border: 5px solid var(--border); 
    border-top-color: var(--primary); 
    border-radius: 50%; 
    animation: spin 1s linear infinite; 
    margin-bottom: 20px; 
}
.loading-title { font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }
.loading-text { font-size: 0.9rem; color: var(--text-light); font-weight: 500; }

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

.matrix-box.disabled { opacity: 0.55; cursor: not-allowed; background: #f8fafc; color: var(--text-light); }
.matrix-box.disabled .matrix-box-name,
.matrix-box.disabled .matrix-box-number { color: var(--text-light); }
