:root {
    /* === WARNA TEMA UTAMA === */
    --primary-color: #42b72a;    
    --primary-hover: #36a420;
    --action-color: #1877f2;     
    --action-hover: #166fe5;
    --danger-color: #ff4d4d;     
    --danger-hover: #ff1a1a;
    --pin-color: #f1c40f;        

    /* === WARNA LATAR BELAKANG === */
    --bg-sidebar: #1c1e21;
    --bg-note: #242526;
    --bg-note-hover: #3a3b3c;
    --bg-pinned: #2c2b26;
    --bg-pinned-hover: #3d3b32;
    
    /* === FORM & OVERLAY === */
    --bg-main-overlay: rgba(255, 255, 255, 0.3);
    --bg-form: rgba(255, 255, 255, 0.85);

    /* === TEKS === */
    --text-light: #ffffff;
    --text-dark: #333333;
    --text-muted: #b0b3b8;
    --text-preview: #cccccc;

    /* === SETTING UMUM === */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-family);
    margin: 0;
    display: flex;
    height: 100vh;
    color: var(--text-dark);
    background-image: url('../img/bg-notes.jpg'); 
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed; 
    overflow: hidden;
    font-size: 14px;
}

input, textarea, select, button { font-family: var(--font-family); }

/* LOGIN & REGISTER */
.login-wrapper { display: flex; justify-content: center; align-items: center; width: 100%; padding: 15px;}
.login-container {
    background: var(--bg-form); padding: 30px; border-radius: var(--radius-lg);
    box-shadow: 0 4px 25px rgba(0,0,0,0.2); width: 100%; max-width: 400px; text-align: center;
}
.login-container h2 { margin-top: 0; color: var(--text-dark); font-size: 24px; margin-bottom: 20px; }

.msg { padding: 10px; border-radius: 6px; margin-bottom: 15px; font-size: 14px; text-align: left; }
.error-msg { background: #ffe6e6; color: var(--danger-color); border: 1px solid #ffcccc; }
.success-msg { background: #e6ffe6; color: var(--primary-color); border: 1px solid #ccffcc; }

/* SIDEBAR (GLASSMORPHISM) */
.sidebar { 
    width: 25%; min-width: 260px; max-width: 320px; 
    height: calc(100vh - 40px); 
    margin: 20px 0 20px 20px;   
    border-radius: 16px;        
    display: flex; flex-direction: column; 
    box-sizing: border-box; 
    background: rgba(28, 30, 33, 0.75); 
    backdrop-filter: blur(15px);        
    -webkit-backdrop-filter: blur(15px); 
    border: 1px solid rgba(255, 255, 255, 0.08); 
    box-shadow: 0 10px 30px rgba(0,0,0,0.4); 
    padding: 20px 15px;
}

.note-list { flex: 1; overflow-y: auto; padding-right: 5px; list-style: none; padding-left:0; margin:0; }
.note-list::-webkit-scrollbar { width: 6px; }
.note-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.note-item { 
    position: relative; padding-bottom: 12px; padding-top: 12px; 
    background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05); 
    margin-bottom: 10px; border-radius: 8px; padding: 12px;
}
.note-pinned { border-left: 3px solid var(--pin-color); } 

.action-buttons {
    position: absolute; right: 10px; top: 12px; display: flex; gap: 4px !important; 
    align-items: center; background: rgba(0,0,0, 0.4); padding: 2px 5px; border-radius: 6px;
}
.btn-icon { font-size: 15px; text-decoration: none; opacity: 0.8; transition: 0.2s;}
.btn-icon:hover { opacity: 1; transform: scale(1.1); }

/* FOOTER SIDEBAR (LANGUAGE & LOGOUT ICON) */
.sidebar-footer {
    margin-top: 15px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: flex-start; gap: 10px; align-items: center;
}

.icon-select, .logout-icon-btn {
    width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; text-decoration: none; transition: 0.2s; margin: 0;
}

.icon-select {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: #fff; font-size: 18px; cursor: pointer; outline: none; font-family: 'Segoe UI Emoji', Arial;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    text-align: center; text-align-last: center; padding: 0;
}
.icon-select option { color: #333; }
.icon-select:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }

.logout-icon-btn {
    color: #ff4d4d; background: rgba(255, 77, 77, 0.15); border: 1px solid rgba(255, 77, 77, 0.3);
}
.logout-icon-btn:hover { background: #ff4d4d; color: #fff; transform: scale(1.05); }

/* MAIN CONTENT */
.main-content { 
    flex: 1; height: 100vh; box-sizing: border-box; padding: 20px; 
    display: flex; flex-direction: column; overflow: hidden; 
}

.content-wrapper { 
    flex: 1; display: flex; gap: 25px; align-items: stretch; 
    max-width: 1000px; margin: 0 auto; width: 100%; overflow: hidden; 
}

/* FOLDER COLUMN */
.folder-column { 
    width: 210px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; 
    overflow-y: auto; padding-right: 5px;
}
.folder-column::-webkit-scrollbar { width: 4px; }
.folder-column::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.folder-item-wrapper { display: flex; gap: 5px; align-items: stretch; }
.folder-actions { display: none; flex-direction: column; gap: 4px; justify-content: center; }
.folder-item-wrapper:hover .folder-actions { display: flex; }

.folder-btn {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: 10px; text-decoration: none; color: #333; 
    background: rgba(255, 255, 255, 0.75); 
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6); font-weight: 600;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); transition: all 0.2s ease;
}
.folder-btn:hover {
    transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.1); 
    background: rgba(255, 255, 255, 0.95); border-color: var(--primary-color);
}
.folder-btn.active {
    background: linear-gradient(135deg, rgba(66, 183, 42, 0.85), rgba(54, 164, 32, 0.85)); 
    color: #fff; border: 1px solid rgba(255,255,255,0.2); 
    box-shadow: 0 6px 15px rgba(66, 183, 42, 0.35);
}

/* --- KOD BARU: BUTANG NEW NOTE (INLINE & HIJAU) --- */
.btn-new-note {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover)) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(66, 183, 42, 0.3) !important;
    justify-content: center;
}
.btn-new-note:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 15px rgba(66, 183, 42, 0.4) !important;
}
.new-note-text { display: inline; }

.folder-icon { font-size: 17px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1)); }

.folder-action-btn {
    background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.5); border-radius: 6px; padding: 6px;
    cursor: pointer; font-size: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: background 0.2s;
}
.folder-action-btn:hover { background: #fff; }

/* EDITOR COLUMN */
.editor-column { flex: 1; width: 100%; display: flex; flex-direction: column; }

.custom-form-container {
    flex: 1; background: rgba(255, 255, 255, 0.80); 
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    padding: 25px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); 
    border: 1px solid rgba(255, 255, 255, 0.7); 
    overflow-y: auto; display: flex; flex-direction: column;
}

/* INPUTS & BUTTONS */
input, select {
    width: 100%; padding: 12px; margin-top: 8px; margin-bottom: 15px;
    border: 1px solid #ddd; border-radius: var(--radius); font-size: 16px; background: #f9f9f9;
}
.tox-tinymce { border-radius: var(--radius); border: 1px solid #ddd !important; margin-bottom: 15px; flex: 1; height: 100% !important;}

.btn { border: none; padding: 15px; width: 100%; border-radius: var(--radius); font-size: 16px; font-weight: bold; cursor: pointer; transition: 0.3s; color: var(--text-light); }
.btn-save { background: var(--primary-color); }
.btn-save:hover { background: var(--primary-hover); }
.btn-update { background: var(--action-color); }
.btn-update:hover { background: var(--action-hover); }

/* =========================================
   5. MOBILE HEADER & OFFCANVAS SIDEBAR
========================================= */
.mobile-header { display: none; }
.sidebar-overlay { display: none; }
.close-sidebar-btn { display: none; } 

@media (max-width: 992px) { 
    .sidebar { width: 30%; min-width: 220px; margin: 15px 0 15px 15px; } 
    .content-wrapper { flex-direction: column; }
    
    /* FOLDER COLUMN JADI MELINTANG */
    .folder-column { width: 100%; flex-direction: row; overflow-x: auto; padding-bottom: 15px; }
    .folder-btn { white-space: nowrap; }
    .folder-actions { display: flex !important; }

    /* HILANGKAN TEKS 'NEW NOTE' DI MOBILE */
    .new-note-text { display: none; }
    .btn-new-note { padding: 10px 14px; min-width: auto; border-radius: 10px; }
}

@media (max-width: 768px) {
    body { flex-direction: column; height: 100dvh; overflow-y: auto; overflow-x: hidden; padding: 0; }
    
    .mobile-header {
        display: flex; justify-content: space-between; align-items: center;
        padding: 12px 20px; background: rgba(28, 30, 33, 0.9);
        backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        position: sticky; top: 0; z-index: 900;
    }

    .hamburger-btn {
        background: transparent; border: none; color: #fff; font-size: 26px;
        cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center;
    }

    .sidebar { 
        position: fixed; top: 0; left: -100%; 
        width: 80%; max-width: 320px; height: 100dvh; 
        margin: 0; border-radius: 0; border-right: 1px solid rgba(255,255,255,0.1); 
        z-index: 1000; transition: left 0.3s ease;
    }
    .sidebar.show { left: 0; }

    .close-sidebar-btn {
        display: block; width: 100%; background: rgba(255, 77, 77, 0.15); color: #ff4d4d;
        border: 1px solid rgba(255, 77, 77, 0.3); padding: 12px; border-radius: 8px;
        margin-bottom: 15px; text-align: center; font-weight: bold; font-size: 14px;
        cursor: pointer; transition: 0.2s;
    }
    .close-sidebar-btn:hover { background: #ff4d4d; color: #fff; }

    .sidebar-overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100dvh;
        background: rgba(0,0,0,0.6); z-index: 999;
        backdrop-filter: blur(2px); opacity: 0; transition: opacity 0.3s;
        pointer-events: none; 
    }
    .sidebar-overlay.show { opacity: 1; pointer-events: auto; }

    .main-content { width: 100%; height: auto; min-height: calc(100dvh - 60px); overflow-y: visible; padding: 15px;}
    .content-wrapper { overflow: visible; height: auto; }
    
    .custom-form-container { min-height: 620px; overflow: visible; }
    .tox-tinymce { min-height: 520px !important; }
    
    .mobile-flex-col { flex-direction: column; }
    .mobile-w-full { width: 100% !important; margin-top: 10px; }
    
    .sidebar-brand-header { display: none !important; }
}