/* Variables & Theming */
:root {
    /* Light Mode Colors (Notion inspired, extremely clean) */
    --bg-main: #ffffff;
    --bg-sidebar: #f7f7f5;
    --bg-hover: #efefed;
    --bg-modal: #ffffff;
    --bg-overlay: rgba(15, 15, 15, 0.4);
    
    --text-primary: #37352f;
    --text-secondary: #787774;
    --text-muted: #9b9a97;
    
    --border-color: #ededeb;
    --accent-color: #2eaadc;
    --accent-hover: #1e87b4;
    --error-color: #eb5757;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif;
    
    --sidebar-width: 260px;
    --transition-speed: 0.2s;
}



/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden; /* App takes full height */
}

/* Base styles / Editor reset */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; }
p { line-height: 1.6; }
a { color: var(--text-primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }

/* Layout Grid */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    transition: width var(--transition-speed);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    margin-bottom: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.brand-icon {
    font-size: 20px;
}

.sidebar-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
}

.sidebar-search {
    padding: 0 16px 12px 16px;
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition-speed);
}

.sidebar-search input:focus { 
    border-color: var(--accent-color); 
}

.search-icon {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-muted);
    margin-top: -6px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px;
    margin-bottom: 4px;
}

.page-list {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 400; /* Reduced from 500 */
    cursor: pointer;
    transition: background-color var(--transition-speed);
    margin-bottom: 2px;
}

.nav-item:hover {
    background-color: var(--bg-hover);
}

.nav-item.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500; /* Softened bold */
}

.nested-item {
    /* Indentation is handled dynamically by JS */
    border-radius: var(--radius-sm);
}

.folder-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px; /* Increased from 11px */
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 12px;
    margin-top: 8px; /* Reduced from 16px */
    cursor: default;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.folder-title:first-child {
    margin-top: 0;
}

.folder-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.folder-actions {
    display: flex;
    gap: 4px;
}

.mini-btn {
    padding: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.folder-title:hover .mini-btn {
    opacity: 1;
}

.folder-title .folder-icon {
    font-size: 14px;
}

.nav-item .material-icons-outlined {
    font-size: 18px;
}

/* Drag and Drop features */
.nav-item[draggable="true"] {
    cursor: grab;
}

.nav-item[draggable="true"]:active {
    cursor: grabbing;
}

.folder-title.drag-over {
    background-color: var(--bg-hover);
    border-radius: var(--radius-sm);
    color: var(--accent-color);
    box-shadow: inset 0 0 0 1px var(--accent-color);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background var(--transition-speed);
}
.login-btn:hover { background-color: var(--bg-hover); }

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-main);
}

.content-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

#current-page-crumb {
    color: var(--text-primary);
    font-weight: 500;
}

.content-actions {
    display: flex;
    gap: 8px;
}

/* Page Area */
.page-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px 10%;
    scroll-behavior: smooth;
}

.page-title {
    font-size: 40px;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-body {
    font-size: 16px;
    color: var(--text-primary);
    line-height: 1.7;
    padding: 0;
}

/* Editor Specifics */
.page-title-input {
    font-size: 40px;
    font-weight: 700;
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.editor-header-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.page-icon-input {
    font-size: 40px;
    width: 50px;
    background: transparent;
    border: none;
    outline: none;
    text-align: center;
}

.page-emoji {
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; /* Matches material icons size better */
    margin-left: -3px;
}

.page-title-input::placeholder {
    color: var(--text-muted);
}

.quill-container {
    font-size: 16px;
    border: none !important;
}
.ql-toolbar {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background-color: var(--bg-sidebar);
}
.ql-container {
    border: 1px solid var(--border-color) !important;
    border-top: none !important;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    min-height: 300px;
}


/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-speed);
}

.btn.primary {
    background-color: var(--accent-color);
    color: white;
}

.btn.primary:hover {
    background-color: var(--accent-hover);
}

.btn.secondary {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn.danger {
    background-color: #fee2e2;
    color: #ef4444;
}

.btn.danger:hover {
    background-color: #fecaca;
    color: #dc2626;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: background var(--transition-speed);
}
.icon-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}
.icon-btn .material-icons-outlined { font-size: 18px; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}
.modal.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: var(--bg-overlay);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    background-color: var(--bg-modal);
    padding: 32px;
    border-radius: var(--radius-lg);
    width: 360px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 14px;
}
.modal input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(46, 170, 220, 0.2);
}

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

.error-msg {
    color: var(--error-color);
    font-size: 13px;
    margin-bottom: 16px;
    margin-top: -8px;
}

/* Utilities */
.hidden { display: none !important; }

/* Skeleton */
.skeleton-loader {
    width: 100%;
    height: 20px;
    background: linear-gradient(110deg, var(--bg-hover) 8%, var(--border-color) 18%, var(--bg-hover) 33%);
    border-radius: 4px;
    background-size: 200% 100%;
    animation: 1.5s shine linear infinite;
    margin-bottom: 12px;
}
.skeleton-loader:nth-child(2) { width: 80%; }
.skeleton-loader:nth-child(3) { width: 90%; }
@keyframes shine {
    to { background-position-x: -200%; }
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}
.toast {
    background-color: var(--bg-modal);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--accent-color);
    font-size: 14px;
    animation: toastIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 12px;
}
.toast.success { border-color: #10b981; }
.toast.error { border-color: var(--error-color); }
@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Mobile Responsiveness */
.mobile-only { display: none; }

@media (max-width: 768px) {
    .app-container { position: relative; overflow-x: hidden; }
    .sidebar {
        position: absolute;
        left: -260px; /* Instead of -100% since width is var(--sidebar-width) which is 260px */
        height: 100%;
        z-index: 100;
        box-shadow: var(--shadow-lg);
        transition: left 0.3s ease;
    }
    .sidebar.open { left: 0; }
    .mobile-only { display: flex; }
    .content-header { padding: 0 12px; }
    .page-area { padding: 24px 16px; /* more space on mobile */ }
    
    .page-title, .page-title-input { font-size: 28px; margin-bottom: 24px; }
    .page-icon-input { font-size: 28px; width: 40px; }
    
    .content-actions .btn { padding: 6px 10px; font-size: 12px; }
    .content-actions .btn span { font-size: 16px; }
}
/* Custom Modal System */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-overlay);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.2s ease;
}

.custom-modal-content {
    background-color: var(--bg-modal);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    padding: 24px;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-modal-content h3 {
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.custom-modal-content p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
}

.custom-modal-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-hover);
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.2s;
}

.custom-modal-input:focus {
    border-color: var(--accent-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

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

/* Emoji Picker & Image Upload */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.title-with-icon {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.icon-selector-container {
    position: relative;
    display: flex;
    align-items: center;
}

#btn-emoji-picker {
    position: absolute;
    right: -10px;
    top: -10px;
    background: var(--bg-modal);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 4px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 0;
}

.emoji-item {
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-item:hover {
    background-color: var(--bg-hover);
}

.emoji-picker-content {
    max-width: 360px;
}
