:root {
    --apple-yellow: #edae41;
    --bg-dark: #1e1e1e;
    --bg-darker: #191919;
    --border-dark: #333333;
    --bg-hover: #2d2d2d;
    --bg-active: #3a3a3c;
    --text-primary: #ffffff;
    --text-secondary: #999999;
    --text-muted: #666666;
    
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-stack);
    color: var(--text-primary);
    background-color: var(--bg-dark);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    /* 3 Column default */
    grid-template-columns: 220px 300px 1fr;
    height: 100vh;
    transition: grid-template-columns 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.app-container.note-active {
    /* Shrink the first column slightly when a note is active */
    grid-template-columns: 160px 300px 1fr;
}

/* Base button styles */
button {
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-stack);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.icon-btn {
    font-size: 20px;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.1s;
    color: var(--text-secondary);
}

.icon-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.tool-btn {
    padding: 4px 8px;
    border-radius: 6px;
}
.tool-btn.active {
    background-color: var(--bg-active);
    color: var(--text-primary);
}

/* =========================================
   COL 1: SIDEBAR FOLDERS
========================================= */
.sidebar-folders {
    background-color: var(--bg-darker);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
}

.folder-header-top {
    height: 52px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: relative;
}

.mac-buttons {
    display: flex;
    gap: 8px;
}
.mac-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.mac-btn.close { background-color: #ff5f56; }
.mac-btn.min { background-color: #ffbd2e; }
.mac-btn.max { background-color: #27c93f; }

#toggleSidebarBtn {
    position: absolute;
    right: 8px;
}

.folder-list-content {
    flex: 1;
    overflow-y: auto;
    padding-top: 10px;
}

.folder-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 4px 16px;
    text-transform: uppercase;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 28px; /* indent */
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
}

.folder-item i {
    color: var(--text-secondary);
    font-size: 16px;
}

.folder-item.active {
    background-color: var(--bg-active);
    color: var(--apple-yellow);
}

.folder-delete-btn {
    position: absolute;
    right: 12px;
    font-size: 14px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    display: none;
    padding: 2px;
}

.folder-delete-btn:hover {
    color: #ff5f56;
}

.folder-item:hover .folder-delete-btn {
    display: block;
}

.folder-item:hover:not(.active) {
    background-color: var(--bg-hover);
}

.folder-item.drag-over {
    background-color: var(--apple-yellow);
    color: #1a1a1a;
}
.folder-item.drag-over i {
    color: #1a1a1a;
}

.folder-footer {
    height: 40px;
    display: flex;
    align-items: center;
    padding: 0 16px;
}


/* =========================================
   COL 2: NOTES LIST PANE
========================================= */
.notes-list-pane {
    background-color: var(--bg-dark);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
}

.notes-list-header {
    height: 52px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.header-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title h4 {
    font-size: 14px;
    font-weight: 600;
}

.header-title .subtitle {
    font-size: 11px;
    color: var(--text-secondary);
}

.notes-list {
    flex: 1;
    overflow-y: auto;
}

.note-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-dark);
    cursor: pointer;
}

.note-card:last-child {
    border-bottom: none;
}

.note-card.active {
    background-color: var(--apple-yellow);
    border-radius: 6px;
    margin: 4px 8px;
    padding: 8px 8px;
    border-bottom: none;
}
/* Sub elements color change when active */
.note-card.active h3, .note-card.active .note-meta, .note-card.active .time, .note-card.active .note-folder i, .note-card.active .note-folder {
    color: #1a1a1a !important; /* Dark text on yellow background */
}

.note-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-meta {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.note-meta .time {
    color: var(--text-primary);
    margin-right: 6px;
}

.note-folder {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* =========================================
   COL 3: EDITOR
========================================= */
.editor-pane {
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-dark);
}

.editor-header {
    height: 52px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    position: relative;
}

.toolbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
}

.toolbar-right {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-left: auto;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-hover);
    border-radius: 6px;
    padding: 4px 8px;
    width: 200px;
    border: 1px solid var(--border-dark);
}

.search-bar i {
    color: var(--text-secondary);
    font-size: 14px;
    margin-right: 6px;
}

.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 13px;
    color: var(--text-primary);
}

.editor-content-area {
    flex: 1;
    padding: 0 60px 40px;
    overflow-y: auto;
    transition: opacity 0.2s;
}

.editor-date-right {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 40px;
    padding-top: 10px;
}

.editor-body {
    font-size: 15px;
    line-height: 1.6;
    outline: none;
    min-height: 500px;
}

.editor-body[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-muted);
}

/* Rich Text Styles */
.editor-body h1 { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.editor-body h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; margin-top: 16px; }
.editor-body h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; margin-top: 12px; }
.editor-body p { margin-bottom: 8px; min-height: 1lh; }
.editor-body blockquote { border-left: 3px solid var(--apple-yellow); padding-left: 12px; color: var(--text-secondary); margin: 12px 0; }
.editor-body pre { font-family: monospace; background-color: var(--bg-hover); padding: 12px; border-radius: 6px; margin: 12px 0; }
.editor-body ul, .editor-body ol { margin-left: 24px; margin-bottom: 12px; }
.editor-body b { font-weight: 700; }
.editor-body i { font-style: italic; }
.editor-body u { text-decoration: underline; }
.editor-body s { text-decoration: line-through; }


/* =========================================
   POPOVER & MODAL
========================================= */
.format-popover {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2b2b2d;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    width: 220px;
    z-index: 100;
    display: none;
    flex-direction: column;
}

.format-popover.show { display: flex; }

.popover-top-tools {
    display: flex;
    padding: 8px;
    border-bottom: 1px solid #444;
    justify-content: space-between;
    align-items: center;
}

.popover-top-tools button { width: 28px; height: 28px; border-radius: 4px; font-size: 15px; color: var(--text-secondary); }
.popover-top-tools button:hover { background-color: rgba(255,255,255,0.1); color: white; }
.popover-top-tools button:first-child b { color: var(--apple-yellow); background-color: rgba(237, 174, 65, 0.15); border-radius: 4px; padding: 4px; display: inline-block; width: 100%; }
.color-picker-dot { width: 12px; height: 12px; background-color: #ff3b30; border-radius: 50%; margin-left: 4px; }
.popover-list { display: flex; flex-direction: column; padding: 6px 0; }
.popover-list button { padding: 8px 16px; justify-content: flex-start; font-size: 14px; color: var(--text-primary); }
.popover-list button:hover { background-color: rgba(255,255,255,0.1); }
.popover-list button.has-check::before { content: '✓'; margin-right: 8px; font-size: 12px; opacity: 0; }
.popover-list button.has-check.active::before { opacity: 1; }
.popover-list .divider { height: 1px; background-color: #444; margin: 6px 0; }

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }

.modal {
    background-color: var(--bg-hover);
    padding: 24px;
    border-radius: 12px;
    width: 300px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border: 1px solid var(--border-dark);
}
.modal h3 { margin-bottom: 8px; font-size: 16px; font-weight: 600; }
.modal p { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.modal input {
    width: 100%; padding: 8px; border-radius: 6px;
    border: 1px solid var(--border-dark);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    outline: none; margin-bottom: 16px; font-size: 14px;
}
.modal input:focus { border-color: var(--apple-yellow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button { padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.btn-cancel { background-color: var(--border-dark); color: white; }
.btn-cancel:hover { background-color: #444; }
.btn-primary { background-color: var(--apple-yellow); color: #000; }
.btn-primary:hover { background-color: #df9e30; }

/* Trash Banner */
.trash-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #2b2b2d;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-dark);
    margin-bottom: 10px;
}

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

.trash-banner-text i {
    color: var(--apple-yellow);
    font-size: 18px;
}

.trash-banner-actions {
    display: flex;
    gap: 12px;
}

.trash-banner-actions button {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.btn-danger {
    background-color: #ff3b30;
    color: white;
}

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

/* Auth / Admin Mode CSS */
body:not(.admin-mode) .admin-only {
    display: none !important;
}

body:not(.admin-mode) .folder-delete-btn {
    display: none !important;
}
