/* ============================================================
   Notes Section Styles
   ============================================================ */

/* Flip face for Notes - same pattern as flip-back-kanban */
.flip-back-notes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: rotateY(180deg) translateZ(0);
    background: transparent;
    display: flex;
    flex-direction: column;
}

/* Hide elements when notes is active */
.notes-active #weatherWidget,
.notes-active .bg-controls-fixed,
.notes-active #vaultControls,
.notes-active #userBadge,
.notes-active .controls {
    display: none !important;
}

/* Prevent body scroll when notes is active */
body.notes-active,
html.notes-active {
    overflow: hidden !important;
    height: 100vh;
    width: 100vw;
}

/* Notes workspace layout */
.notes-workspace {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    font-family: var(--font-main);
    position: fixed;
    top: 0;
    left: 0;
}

/* ---- Toolbar ---- */
.notes-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--card-bg);
    border-bottom: 2px solid var(--accent);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.notes-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 auto;
}

.notes-toolbar-center {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.notes-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.notes-tool-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-main);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.notes-tool-btn:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 80%);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.notes-tool-btn.notes-back-btn {
    background: var(--card-bg);
}

.notes-tool-btn.notes-back-btn:hover {
    background: var(--accent-color);
    color: var(--color-1);
    border-color: var(--accent-color);
}

.notes-tool-btn.notes-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #ef4444;
}

.notes-toolbar h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.notes-toolbar h2 i {
    color: var(--accent-color);
}

.notes-separator {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 0.25rem;
}

/* Search in toolbar */
.notes-search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-small);
    padding: 0.35rem 0.75rem;
    transition: var(--transition);
}

.notes-search-box:focus-within {
    border-color: var(--accent-color);
}

.notes-search-box i {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.notes-search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.875rem;
    width: 180px;
}

.notes-search-box input::placeholder {
    color: var(--text-secondary);
}

/* ---- Main content area ---- */
.notes-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- Sidebar ---- */
.notes-sidebar {
    width: 320px;
    min-width: 260px;
    max-width: 420px;
    background: var(--card-bg);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.notes-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--accent);
    flex-shrink: 0;
}

.notes-sidebar-header span {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.notes-sidebar-actions {
    display: flex;
    gap: 0.25rem;
}

.notes-icon-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-small);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.notes-icon-btn:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 80%);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Tree */
.notes-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.notes-tree::-webkit-scrollbar {
    width: 4px;
}

.notes-tree::-webkit-scrollbar-track {
    background: transparent;
}

.notes-tree::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* Category */
.notes-category {
    margin-bottom: 0.25rem;
}

.notes-category-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem 0.45rem 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-small);
    margin: 0 0.5rem;
    transition: background 0.15s ease;
    user-select: none;
    position: relative;
}

.notes-category-header:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 90%);
}

.notes-category-header:hover .notes-tree-actions {
    opacity: 1;
}

.notes-category-chevron {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    width: 14px;
}

.notes-category.collapsed .notes-category-chevron {
    transform: rotate(-90deg);
}

.notes-category-icon {
    color: var(--accent-color);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.notes-category-name {
    flex: 1;
    font-size: 0.750rem;
    font-weight: 400;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Subcategory */
.notes-subcategory {
    margin-left: 1.25rem;
    margin-bottom: 0.1rem;
}

.notes-subcategory-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem 0.35rem 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-small);
    margin: 0 0.5rem;
    transition: background 0.15s ease;
    user-select: none;
    position: relative;
}

.notes-subcategory-header:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 90%);
}

.notes-subcategory-header:hover .notes-tree-actions {
    opacity: 1;
}

.notes-subcategory-icon {
    color: var(--accent-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.notes-subcategory-name {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Note item */
.notes-note-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem 0.3rem 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-small);
    margin: 0 0.5rem;
    transition: background 0.15s ease;
    position: relative;
}

.notes-note-item:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 90%);
}

.notes-note-item:hover .notes-tree-actions {
    opacity: 1;
}

.notes-note-item.active {
    background: color-mix(in srgb, var(--accent-color), transparent 80%);
    border: 1px solid color-mix(in srgb, var(--accent-color), transparent 60%);
}

.notes-note-item.active .notes-note-name {
    color: var(--accent-color);
}

.notes-note-icon {
    color: var(--text-secondary);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.notes-note-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Indentation for notes inside subcategories */
.notes-subcategory .notes-note-item {
    margin-left: 1rem;
}

/* Tree action buttons (shown on hover) */
.notes-tree-actions {
    display: flex;
    gap: 0.15rem;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.notes-tree-action-btn {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-small);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.notes-tree-action-btn:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 80%);
    color: var(--accent-color);
}

.notes-tree-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Collapsed children */
.notes-category.collapsed .notes-category-children,
.notes-subcategory.collapsed .notes-subcategory-children {
    display: none;
}

/* Inline rename input */
.notes-inline-input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-small);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.875rem;
    padding: 0.1rem 0.4rem;
    outline: none;
}

/* Empty state */
.notes-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.notes-empty-state i {
    font-size: 2.5rem;
    color: var(--accent-color);
    opacity: 0.4;
}

.notes-empty-state p {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ---- Editor area ---- */
.notes-editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
}

.notes-editor-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 2px solid var(--accent);
    flex-shrink: 0;
    background: var(--card-bg);
}

.notes-editor-title {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 600;
}

.notes-editor-title::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.notes-editor-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    white-space: nowrap;
}

.notes-editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Markdown editor textarea */
.notes-md-editor {
    flex: 1;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'Outfit', monospace;
    font-size: 0.95rem;
    line-height: 1.7;
    padding: 1.25rem 1.5rem;
    resize: none;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.notes-md-editor::-webkit-scrollbar {
    width: 6px;
}

.notes-md-editor::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.notes-md-editor::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Markdown preview */
.notes-md-preview {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: none;
    color: var(--text-primary);
    line-height: 1.7;
}

.notes-md-preview::-webkit-scrollbar {
    width: 6px;
}

.notes-md-preview::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.notes-md-preview::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* Preview markdown styles (reuse scratchpad pattern) */
.notes-md-preview h1,
.notes-md-preview h2,
.notes-md-preview h3,
.notes-md-preview h4,
.notes-md-preview h5,
.notes-md-preview h6 {
    margin: 1em 0 0.5em 0;
    color: var(--accent-color);
    font-weight: 600;
}

.notes-md-preview h1 {
    font-size: 1.8em;
    border-bottom: 2px solid var(--card-border);
    padding-bottom: 0.3em;
}

.notes-md-preview h2 {
    font-size: 1.4em;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.3em;
}

.notes-md-preview h3 {
    font-size: 1.2em;
}

.notes-md-preview p {
    margin: 0.8em 0;
}

.notes-md-preview ul,
.notes-md-preview ol {
    margin: 0.8em 0;
    padding-left: 2em;
}

.notes-md-preview li {
    margin: 0.3em 0;
}

.notes-md-preview a {
    color: var(--accent-color);
    text-decoration: underline;
}

.notes-md-preview code {
    background: var(--card-bg);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-small);
    font-family: monospace;
    font-size: 0.9em;
}

.notes-md-preview pre {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-small);
    padding: 1em;
    overflow-x: auto;
    margin: 1em 0;
}

.notes-md-preview pre code {
    background: transparent;
    padding: 0;
}

.notes-md-preview blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 1em 0;
    padding-left: 1em;
    color: var(--text-secondary);
    font-style: italic;
}

.notes-md-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.notes-md-preview th,
.notes-md-preview td {
    border: 1px solid var(--card-border);
    padding: 0.5em;
    text-align: left;
}

.notes-md-preview th {
    background: var(--card-bg);
    font-weight: 600;
}

.notes-md-preview hr {
    border: none;
    border-top: 2px solid var(--accent);
    margin: 2em 0;
}

.notes-md-preview strong {
    font-weight: 600;
    color: var(--text-primary);
}

.notes-md-preview em {
    font-style: italic;
}

/* No note selected state */
.notes-no-selection {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.notes-no-selection i {
    font-size: 4rem;
    color: var(--accent-color);
    opacity: 0.2;
}

.notes-no-selection h3 {
    font-size: 1.1rem;
    font-weight: 500;
    opacity: 0.5;
}

.notes-no-selection p {
    font-size: 0.85rem;
    opacity: 0.4;
}

/* Save status indicator */
.notes-save-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.notes-save-status.saving {
    color: var(--accent-color);
    opacity: 1;
}

.notes-save-status.saved {
    color: #22c55e;
    opacity: 1;
}

.notes-save-status.error {
    color: #ef4444;
    opacity: 1;
}

/* Encryption badge */
.notes-enc-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: #22c55e;
    opacity: 0.7;
    padding: 0.2rem 0.5rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius-small);
}

/* Flip animation for notes */
.flip-container.flipped-notes .flip-inner {
    transform: rotateY(180deg);
}

/* When notes is active, show notes face */
.flip-container.flipped-notes .flip-back-notes {
    pointer-events: all;
}

/* Hide notes face when not active */
.flip-container:not(.flipped-notes) .flip-back-notes {
    pointer-events: none;
    visibility: hidden;
}

/* Hide other flip faces when notes is active */
.flip-container.flipped-notes .flip-front {
    pointer-events: none;
    visibility: hidden;
}

.flip-container.flipped-notes .flip-back {
    pointer-events: none;
    visibility: hidden;
}

.flip-container.flipped-notes .flip-back-kanban {
    pointer-events: none;
    visibility: hidden;
}

/* Hide side panel toggles when notes is active */
.notes-active .side-panel-toggles {
    display: none;
}

/* ============================================================
   Drag and Drop
   ============================================================ */

/* Drag handles */
.notes-note-drag-handle,
.notes-subcategory-drag-handle {
    color: var(--text-secondary);
    opacity: 0;
    font-size: 0.75rem;
    cursor: grab;
    transition: var(--transition);
    flex-shrink: 0;
}

.notes-note-item:hover .notes-note-drag-handle,
.notes-subcategory-header:hover .notes-subcategory-drag-handle {
    opacity: 0.5;
}

.notes-note-drag-handle:hover,
.notes-subcategory-drag-handle:hover {
    opacity: 1 !important;
    color: var(--accent-color);
}

/* Dragging state */
.notes-note-item.dragging,
.notes-subcategory.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    border: 2px dashed var(--accent-color);
}

/* Drop zone indicators */
.notes-category-header.drag-over,
.notes-subcategory-header.drag-over {
    background: color-mix(in srgb, var(--accent-color), transparent 85%) !important;
    border: 2px dashed var(--accent-color);
    border-radius: var(--radius-small);
}

.notes-category-header.drag-over::before,
.notes-subcategory-header.drag-over::before {
    content: '↓ Drop here';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 600;
    pointer-events: none;
}

/* Cursor states */
.notes-note-item[draggable="true"],
.notes-subcategory[draggable="true"] {
    cursor: grab;
}

.notes-note-item[draggable="true"]:active,
.notes-subcategory[draggable="true"]:active {
    cursor: grabbing;
}

/* Ensure relative positioning for drop indicators */
.notes-category-header,
.notes-subcategory-header {
    position: relative;
}

/* ============================================================
   Export Modal
   ============================================================ */

.notes-export-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notes-export-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-small);
    cursor: pointer;
    transition: var(--transition);
}

.notes-export-option:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 85%);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-2px);
}

.notes-export-option i {
    font-size: 2rem;
    color: var(--accent-color);
    flex-shrink: 0;
}

.notes-export-option div {
    flex: 1;
}

.notes-export-option h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notes-export-option p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* ============================================================
   Markdown Guide Modal
   ============================================================ */

.notes-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.notes-modal {
    background: color-mix(in srgb, var(--color-1), transparent 15%);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-small);
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: modalSlideUp 0.25s ease;
}

.notes-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--card-border);
}

.notes-modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notes-modal-header h2 i {
    color: var(--accent-color);
}

.notes-modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-small);
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.notes-modal-close:hover {
    background: color-mix(in srgb, var(--accent-color), transparent 80%);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.notes-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.notes-modal-body::-webkit-scrollbar {
    width: 6px;
}

.notes-modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.notes-modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.markdown-guide-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.markdown-guide-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-color);
    margin: 0 0 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.markdown-example {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-small);
}

.markdown-example code {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-small);
    border-left: 3px solid var(--accent-color);
}

.markdown-guide-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.markdown-guide-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .notes-sidebar {
        width: 220px;
        min-width: 180px;
    }

    .notes-search-box input {
        width: 120px;
    }

    .notes-toolbar h2 span {
        display: none;
    }
}

@media (max-width: 600px) {
    .notes-sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 260px;
        background: color-mix(in srgb, var(--card-bg), #000 50%);
    }

    .notes-sidebar.mobile-open {
        transform: translateX(0);
    }

    .notes-content {
        position: relative;
    }
}}
}}
}