/* Main content area for notes */
.notes-content {
    flex: 1;
    background: var(--container-background);
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden; /* Remove auto scrolling from main content */
    position: relative;
    transition: all var(--transition-speed) var(--transition-curve);
    margin: 0;
    left: 0;
}

/* Hide main content scrollbar - scrolling happens in note-content only */
.notes-content::-webkit-scrollbar {
    display: none;
}

.notes-content {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Custom scrollbar for individual note content only */
.note-content::-webkit-scrollbar {
    width: 6px;
}

.note-content::-webkit-scrollbar-track {
    background: transparent;
}

.note-content::-webkit-scrollbar-thumb {
    background: rgba(113, 113, 122, 0.3);
    border-radius: 3px;
}

.note-content::-webkit-scrollbar-thumb:hover {
    background: rgba(113, 113, 122, 0.5);
}

.sidebar-collapsed .notes-content {
    border-left: none;
    width: 100%;
}

/* Note Header - Integrated with content */
.note-header {
    background: linear-gradient(180deg, 
        rgba(30, 30, 35, 0.4) 0%, 
        rgba(30, 30, 35, 0.2) 50%, 
        transparent 100%
    );
    padding: 1.25rem 2.5rem 1rem 2.5rem;
    margin-bottom: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(113, 113, 122, 0.3); /* Softer border */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Header content wrapper */
.note-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 2rem;
}

/* Header date styling */
.note-header-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    opacity: 0.9;
}

/* Dark mode - brighter date */
body.dark-mode .note-header-date,
.dark-mode .note-header-date {
    color: rgba(209, 213, 219, 0.85); /* Brighter in dark mode */
    opacity: 1;
}

/* Light mode - darker date */
body:not(.dark-mode) .note-header-date {
    color: rgba(55, 65, 81, 0.8); /* Darker in light mode */
    opacity: 1;
}

/* Add a subtle paper-like texture effect */
.note-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        radial-gradient(circle at 60% 80%, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: 30px 30px, 40px 40px;
    pointer-events: none;
    opacity: 0.3;
}

.note-header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--primary-color);
    font-weight: 600; /* Reduced from 700 */
    font-family: 'system-ui', -apple-system, 'Segoe UI', 'Roboto', sans-serif; /* Match body text */
    text-shadow: 0 2px 4px rgba(0,0,0,0.2); /* Lighter shadow */
    position: relative;
    z-index: 2; /* Ensure title stays above background texture */
}

.note-meta {
    display: none; /* Hidden since date is now in header */
}

/* Note Content Area - Flows with header */
.note-content {
    padding: 2rem 2.5rem 8rem 2.5rem; /* Increased bottom padding to ensure full scroll visibility */
    background: transparent;
    color: var(--text-color);
    line-height: 1.7;
    font-size: 1rem;
    font-family: 'system-ui', -apple-system, 'Segoe UI', 'Roboto', sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    height: calc(100vh - 140px); /* Better height calculation accounting for header + nav */
    overflow-y: auto; /* Add scrolling only to individual note content */
    overflow-x: hidden;
    margin-top: -0.5rem; /* Slight negative margin to connect with header */
    box-sizing: border-box; /* Include padding in height calculation */
}

/* Empty State */
.notes-content.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text-muted);
    padding: 2rem;
    text-align: center;
    overflow: hidden; /* Ensure no scrollbars in empty state */
}

.notes-content.empty h2 {
    color: var(--primary-color);
    margin-top: -5rem;
    font-size: 1.5rem;
    font-weight: 600;
}
body:not(.dark-mode) .notes-content.empty h2 {
    color: #111827;
}

.notes-content.empty p {
    color: var(--text-muted);
    font-size: 1rem;
    text-align: center;
    font-size: 1rem;
    max-width: 400px;
}

/* Typography */
.note-content h1, .note-content h2, .note-content h3, .note-content h4 {
    color: var(--primary-color);
    font-family: 'system-ui', -apple-system, 'Segoe UI', 'Roboto', sans-serif; /* Match body text */
    line-height: 1.3;
    font-weight: 400;
    text-align: left;
}

.note-content h1 {
    font-size: 1.6rem; /* Smaller to not compete with header title */
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(113, 113, 122, 0.6); /* More visible border in dark mode */
    margin-top: 0;
    margin-bottom: 0.75rem; /* Reduced from 1rem */
    font-family: 'system-ui', -apple-system, 'Segoe UI', 'Roboto', sans-serif; /* Match body text */
    font-weight: 400; /* Match h2 weight - no glow effect */
    color: var(--primary-color); /* Match h2 color exactly */
}
.note-content h2 { 
    font-size: 1.4rem; 
    color: var(--primary-color); /* Made brighter - using primary color instead of accent-hover */
    margin-top: 1rem;
    margin-bottom: 0.75rem;
}
.note-content h3 { 
    font-size: 1.2rem; 
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}
.note-content h4 { 
    font-size: 1rem; 
    color: var(--text-muted); 
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.note-content p {
    line-height: 1.7;
    color: var(--text-color);
    margin-bottom: 0.15rem;
    margin-top: 0.5rem;
}

/* Reduce margin for first paragraph */
.note-content p:first-child {
    margin-top: 0;
}

/* Reduce spacing between closely related paragraphs */
.note-content p + p {
    margin-top: 0.25rem;
}

.note-content ul, .note-content ol {    
    padding-left: 1.5rem;
    line-height: 1.7;   
    margin-bottom: 0.2rem;
}

.note-content ul li, .note-content ol li {
    color: var(--text-color);
    margin-bottom: 0.2rem;  
}

.note-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

.note-content em {
    color: var(--text-muted);
    font-style: italic;
}

.note-content a {
    color: var(--accent-hover);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-color);
    transition: all var(--transition-speed) var(--transition-curve);
    padding-bottom: 1px;
}

.note-content a:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(161, 161, 170, 0.1);
    border-radius: 2px;
}

/* Block Elements */
.note-content blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: rgba(113, 113, 122, 0.1);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.6;
}

.note-content code {
    background: var(--secondary-color);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--card-border);
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    color: #f87171; /* Keep red for inline code for visibility */
}

.note-content pre {
    background: var(--secondary-color);
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    border: var(--card-border);
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: var(--box-shadow);
}

.note-content pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--text-color);
}

.note-content hr {
    border: none;
    height: 1px;
    background: rgba(113, 113, 122, 0.4);
    margin: 1rem 0;
}

/* Media */
.note-content img.note-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    box-shadow: var(--box-shadow);
    border: var(--card-border);
}

.note-content .image-error {
    display: inline-block;
    background: rgba(220, 38, 38, 0.1);
    color: #f87171;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-style: italic;
    margin: 1rem 0;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

/* Tables - Enhanced visibility with proper borders */
.note-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    border: 2px solid rgba(113, 113, 122, 0.4); /* Stronger outer border */
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    background: var(--card-background);
}

.note-content th,
.note-content td {
    padding: 0.5rem 1rem; /* Reduced vertical padding for tighter cells */
    text-align: left;
    border: 1px solid rgba(113, 113, 122, 0.3); /* Full borders around all cells */
    vertical-align: top;
    line-height: 1.4;
}

.note-content th {
    background: rgba(113, 113, 122, 0.15); /* Distinct header background */
    font-weight: 700; /* Bolder headers */
    color: var(--primary-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(113, 113, 122, 0.5); /* Stronger bottom border for headers */
}

.note-content td {
    background: rgba(30, 30, 35, 0.2); /* Subtle alternating cell background */
    color: var(--text-color);
}

/* Mobile Back Button */
.back-to-notes-btn {
    display: none; /* Hidden by default, shown in notes.css media query */
    background: var(--accent-secondary);
    color: var(--primary-color);
    border: var(--card-border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: all var(--transition-speed) var(--transition-curve);
}

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

/* Light Mode Styles */
body:not(.dark-mode) .notes-content {
    background: #f8fafc;
    color: #374151;
}

body:not(.dark-mode) .note-header {
    border-bottom: 2px solid #e5e7eb;
}

body:not(.dark-mode) .note-header h1 {
    color: #111827;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1); /* Lighter shadow for light mode */
}

body:not(.dark-mode) .note-meta {
    color: #6b7280;
}

body:not(.dark-mode) .note-content {
    color: #374151;
}

body:not(.dark-mode) .note-content p,
body:not(.dark-mode) .note-content ul li,
body:not(.dark-mode) .note-content ol li {
    color: #374151;
}

body:not(.dark-mode) .note-content h1, 
body:not(.dark-mode) .note-content h2, 
body:not(.dark-mode) .note-content h3, 
body:not(.dark-mode) .note-content h4,
body:not(.dark-mode) .note-content strong {
    color: #111827;
}

/* Light mode H1 border */
body:not(.dark-mode) .note-content h1 {
    border-bottom-color: #d1d5db;
}


body:not(.dark-mode) .note-content a {
    color: #1d4ed8;
    border-bottom-color: rgba(29, 78, 216, 0.3);
}

body:not(.dark-mode) .note-content a:hover {
    color: #1e40af;
    background: rgba(29, 78, 216, 0.1);
}

body:not(.dark-mode) .note-content blockquote {
    border-left-color: #1d4ed8;
    background: rgba(29, 78, 216, 0.05);
    color: #6b7280;
}

body:not(.dark-mode) .note-content code {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #dc2626;
}

body:not(.dark-mode) .note-content pre {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

body:not(.dark-mode) .note-content pre code {
    color: #374151;
}

body:not(.dark-mode) .note-content hr {
    background: #e2e8f0;
}


/* Light mode table styling */
body:not(.dark-mode) .note-content table {
    border: 2px solid #cbd5e1; /* Stronger border for light mode */
    background: #ffffff;
}

body:not(.dark-mode) .note-content th,
body:not(.dark-mode) .note-content td {
    border: 1px solid #e2e8f0; /* Full borders around all cells */
}

body:not(.dark-mode) .note-content th {
    background: #f1f5f9; /* Distinct header background */
    color: #1e293b; /* Darker text for contrast */
    border-bottom: 2px solid #cbd5e1; /* Stronger header border */
}

body:not(.dark-mode) .note-content td {
    background: #fafafa; /* Light cell background */
    color: #374151;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .note-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .note-header h1 {
        font-size: 1.3rem;
        font-weight: 600; /* Ensure consistency on mobile */
    }

    .note-header-date {
        font-size: 0.75rem;
    }

    .note-meta {
        width: 100%;
        justify-content: space-between;
    }

    .note-content {
        padding: 1rem 1rem 2rem 1rem;
        font-size: 0.9rem; /* Smaller text on mobile */
        height: calc(60vh - 60px);
    }

    .note-content h1 {
        font-size: 1.3rem;
    }

    .note-content h2 {
        font-size: 1.15rem;
    }

    .note-content h3 {
        font-size: 1rem;
    }

    .note-content h4 {
        font-size: 0.9rem;
    }

    .note-content p,
    .note-content ul li,
    .note-content ol li {
        font-size: 0.9rem;
    }

    /* Responsive table adjustments */
    .note-content table {
        font-size: 0.8rem;
        margin: 1rem 0;
    }
    
    .note-content th,
    .note-content td {
        padding: 0.4rem 0.7rem;
        font-size: 0.75rem;
    }
    
    .note-content th {
        font-size: 0.7rem;
    }
}
