/* 1. Variabel CSS (Palet Warna) */
:root {
    /* Light Mode */
    --bg-color: #f0f2f5;
    --container-bg: rgba(255, 255, 255, 0.85);
    --sidebar-bg: rgba(245, 245, 247, 0.7);
    --border-color: rgba(200, 200, 200, 0.5);
    --text-color: #212529;
    --text-light: #6c757d;
    --shadow-base: 0 8px 32px rgba(0, 0, 0, 0.08);
    --blur-strength: 10px;
    --input-bg: rgba(0, 0, 0, 0.03);
    --primary-color: #007aff;
    --danger-color: #ff3b30;
}

/* Dark Mode (Class 'dark-mode' pada body) */
body.dark-mode {
    --bg-color: #1c1c1e;
    --container-bg: rgba(28, 28, 30, 0.8);
    --sidebar-bg: rgba(44, 44, 46, 0.7);
    --border-color: rgba(60, 60, 67, 0.7);
    --text-color: #f2f2f7;
    --text-light: #8e8e93;
    --shadow-base: 0 8px 32px rgba(0, 0, 0, 0.3);
    --input-bg: rgba(255, 255, 255, 0.08);
    --primary-color: #0a84ff;
    --danger-color: #ff453a;
}

/* 2. Reset dasar dan gaya body */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 3. Kontainer utama (Glassmorphism) */
.container {
    width: 100%;
    max-width: 1100px;
    height: 85vh; /* Tinggi agar terlihat seperti aplikasi desktop */
    min-height: 500px;
    background: var(--container-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-base);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    display: flex;
    overflow: hidden; /* Penting untuk border-radius */
    position: relative;
}

/* 4. Tombol Dark Mode */
#dark-mode-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
#dark-mode-toggle:hover {
    background-color: var(--border-color);
}

/* 5. Sidebar (Daftar Catatan) */
.notes-list {
    flex: 0 0 300px; /* Lebar sidebar 300px */
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease;
}

.list-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}
.list-header h2 {
    font-size: 24px;
    font-weight: 700;
}
#add-note-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}
#add-note-btn:hover {
    background-color: rgba(0, 122, 255, 0.1);
}

.notes-list-items {
    overflow-y: auto;
    flex: 1;
}
.note-list-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.note-list-item:hover {
    background-color: var(--input-bg);
}
.note-list-item.active {
    background-color: var(--primary-color);
    color: #fff;
}
.note-list-item h3 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}
.note-list-item p {
    font-size: 14px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-list-item.active p {
    color: rgba(255, 255, 255, 0.8);
}

/* 6. Editor Utama */
.notes-editor {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
}
/* Sembunyikan editor jika tidak ada catatan dipilih */
.notes-editor:not(.active) {
    display: none;
}

#note-title-input {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background: transparent;
    border: none;
    outline: none;
    padding: 0;
    margin-bottom: 20px;
}
#note-title-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

#note-content-input {
    flex: 1; /* Mengisi sisa ruang */
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: transparent;
    border: none;
    outline: none;
    resize: none; /* Matikan resize handle */
}
#note-content-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

#delete-note-btn {
    background: transparent;
    border: none;
    color: var(--danger-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    margin-top: 20px;
    align-self: flex-start; /* Posisikan di kiri bawah */
    transition: background-color 0.2s ease;
}
#delete-note-btn:hover {
    background-color: rgba(255, 59, 48, 0.1);
}

/* 7. Logika Responsif (Mobile) */
.mobile-only {
    display: none; /* Sembunyikan di desktop */
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 20px;
    align-self: flex-start;
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    .container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        min-height: 0;
    }
    .notes-list {
        flex: 1; /* Ambil lebar penuh */
        border-right: none;
    }
    .notes-editor {
        /* Sembunyikan editor */
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 5;
        background-color: var(--container-bg); /* Beri background solid */
    }
    /* Tampilkan editor jika 'active' */
    .notes-editor.active {
        display: flex;
    }
    /* Sembunyikan list jika editor 'active' */
    .notes-editor.active + .notes-list {
        display: none;
    }
    /* Tampilkan tombol kembali di mobile */
    .mobile-only {
        display: block;
    }
    #dark-mode-toggle {
        top: 15px;
        right: 15px;
    }
    .list-header {
        padding: 20px;
        padding-right: 70px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
    }
    .notes-editor {
        padding: 20px;
    }
}