/* Custom Styles for mdlib */

/* Base styles */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --text-color: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --transition-speed: 0.2s;
    --sidebar-width: 300px; /* Fixed sidebar width */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Markdown Preview Styles */
.markdown-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    max-width: 100%;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.3;
}

.markdown-body h1 {
    font-size: 2em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border-color);
    color: #2d3748;
}

.markdown-body h2 {
    font-size: 1.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border-color);
    color: #2d3748;
}

.markdown-body h3 {
    font-size: 1.25em;
    color: #2d3748;
}

.markdown-body h4 {
    font-size: 1em;
    color: #2d3748;
}

.markdown-body h5 {
    font-size: 0.875em;
    color: #4a5568;
}

.markdown-body h6 {
    font-size: 0.85em;
    color: #718096;
}

.markdown-body p {
    margin-top: 0;
    margin-bottom: 1.2em;
}

.markdown-body blockquote {
    padding: 0.75em 1.2em;
    color: #718096;
    border-left: 0.25em solid #e2e8f0;
    margin: 0 0 1.2em 0;
    background-color: #f8fafc;
    border-radius: 0.25em;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 2em;
    margin-top: 0;
    margin-bottom: 1.2em;
}

.markdown-body li + li {
    margin-top: 0.25em;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: #f1f5f9;
    border-radius: 0.25em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.markdown-body pre {
    word-wrap: normal;
    padding: 1rem;
    overflow: auto;
    line-height: 1.45;
    background-color: #f8fafc;
    border-radius: 0.375rem;
    margin-bottom: 1.2em;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.markdown-body pre code {
    padding: 0;
    margin: 0;
    background-color: transparent;
    border: 0;
    word-break: normal;
    white-space: pre;
    display: inline;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
}

.markdown-body img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: #fff;
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.markdown-body table {
    border-spacing: 0;
    border-collapse: collapse;
    margin-top: 0;
    margin-bottom: 16px;
    width: 100%;
    overflow: auto;
    border-radius: 0.375rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.markdown-body table th {
    font-weight: 600;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
}

.markdown-body table td {
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
}

.markdown-body table tr {
    background-color: #fff;
    border-top: 1px solid #e2e8f0;
}

.markdown-body table tr:nth-child(2n) {
    background-color: #f8fafc;
}

.markdown-body hr {
    height: 1px;
    padding: 0;
    margin: 24px 0;
    background-color: #e2e8f0;
    border: 0;
}

.markdown-body a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

.markdown-body a:hover {
    text-decoration: underline;
    color: var(--primary-hover);
}

/* Dark Mode Styles */
.dark-mode {
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: #312e81;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --bg-color: #111827;
    --card-bg: #1e293b;
    
    background-color: var(--bg-color);
    color: var(--text-color);
}

.dark-mode .bg-white {
    background-color: var(--card-bg) !important;
}

.dark-mode .bg-gray-50 {
    background-color: #1f2937 !important;
}

.dark-mode .text-gray-700,
.dark-mode .text-gray-800,
.dark-mode .text-gray-900 {
    color: var(--text-color) !important;
}

.dark-mode .text-gray-500,
.dark-mode .text-gray-600 {
    color: var(--text-muted) !important;
}

.dark-mode .border-gray-200,
.dark-mode .border-gray-300 {
    border-color: var(--border-color) !important;
}

/* Fix for input fields in dark mode */
.dark-mode input[type="text"],
.dark-mode textarea,
.dark-mode #search-input {
    background-color: #2d3748;
    color: #e2e8f0;
    border-color: var(--border-color);
    caret-color: #e2e8f0; /* This ensures cursor visibility */
}

.dark-mode #new-note-name::placeholder,
.dark-mode #search-input::placeholder {
    color: #94a3b8;
}

/* Make Cancel button more visible in dark mode */
.dark-mode #btn-modal-cancel {
    background-color: #374151;
    color: #e2e8f0;
}

.dark-mode #btn-modal-cancel:hover {
    background-color: #4b5563;
}

.dark-mode #editor {
    background-color: #1a202c;
    color: var(--text-color);
    border-color: var(--border-color);
}

.dark-mode .markdown-body h1,
.dark-mode .markdown-body h2,
.dark-mode .markdown-body h3,
.dark-mode .markdown-body h4 {
    color: #e2e8f0;
}

.dark-mode .markdown-body h5,
.dark-mode .markdown-body h6 {
    color: #cbd5e1;
}

.dark-mode .markdown-body h1,
.dark-mode .markdown-body h2 {
    border-bottom-color: var(--border-color);
}

.dark-mode .markdown-body blockquote {
    color: #cbd5e1;
    border-left-color: #475569;
    background-color: #1e293b;
}

.dark-mode .markdown-body code {
    background-color: #1e293b;
}

.dark-mode .markdown-body pre {
    background-color: #0f172a;
}

.dark-mode .markdown-body table th,
.dark-mode .markdown-body table td {
    border-color: var(--border-color);
}

.dark-mode .markdown-body table th {
    background-color: #1e293b;
}

.dark-mode .markdown-body table tr {
    background-color: var(--card-bg);
    border-top-color: var(--border-color);
}

.dark-mode .markdown-body table tr:nth-child(2n) {
    background-color: #0f172a;
}

.dark-mode .markdown-body hr {
    background-color: var(--border-color);
}

.dark-mode .markdown-body a {
    color: #93c5fd;
}

.dark-mode .markdown-body a:hover {
    color: #bfdbfe;
}

/* Improved Sidebar Styles */
#sidebar {
    width: 300px; /* Fixed width value */
    height: calc(100vh - 4rem); /* Adjust based on header height */
    position: sticky;
    top: 4rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: none; /* Remove width transition */
    flex-shrink: 0; /* Prevent sidebar from shrinking */
}

#sidebar > div {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px; /* Compensate for scrollbar to avoid layout shift */
    scrollbar-width: thin;
}

/* File List with Improved Handling for Long Names */
#file-list {
    max-height: 100%;
    overflow-y: auto;
    margin-bottom: 1rem;
}

#file-list li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    transition: background-color 0.2s, color 0.2s;
    position: relative;
    color: var(--text-color);
    box-sizing: border-box;
}

#file-list li .note-icon {
    margin-right: 0.5rem !important;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    display: inline-flex !important;
    justify-content: center;
    align-items: center;
}

#file-list li .note-title {
    flex: 1 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 2px;
    display: inline-block;
    text-align: left !important;
    min-width: 0 !important;
}

/* Category List Improvements */
#category-list {
    margin-bottom: 1rem;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    margin-bottom: 0.25rem;
    transition: background-color 0.2s;
    position: relative;
    text-align: left;
    justify-content: flex-start;
}

.category-name {
    margin-left: 0.5rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tags Section Improvements */
#tags-container {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    gap: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
    padding-bottom: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    background-color: var(--primary-light);
    color: var(--primary-color);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color var(--transition-speed);
}

/* Enhanced Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Custom scrollbar for Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

/* Responsive sidebar handling */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        z-index: 40;
        width: 300px; /* Keep the same fixed width */
        height: 100vh;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    #sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block !important;
    }
}

/* Remove breakpoint width adjustments */
@media (min-width: 769px) and (max-width: 1280px) {
    /* Remove the root variable override */
}

@media (min-width: 1281px) {
    /* Remove the root variable override */
}

/* Fix for long context menu items */
#context-menu {
    max-width: 250px;
}

#context-menu > div {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Add toast container to prevent layout shift */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Modern Buttons */
button {
    transition: all var(--transition-speed) ease;
}

/* Transitions */
.fade-enter {
    opacity: 0;
}

.fade-enter-active {
    opacity: 1;
    transition: opacity var(--transition-speed) ease;
}

.fade-exit {
    opacity: 1;
}

.fade-exit-active {
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

/* Modern scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.dark-mode ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Tags styling */
.tag:hover {
    background-color: #d1d5db;
}

.tag.active {
    background-color: #4f46e5;
    color: white;
}

/* Category styling */
.category-item:hover {
    background-color: #f3f4f6;
}

.category-item.active {
    background-color: #e5edff;
    color: #4f46e5;
    font-weight: 500;
}

.category-delete-btn {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.category-item:hover .category-delete-btn {
    visibility: visible;
    opacity: 1;
}

.category-item svg {
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.category-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-add-form {
    display: flex;
    margin-bottom: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.category-input {
    flex-grow: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    outline: none;
    font-size: 0.875rem;
}

.category-input:focus {
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.category-add-button {
    background-color: #4f46e5;
    color: white;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.category-add-button:hover {
    background-color: #4338ca;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    background-color: #eef2ff;
    color: #4f46e5;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.category-badge svg {
    margin-right: 0.25rem;
    width: 0.75rem;
    height: 0.75rem;
}

.category-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.category-section-title h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.category-empty {
    text-align: left;
    padding: 1rem;
    color: #6b7280;
    font-style: italic;
    font-size: 0.875rem;
}

/* New category modal */
.category-modal {
    background-color: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    max-width: 24rem;
    width: 100%;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.category-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1f2937;
}

.category-modal-button {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.category-modal-confirm {
    background-color: #4f46e5;
    color: white;
}

.category-modal-confirm:hover {
    background-color: #4338ca;
}

.category-modal-cancel {
    background-color: #f3f4f6;
    color: #1f2937;
}

.category-modal-cancel:hover {
    background-color: #e5e7eb;
}

/* Context menu styling */
#context-menu {
    min-width: 160px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
}

#context-menu > div {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

#context-menu > div:hover {
    background-color: #eef2ff;
}

#context-menu > div:first-child {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

#context-menu > div:last-child {
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* File item styling with tags */
.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.file-item:hover {
    background-color: #eef2ff;
}

.file-item .tags-indicator {
    font-size: 0.75rem;
    background-color: #e5e7eb;
    color: #4b5563;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

/* Sidebar sections */
.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #4b5563;
    display: flex;
    align-items: center;
}

.sidebar-section-title svg {
    margin-right: 0.5rem;
    width: 1.25rem;
    height: 1.25rem;
    color: #4f46e5;
}

/* Toast notification */
.toast {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    background-color: var(--card-bg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    color: var(--text-color);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

/* Tag hover styles */
.tag-item {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tag-delete-btn {
    margin-left: 0.25rem;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tag-item:hover .tag-delete-btn {
    visibility: visible;
    opacity: 1;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    background-color: var(--card-bg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    color: var(--text-color);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

/* Context menu styles */
#context-menu {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color);
    max-width: 200px;
}

#context-menu > div {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#context-menu > div:hover {
    background-color: #f3f4f6;
}

.dark-mode #context-menu {
    background-color: #1e293b;
    border-color: #334155;
}

.dark-mode #context-menu > div:hover {
    background-color: #374151;
}

/* Enhanced File List */
.file-list-container {
    overflow-y: auto;
    max-height: calc(100vh - 450px);
    min-height: 200px;
    border-radius: 0.375rem;
    scrollbar-width: thin;
}

#file-list {
    position: relative;
}

#file-list li {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    transition: background-color var(--transition-speed);
    position: relative;
    color: var(--text-color);
}

#file-list li .note-icon {
    margin-right: 0.5rem;
    flex-shrink: 0;
}

#file-list li .note-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#file-list li:hover {
    background-color: #f3f4f6;
}

.dark-mode #file-list li:hover {
    background-color: #374151;
}

#file-list li.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    font-weight: 500;
}

.dark-mode #file-list li.active {
    background-color: #312e81;
    color: #a5b4fc;
}

/* Enhanced Category Styles */
.category-list-container {
    overflow-y: auto;
    max-height: 200px;
    border-radius: 0.375rem;
    scrollbar-width: thin;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    margin-bottom: 0.25rem;
    transition: background-color 0.2s;
    position: relative;
}

.category-item svg {
    flex-shrink: 0;
}

.category-name {
    margin-left: 0.5rem;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-delete-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.category-item:hover .category-delete-btn {
    opacity: 1;
}

.category-item:hover {
    background-color: #f3f4f6;
}

.dark-mode .category-item:hover {
    background-color: #374151;
}

.category-item.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    font-weight: 500;
}

.dark-mode .category-item.active {
    background-color: #312e81;
    color: #a5b4fc;
}

/* Ensure all text inputs are left-aligned */
input[type="text"], 
textarea, 
select {
    text-align: left;
}

/* Responsive Sidebar Toggle */
.sidebar-toggle {
    display: none;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
    
    #sidebar {
        position: fixed;
        z-index: 40;
        width: 100%;
        height: 100vh;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    #sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .file-list-container {
        max-height: calc(100vh - 400px);
    }
    
    #content-container {
        margin-top: 1rem;
    }
    
    #toolbar {
        flex-wrap: wrap;
    }
    
    #file-info {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Compact Mode for many items */
@media (min-height: 800px) {
    .file-list-container {
        max-height: calc(100vh - 350px);
    }
}

/* Delete button in file list */
.delete-btn {
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

#file-list li:hover .delete-btn {
    opacity: 1;
}

.dark-mode .delete-btn {
    color: #6b7280;
}

.dark-mode .delete-btn:hover {
    color: #ef4444;
} 