:root {
    --bg: #f7f7f7;
    --card: white;
    --text: #222;
    --subtext: gray;
    --accent: #9b00ff;
    --pink: #ff3fa4;
    --border: #e6e6e6;
    --cat-tugas: #6366f1;
    --cat-ujian: #ef4444;
    --cat-project: #10b981;
}

body.dark {
    --bg: #1b1b1b;
    --card: #2a2a2a;
    --text: #ffffff;
    --subtext: #cfcfcf;
    --border: #3a3a3a;
}

body {
    margin: 0;
    font-family: "Poppins", sans-serif;
    background: var(--bg);
    display: flex;
    justify-content: center;
    transition: 0.3s ease;
}

.app-container {
    width: 100%;
    max-width: 420px;
    height: 100vh;
    border-radius: 20px;
    background: var(--bg);
    position: relative;
    transition: 0.3s ease;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.app-header {
    padding: 16px;
    background: var(--bg);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 100px 16px;
    position: relative;
}

.app-content::after {
    content: "";
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to top, var(--bg), transparent);
    pointer-events: none;
    z-index: 15;
    max-width: 420px;
    left: 50%;
    transform: translateX(-50%);
}

@media (max-width: 480px) {
    .app-container {
        border-radius: 0;
    }

    .app-header {
        padding: 12px;
    }

    .app-content {
        padding: 0 12px 100px 12px;
    }
}

/* HEADER */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    margin-bottom: 16px;
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.toggle-dark {
    background: var(--card);
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text);
    font-size: 18px;
}

/* SEARCH */
.search-box {
    background: var(--card);
    padding: 12px 15px;
    border-radius: 12px;
    margin-top: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    color: var(--text);
}

.search-box input {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
}

.search-box input::placeholder {
    color: var(--subtext);
}

/* FILTER */
.filter-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.filter-group::-webkit-scrollbar {
    height: 4px;
}

.filter-group::-webkit-scrollbar-track {
    background: transparent;
}

.filter-group::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.filter-btn {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    font-size: 13px;
    transition: 0.2s ease;
    flex-shrink: 0;
}

.filter-btn:active {
    transform: scale(0.96);
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

#filterContainer {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.add-category-btn {
    padding: 8px 12px;
    border-radius: 20px;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.add-category-btn:active {
    transform: scale(0.96);
}

/* Category Modal */
.category-modal-bg {
    position: fixed;
    top: 0;
    width: 100%;
    height: 100%;
    background: #00000070;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    z-index: 1002;
    padding: 20px;
}

.category-modal {
    background: var(--card);
    border-radius: 20px;
    padding: 24px;
    max-width: 350px;
    width: 100%;
    color: var(--text);
    animation: scaleIn 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.category-modal-header {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.category-form-group {
    margin-bottom: 16px;
}

.category-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--subtext);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.category-form-group input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
}

.color-picker-wrapper {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: 0.2s ease;
}

.color-option:active {
    transform: scale(0.9);
}

.color-option.selected {
    border-color: var(--text);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
}

.category-modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.category-modal-buttons button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s ease;
}

.category-modal-buttons .btn-cancel {
    background: var(--border);
    color: var(--text);
}

.category-modal-buttons .btn-add {
    background: var(--accent);
    color: white;
}

.category-modal-buttons button:active {
    transform: scale(0.96);
}

.filter-btn.cat-tugas { border-color: var(--cat-tugas); }
.filter-btn.cat-tugas.active { background: var(--cat-tugas); border-color: var(--cat-tugas); }

.filter-btn.cat-ujian { border-color: var(--cat-ujian); }
.filter-btn.cat-ujian.active { background: var(--cat-ujian); border-color: var(--cat-ujian); }

.filter-btn.cat-project { border-color: var(--cat-project); }
.filter-btn.cat-project.active { background: var(--cat-project); border-color: var(--cat-project); }
.stats {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 20px;
}

.stat-card {
    flex: 1;
    background: var(--card);
    padding: 14px 10px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
    transition: 0.25s ease;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
}

.stat-card:active {
    transform: translateY(-2px);
}

.stat-card.active {
    color: white;
    border-color: transparent;
}

.stat-card.active .stat-number,
.stat-card.active .stat-label {
    color: white;
}

/* Colored stat states */
.stat-card.stat-total.active {
    background: var(--accent);
    border-color: var(--accent);
}

.stat-card.stat-done.active {
    background: #10b981;
    border-color: #10b981;
}

.stat-card.stat-notdone.active {
    background: #f59e0b;
    border-color: #f59e0b;
}

.stat-card.stat-important.active {
    background: #ef4444;
    border-color: #ef4444;
}

.stat-number {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent);
}

.stat-label {
    font-size: 11px;
    color: var(--subtext);
    margin-top: 6px;
}

/* TASK LIST */
.task-item {
    background: var(--card);
    padding: 14px 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    color: var(--text);
    transition: 0.15s ease;
    gap: 10px;
}

.task-item:active {
    transform: scale(0.98);
}

.task-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.task-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.task-edit-btn {
    cursor: pointer;
    font-size: 18px;
    transition: transform 0.15s ease;
}

.task-edit-btn:active {
    transform: scale(0.9);
}

.task-category-badge {
    width: 4px;
    height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
}

.task-category-badge.cat-tugas { background: var(--cat-tugas); }
.task-category-badge.cat-ujian { background: var(--cat-ujian); }
.task-category-badge.cat-project { background: var(--cat-project); }

.task-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.2s ease;
}

.task-check:active {
    transform: scale(0.9);
}

.task-check.done {
    background: var(--accent);
    border-color: var(--accent);
}

.task-title {
    color: var(--text);
    word-break: break-word;
    flex: 1;
}

.task-title.done {
    text-decoration: line-through;
    color: var(--subtext);
    opacity: 0.7;
}

.task-title > div {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
}

/* DONE TASK STYLING */
.task-item.done {
    background: linear-gradient(135deg, var(--card) 0%, rgba(16, 185, 129, 0.05) 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.task-item.done::after {
    content: "✓ SELESAI";
    position: absolute;
    top: 4px;
    right: 4px;
    background: #10b981;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* IMPORTANT TASK STYLING (Not Done) */
.task-item.important:not(.done) {
    border-left: 4px solid #ff3fa4;
    background: linear-gradient(135deg, var(--card) 0%, rgba(255, 63, 164, 0.05) 100%);
    box-shadow: 0 2px 8px rgba(255, 63, 164, 0.15);
}

.task-item.important:not(.done)::before {
    content: "⭐ PENTING";
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ff3fa4;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* IMPORTANT + DONE (Selesai mengambil prioritas warna) */
.task-item.important.done {
    border-left: 4px solid #10b981;
    background: linear-gradient(135deg, var(--card) 0%, rgba(16, 185, 129, 0.05) 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.task-item.important.done::before {
    content: "⭐ PENTING";
    position: absolute;
    top: 4px;
    right: 72px;
    background: #10b981;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.task-item.important:not(.done) .task-title {
    font-weight: 600;
}

.empty-text {
    color: var(--text);
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
}

.main-add-btn {
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--pink);
    text-align: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    border: none;
    margin: 0;
    transition: 0.15s ease;
    position: fixed;
    bottom: 16px;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.main-add-btn:active {
    transform: scale(0.98);
}

@media (max-width: 480px) {
    .main-add-btn {
        bottom: 12px;
    }
}

/* BOTTOM SHEET */
.bottom-sheet-bg {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #00000070;
    display: none;
    justify-content: center;
    align-items: flex-end;
    backdrop-filter: blur(5px);
    z-index: 999;
}

.bottom-sheet {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    animation: slideUp 0.25s ease;
    color: var(--text);
    box-sizing: border-box;
    z-index: 1000;
    position: relative;
}

/* DETAIL MODAL */
.detail-modal-bg {
    position: fixed;
    top: 0;
    width: 100%;
    height: 100%;
    background: #00000070;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    z-index: 1001;
    padding: 20px;
}

.detail-modal {
    background: var(--card);
    border-radius: 20px;
    padding: 24px;
    max-width: 380px;
    width: 100%;
    color: var(--text);
    animation: scaleIn 0.3s ease;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.detail-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    word-break: break-word;
}

.detail-close {
    cursor: pointer;
    font-size: 24px;
    color: var(--subtext);
    transition: 0.2s ease;
    margin: -8px -8px 0 0;
    padding: 8px;
}

.detail-close:active {
    transform: rotate(90deg);
}

.detail-item {
    background: var(--bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.detail-item-label {
    font-size: 12px;
    color: var(--subtext);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 6px;
}

.detail-item-content {
    font-size: 15px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-category-badge {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.detail-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
}

.detail-status.done {
    background: #d1fae5;
    color: #065f46;
}

.detail-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.detail-status.important {
    background: #fee2e2;
    color: #991b1b;
}

.detail-note {
    background: var(--bg);
    border-radius: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.sheet-header { 
    display: flex; 
    justify-content: space-between;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 15px;
}

.sheet-close { 
    cursor: pointer;
    font-size: 20px;
}

.sheet-body input,
.sheet-body select,
.sheet-body textarea {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.sheet-body label {
    display: block;
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
}

.sheet-body {
    width: 100%;
    box-sizing: border-box;
}

.sheet-body input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.sheet-save {
    width: 100%;
    margin-top: 15px;
    padding: 12px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    border: none;
    font-weight: 600;
    transition: 0.15s ease;
}

.sheet-save:active {
    transform: scale(0.98);
}

/* ANIMATIONS */
.fade-in {
    animation: fadeIn 0.4s ease both;
}

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

.btn-press {
    transition: 0.15s ease;
}

.btn-press:active {
    transform: scale(0.96);
}

/* RIPPLE EFFECT */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple:after {
    content: "";
    position: absolute;
    background: #ffffff40;
    width: 5px;
    height: 5px;
    opacity: 0;
    border-radius: 50%;
    transform: scale(1);
    transition: 0s;
}

.ripple:active:after {
    opacity: 1;
    transform: scale(40);
    transition: 0.6s ease-out;
    top: var(--ripple-y);
    left: var(--ripple-x);
}