/* ============================================
   Notes Page Styles
   ============================================ */

/* Page-level styles */
.notes-page {
    overflow: hidden;
}

/* Main Layout */
.notes-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   Left Panel: Notes Sidebar
   ============================================ */
.notes-sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.notes-sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.back-to-chat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    transition: var(--transition);
}

.back-to-chat:hover {
    background: var(--sidebar-hover);
}

.back-icon {
    font-size: 1rem;
}

.notes-title {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.new-note-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.new-note-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Search Section */
.notes-search-section {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-input-wrapper {
    position: relative;
    margin-bottom: 0.5rem;
}

.notes-search-input {
    width: 100%;
    padding: 0.625rem 2rem 0.625rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius);
    color: var(--sidebar-text);
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.notes-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.notes-search-input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.search-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
}

.search-clear:hover {
    color: var(--sidebar-text);
}

.tag-filter {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    color: var(--sidebar-text);
    font-size: 0.8rem;
    cursor: pointer;
}

.tag-filter:focus {
    outline: 1px solid var(--primary-color);
}

/* Notes List */
.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.notes-loading {
    padding: 2rem 1rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.875rem;
}

.notes-list-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.875rem;
}

/* Note List Item */
.note-list-item {
    padding: 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.25rem;
    border-left: 3px solid transparent;
}

.note-list-item:hover {
    background: var(--sidebar-hover);
}

.note-list-item.selected {
    background: var(--sidebar-selected);
    border-left-color: white;
}

.note-list-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.note-list-preview {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.375rem;
}

.note-list-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.note-list-date {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
}

.note-list-tags {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.note-tag-chip {
    font-size: 0.6rem;
    padding: 0.125rem 0.375rem;
    background: rgba(74, 144, 226, 0.3);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
}

/* Sidebar Footer */
.notes-sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.5rem;
}

.view-graph-btn,
.export-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.view-graph-btn:hover,
.export-btn:hover {
    background: var(--sidebar-hover);
    border-color: rgba(255, 255, 255, 0.25);
}

.graph-icon {
    font-size: 1rem;
}

.export-icon {
    font-size: 0.9rem;
}

/* ============================================
   Right Panel: Main Content
   ============================================ */
.notes-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

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

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.notes-empty-state h2 {
    font-size: 1.5rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.notes-empty-state p {
    max-width: 400px;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.primary-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* ============================================
   Note View Mode
   ============================================ */
.note-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.note-view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.note-view-title-section {
    flex: 1;
    min-width: 0;
}

.note-view-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 0.375rem 0;
    line-height: 1.3;
}

.note-view-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

.note-view-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.action-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.action-btn.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.action-btn.danger {
    color: var(--error-color);
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error-color);
}

/* Tags in View */
.note-view-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.view-tag-chip {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: rgba(74, 144, 226, 0.1);
    color: var(--primary-color);
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.view-tag-chip:hover {
    background: rgba(74, 144, 226, 0.2);
}

/* Note Content */
.note-view-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-color);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Links Sections */
.note-view-links {
    padding: 1rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    flex-shrink: 0;
    display: flex;
    gap: 2rem;
}

.links-section {
    flex: 1;
}

.links-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.5rem;
}

.links-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.links-list li {
    margin-bottom: 0.25rem;
}

.link-item {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
}

.link-item:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================
   Note Editor Mode
   ============================================ */
.note-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.note-editor-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.note-title-input {
    flex: 1;
    padding: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    outline: none;
    transition: var(--transition);
}

.note-title-input:focus {
    border-color: var(--primary-color);
}

.note-editor-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.note-editor-hints {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 2rem;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.hint-divider {
    color: var(--border-color);
}

.note-content-input {
    flex: 1;
    padding: 1.5rem 2rem;
    font-size: 1rem;
    line-height: 1.7;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
}

.note-content-input::placeholder {
    color: var(--text-light);
}

/* Textarea container for autocomplete positioning */
.textarea-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Wiki-link autocomplete dropdown */
.link-autocomplete {
    position: absolute;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    min-width: 200px;
    max-width: 350px;
}

.autocomplete-list {
    padding: 0.25rem 0;
}

.autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--accent-color);
    color: white;
}

.autocomplete-empty {
    padding: 0.5rem 0.75rem;
    color: var(--text-light);
    font-style: italic;
    font-size: 0.85rem;
}

.note-editor-preview {
    display: flex;
    gap: 2rem;
    padding: 0.75rem 2rem;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.preview-label {
    color: var(--text-light);
    margin-right: 0.375rem;
}

.preview-tags-list,
.preview-links-list {
    color: var(--text-color);
}

/* ============================================
   Graph View
   ============================================ */
.graph-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #1a1a2e;
}

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.graph-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

.graph-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.graph-tag-filter {
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    color: white;
    font-size: 0.8rem;
}

.graph-controls .action-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.graph-controls .action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.graph-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#graph-svg {
    width: 100%;
    height: 100%;
}

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Graph Node Styles */
.graph-node {
    cursor: pointer;
}

.graph-node circle {
    transition: all 0.2s ease;
}

.graph-node:hover circle {
    stroke-width: 3px;
    stroke: white;
}

.graph-node text {
    font-size: 10px;
    fill: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    text-anchor: middle;
}

.graph-link {
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 1px;
}

/* Graph Tooltip */
.graph-tooltip {
    position: absolute;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 100;
    max-width: 200px;
}

.graph-tooltip .tooltip-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.graph-tooltip .tooltip-tags {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .notes-layout {
        flex-direction: column;
    }

    .notes-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 50vh;
    }

    .notes-main {
        flex: 1;
        min-height: 50vh;
    }

    .note-view-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem 1.5rem;
    }

    .note-view-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .note-view-content {
        padding: 1rem 1.5rem;
    }

    .note-view-links {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 1.5rem;
    }

    .note-editor-header {
        flex-direction: column;
        padding: 1rem 1.5rem;
    }

    .note-title-input {
        width: 100%;
    }

    .note-editor-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .note-content-input {
        padding: 1rem 1.5rem;
    }

    .graph-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .graph-controls {
        width: 100%;
        justify-content: space-between;
    }
}

/* Scrollbar styling for notes list */
.notes-list::-webkit-scrollbar {
    width: 6px;
}

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

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

.notes-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Scrollbar styling for note content */
.note-view-content::-webkit-scrollbar {
    width: 8px;
}

.note-view-content::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.note-view-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.note-view-content::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}
