@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Notion-like Light Mode Palette */
    --bg-color: #ffffff;
    --sidebar-bg: #f7f7f5;
    --text-color: #37352f;
    --text-secondary: #787774;
    --text-tertiary: #a1a09c;
    --border-color: #e9e9e8;
    --hover-bg: #efefef;
    --active-bg: #e5e5e5;

    --primary-color: #2eaadc;
    /* Keep brand accent, but use sparingly */
    --selection-color: rgba(46, 170, 220, 0.2);
    --danger-color: #eb5757;

    --code-bg: #f7f6f3;
    --input-bg: transparent;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, "Liberation Mono", Menlo, monospace;
}

body.dark-mode {
    /* Notion-like Dark Mode Palette */
    --bg-color: #191919;
    --sidebar-bg: #202020;
    --text-color: #d4d4d4;
    --text-secondary: #9b9b9b;
    --text-tertiary: #6b6b6b;
    --border-color: #2f2f2f;
    --hover-bg: #2c2c2c;
    --active-bg: #37352f;

    --selection-color: rgba(46, 170, 220, 0.3);

    --code-bg: #262626;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
    transition: background-color 0.2s ease, color 0.2s ease;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.1s;
}

/* --- Sidebar --- */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    /* Tighter padding */
    transition: background-color 0.2s ease, border-color 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

/* User Profile (Top of Sidebar) */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
    margin-bottom: 12px;
}

.user-profile:hover {
    background-color: var(--hover-bg);
}

.user-avatar {
    width: 24px;
    height: 24px;
    background-color: #e3e2e0;
    /* Default neutral avatar bg */
    color: #37352f;
    border-radius: 4px;
    /* Square with rounded corners like Notion */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigation Links */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
}

.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin: 16px 10px 4px 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* General Link Items */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-color);
    transition: background 0.1s;
    cursor: pointer;
}

.sidebar-item:hover {
    background-color: var(--hover-bg);
}

.sidebar-item.active {
    background-color: var(--active-bg);
    color: var(--text-color);
    font-weight: 500;
}

.sidebar-item i {
    color: var(--text-secondary);
    font-size: 16px;
    width: 18px;
    text-align: center;
}

.btn-main-add {
    background: none;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    justify-content: flex-start;
    margin-bottom: 4px;
}

.btn-main-add:hover {
    background-color: var(--hover-bg);
    color: var(--text-color);
}

/* Sidebar Footer */
.sidebar-footer {
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 6px;
}

/* Sidebar Bottom Controls (Settings, Logout) */
.sidebar-bottom-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
}

.sidebar-bottom-action:hover {
    background-color: var(--hover-bg);
    color: var(--text-color);
}

/* --- Main Content --- */
.container {
    display: flex;
    width: 100%;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--bg-color);
}

/* Centered Container for Reading/Editing */
.content-wrapper {
    max-width: 900px;
    /* Optimal reading width */
    width: 100%;
    margin: 0 auto;
    padding: 48px 96px;
    /* Generous padding */
}

/* View Header */
.doc-view-header {
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.title {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    color: var(--text-color);
}

/* Metadata (Folders, Breadcrumbs) */
.doc-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

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

/* Document Content */
.doc-content {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
    font-weight: 600;
    margin-top: 1.4em;
    margin-bottom: 0.5em;
}

.doc-content p {
    margin-bottom: 1em;
}

/* Code Blocks */
.doc-content pre {
    background: var(--code-bg);
    padding: 24px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 14px;
    position: relative;
    border: none;
    /* Clean look */
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font-main);
    transition: color 0.2s;
}

.copy-btn:hover {
    color: var(--text-color);
}

/* --- Forms & Inputs (Clean Style) --- */
input,
textarea,
select {
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
}

select option {
    background-color: var(--bg-color);
    color: var(--text-color);
}

body.dark-mode select option {
    background-color: #2d2d2d;
    /* Specialized dark background for dropdowns */
    color: #e0e0e0;
}

/* Title Input (Big & Bold) */
.title-input {
    font-size: 40px;
    font-weight: 700;
    width: 100%;
    border: none;
    outline: none;
    padding: 0;
    margin-bottom: 20px;
    background: transparent;
}

.title-input::placeholder {
    color: var(--border-color);
    /* Very subtle placeholder */
}

/* Content Textarea */
.content-input {
    width: 100%;
    min-height: 70vh;
    border: none;
    outline: none;
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    background: transparent;
}

/* Standard Inputs */
.form-input {
    width: 100%;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    font-size: 15px;
    transition: border-color 0.2s;
    border-radius: 0;
}

.form-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background 0.1s, box-shadow 0.1s;
    line-height: 1.2;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: #269ccb;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background-color: transparent;
    color: var(--danger-color);
}

.btn-danger:hover {
    background-color: rgba(235, 87, 87, 0.1);
}

.btn-tool {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 13px;
}

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

/* --- Document List (Dashboard) --- */
.doc-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 3px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: background 0.1s;
    text-decoration: none;
    color: var(--text-color);
}

.doc-item:hover {
    background-color: var(--hover-bg);
}

.doc-icon {
    margin-right: 12px;
    color: var(--text-secondary);
    font-size: 18px;
}

.doc-title {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
}

.doc-date {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* --- Login / Auth Pages --- */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: var(--bg-color);
}

.auth-card {
    width: 100%;
    max-width: 360px;
    padding: 40px;
    /* Clean, no border/shadow for minimalistic look, just content */
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 32px;
    color: var(--text-color);
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 15, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    background: var(--bg-color);
    width: 100%;
    max-width: 440px;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

/* --- Utility --- */
.hidden {
    display: none;
}

/* --- Content / Markdown Styling --- */
.doc-content {
    line-height: 1.7;
    font-size: 16px;
    color: var(--text-color);
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    color: var(--text-color);
}

.doc-content p {
    margin-bottom: 1em;
}

/* Code Blocks (Modern) */
.doc-content pre {
    background: #1e1e1e;
    /* Darker background */
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 1.2em 0;
    border: none;
    /* Removed heavy border */
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    /* Slight shadow instead */
}

.doc-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    background: rgba(135, 131, 120, 0.15);
    padding: 2px 5px;
    border-radius: 4px;
    color: #EB5757;
}

.doc-content pre code {
    background: transparent;
    color: #f8f8f2;
    padding: 0;
    border-radius: 0;
}

/* Callouts (Blockquotes styled) */
.doc-content blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 16px;
    margin: 1.2em 0;
    color: var(--text-secondary);
    font-style: italic;
    background: transparent;
}

/* Note Callout (Blue) */
.doc-content blockquote.callout-note {
    background: rgba(46, 170, 220, 0.1);
    /* Light Blue */
    border-left: 4px solid #2eaadc;
    padding: 16px;
    border-radius: 4px;
    font-style: normal;
    color: var(--text-color);
}

.doc-content blockquote.callout-note strong:first-child {
    color: #2eaadc;
    display: block;
    margin-bottom: 4px;
}

/* Warning Callout (Orange) */
.doc-content blockquote.callout-warning {
    background: rgba(255, 171, 0, 0.1);
    /* Light Orange */
    border-left: 4px solid #ffab00;
    padding: 16px;
    border-radius: 4px;
    font-style: normal;
    color: var(--text-color);
}

/* Dark Mode Overrides for Callouts */
body.dark-mode .doc-content blockquote.callout-note {
    background: rgba(46, 170, 220, 0.15);
    border: 1px solid rgba(46, 170, 220, 0.2);
    border-left: 4px solid #2eaadc;
}

body.dark-mode .doc-content blockquote.callout-warning {
    background: rgba(255, 171, 0, 0.15);
    border: 1px solid rgba(255, 171, 0, 0.2);
    border-left: 4px solid #ffab00;
}

/* --- Visual Editor Blocks --- */
#editor-blocks {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 100px;
}

.editor-block {
    position: relative;
    /* Create context for absolute controls */
    padding-left: 40px;
    /* Space for controls */
    transition: background 0.1s;
}

.editor-block:hover {
    /* Optional: highlight block on hover */
}

/* Block Controls (Left Gutter) */
.block-controls {
    position: absolute;
    left: 4px;
    /* Slight offset */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    /* Prevent clicks when hidden */
    transition: opacity 0.2s;
    z-index: 100;
    /* Ensure on top */
}

.editor-block:hover .block-controls {
    opacity: 1;
    pointer-events: auto;
}

.control-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

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

.control-btn.btn-add:hover {
    color: var(--primary-color);
    background: rgba(46, 170, 220, 0.1);
}

.control-btn.btn-delete:hover {
    color: var(--danger-color);
    background: rgba(235, 87, 87, 0.1);
}

/* Remove default input styles */
.block-input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    padding: 8px 12px;
}

.block-input:empty:before {
    content: attr(placeholder);
    color: var(--text-tertiary);
    cursor: text;
}

/* Text Block */
.block-text .block-input {
    min-height: 24px;
}

/* Header Blocks */
.block-h1 .block-input {
    font-size: 24px;
    font-weight: 700;
}

.block-h2 .block-input {
    font-size: 20px;
    font-weight: 600;
}

/* Code Blocks (Editor) */
.block-code {
    background: #1e1e1e;
    border-radius: 8px;
    border: none;
    /* Removed heavy border */
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.block-header {
    background: #252525;
    /* Slightly lighter than code bg */
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #8a8a8a;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    letter-spacing: 0.5px;
    height: 32px;
}

.block-code .block-input {
    color: #f8f8f2;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    padding: 16px;
    min-height: 60px;
}

/* Callout Blocks (Boxed with Header) */
.block-callout {
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    /* Stack header and content */
    padding: 0;
    /* Content padding handled by children */
    overflow: hidden;
    border: none;
    margin-bottom: 16px;
}

.block-callout .callout-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.block-callout .block-input {
    padding: 12px;
    font-size: 14px;
    min-height: 40px;
}

/* Note Specifics */
.block-note {
    background: rgba(46, 170, 220, 0.05);
    /* Very subtle blue bg */
    border: 1px solid rgba(46, 170, 220, 0.2);
    /* Subtle border */
}

.block-note .callout-header {
    color: #2eaadc;
    /* background: rgba(46, 170, 220, 0.1); Optional header bg */
}

/* Warning Specifics */
.block-warning {
    background: rgba(255, 171, 0, 0.05);
    /* Very subtle orange bg */
    border: 1px solid rgba(255, 171, 0, 0.2);
}

.block-warning .callout-header {
    color: #ffab00;
}

/* View Mode Callouts (Matching Editor) */
/* View Mode Callouts (Refined generic style to match Editor/Notion) */
.doc-content blockquote.callout {
    border-left: none;
    border: 1px solid transparent;
    /* default */
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5em 0;
    padding: 0;
    /* Content padding handled by children */
    display: flex;
    flex-direction: column;
}

.doc-content .callout-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
}

.doc-content .callout-content {
    padding: 0 16px 16px 16px;
    font-size: 15px;
    line-height: 1.6;
}

/* Remove default margins from paragraphs inside callouts to fit tighter */
.doc-content .callout-content p:last-child {
    margin-bottom: 0;
}

/* Note View (Blue) */
.doc-content blockquote.callout-note {
    background: rgba(46, 170, 220, 0.08);
    /* Very subtle blue */
    border: 1px solid rgba(46, 170, 220, 0.2);
}

.doc-content blockquote.callout-note .callout-header {
    color: #2eaadc;
}

/* Warning View (Orange/Red) */
.doc-content blockquote.callout-warning {
    background: rgba(255, 171, 0, 0.08);
    /* Very subtle orange */
    border: 1px solid rgba(255, 171, 0, 0.2);
}

.doc-content blockquote.callout-warning .callout-header {
    color: #ffab00;
}

/* Dark Mode Adjustments for deeper contrast */
body.dark-mode .doc-content blockquote.callout-note {
    background: rgba(46, 170, 220, 0.15);
}

body.dark-mode .doc-content blockquote.callout-warning {
    background: rgba(255, 171, 0, 0.15);
}

.editor-block:hover .delete-block-btn {
    opacity: 1;
}

.delete-block-btn:hover {
    color: var(--danger-color);
    background: var(--hover-bg);
}

/* Specific positioning for Code Blocks to not overlap text */
.block-code .delete-block-btn,
.block-bash .delete-block-btn,
.block-debian .delete-block-btn {
    top: 20px;
    /* Align with header */
    right: 10px;
    color: #a0a0a0;
}

/* Slash Menu - Fixed Positioning */
.slash-menu {
    position: fixed;
    /* Fixed to viewport to avoid scroll issues */
    width: 280px;
    max-height: 500px;
    /* Increased to show all items */
    overflow-y: auto;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
    flex-direction: column;
    padding: 4px;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Text Highlighters - Neon Colors */
.marker-orange {
    background-color: #ff9f1c;
    color: #000;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

.marker-green {
    background-color: #39ff14;
    color: #000;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* Slash Command Menu */
.slash-menu {
    position: absolute;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    width: 250px;
    z-index: 1000;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.slash-menu.active {
    display: flex;
}

.slash-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.1s;
}

.slash-item:hover,
.slash-item.selected {
    background: var(--hover-bg);
}

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

.slash-header {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
}

/* Global debug rule removed */

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {

    /* Mobile Header */
    /* Mobile Header - PRODUCTION FIX */
    .mobile-header {
        display: flex;
        /* Activate flex on mobile */
        padding: 16px 20px;
        background-color: var(--sidebar-bg);
        /* Restore correct color */
        color: var(--text-color);
        border-bottom: 1px solid var(--border-color);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 99999;
        /* Maintain high z-index */
    }

    /* Container adjusts for fixed header */
    .container {
        padding-top: 60px;
        /* Space for mobile header */
    }

    /* Sidebar - Off Canvas */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        padding-top: 70px;
        /* Fix: Space for mobile header */
        z-index: 100;
        /* Above everything */
        transform: translateX(-100%);
        /* Hidden by default */
        transition: transform 0.3s ease;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
    }

    .sidebar.active {
        transform: translateX(0);
        /* Slide in */
    }

    /* Overlay Backdrop */
    .sidebar-overlay {
        display: block;
        /* Visible in DOM but hidden via opacity */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 95;
        /* Below sidebar, above content */
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Content Area */
    .content-wrapper {
        padding: 24px 20px;
        /* Reduced padding */
        max-width: 100%;
    }

    /* Typography Adjustments */
    .title {
        font-size: 28px;
        /* Smaller title */
    }

    .title-input {
        font-size: 28px;
    }

    /* Hide desktop-only layout quirks if any */
    body {
        overflow-x: hidden;
    }
}

/* Desktop default for mobile elements */
@media (min-width: 769px) {
    .mobile-header {
        display: none;
    }

    .sidebar-overlay {
        display: none;
    }
}

/* --- Share Modal Responsive Styles --- */
.modal-content-share {
    background: #1e1e1e;
    padding: 25px;
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    color: #e0e0e0;
    border: 1px solid #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* --- Upload Blocks (Image & File) --- */

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.02);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.upload-area input[type="file"] {
    display: none;
}

.upload-loading {
    display: none;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Image Block */
.block-image img {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin-bottom: 8px;
}

.block-image .image-caption {
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
}

/* File Block */
.file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.2s;
    width: fit-content;
}

.file-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.file-card i {
    font-size: 24px;
    color: var(--primary-color);
}

.file-info {
    display: flex;
    flex-direction: column;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
}

.file-type {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

/* --- View Mode Media Styling --- */

/* Responsive Images */
.doc-content img {
    max-width: 100%;
    max-height: 80vh;
    /* Prevent taking up entire vertical space */
    width: auto;
    /* Maintain aspect ratio */
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin: 20px auto;
    /* Center horizontally */
    display: block;
    object-fit: contain;
}

/* File Attachment Card (View Mode) */
.view-file-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    text-decoration: none;
    margin: 10px 0;
    transition: all 0.2s;
    max-width: 100%;
    box-sizing: border-box;
}

.view-file-card:hover {
    background: #2a2a2a;
    border-color: #555;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.view-file-card i {
    font-size: 24px;
    color: var(--primary-color);
}

.view-file-card .file-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.view-file-card .file-name {
    font-size: 14px;
    font-weight: 500;
}

.view-file-card .file-meta {
    font-size: 11px;
    color: #888;
}

}

.share-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.share-header h2 {
    margin: 0;
    font-size: 20px;
}

.share-header .close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 24px;
    padding: 0;
}

.share-section-toggle {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.share-add-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.share-add-form select[name="user_id"] {
    flex: 1;
    min-width: 200px;
    background: var(--bg-primary);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 6px;
}

.share-add-form select[name="permission_type"] {
    width: 100px;
    flex-shrink: 0;
    background: var(--bg-primary);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 6px;
}

/* --- FORCED GLOBAL VIEW MODE STYLES --- */
.doc-content img {}

.view-file-card {
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    margin: 10px 0;
    max-width: 100%;
}

.view-file-card i {
    font-size: 24px;
    color: var(--primary-color);
}

.view-file-card .file-name {
    font-weight: 500;
    font-size: 14px;
}

.view-file-card .file-meta {
    font-size: 11px;
    color: #888;
}


/* --- Onboarding / Empty State --- */

.onboarding-container {
    max-width: 800px;
    margin: 40px auto;
    text-align: center;
    padding: 20px;
}

.onboarding-hero {
    margin-bottom: 40px;
}

.onboarding-hero h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.onboarding-hero p {
    font-size: 16px;
    color: var(--text-secondary);
}

.icon-stack {
    font-size: 48px;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.onboarding-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.onboarding-card {
    background: #1e1e1e;
    border: 1px solid #333;
    padding: 24px;
    border-radius: 12px;
    text-align: left;
    transition: transform 0.2s, box-shadow 0.2s;
}

.onboarding-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: #555;
    background: #252525;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}

.bg-blue {
    background: rgba(79, 172, 254, 0.15);
    color: #4facfe;
}

.bg-purple {
    background: rgba(161, 140, 209, 0.15);
    color: #a18cd1;
}

.bg-green {
    background: rgba(67, 233, 123, 0.15);
    color: #43e97b;
}

.onboarding-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #e0e0e0;
}

.onboarding-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.onboarding-card code {
    background: #333;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #fff;
}

.btn-large-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--primary-color);
    color: white;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    transition: background 0.2s;
    box-shadow: 0 4px 15px rgba(46, 170, 220, 0.4);
}


/* --- Modern Login Redesign (Tech/Dark) --- */

.login-body {
    background: #0a0a0a;
    color: #e0e0e0;
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    position: relative;
}

/* Background Glow Effect */
.login-bg-glow {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(46, 170, 220, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    border-radius: 50%;
    z-index: 0;
    opacity: 0.8;
    animation: pulseGlow 10s infinite alternate;
}

@keyframes pulseGlow {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.02);
        opacity: 0.8;
    }
}

.login-modern-container {
    background: rgba(20, 20, 20, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    max-width: 400px;
    padding: 15px 40px 40px;
    /* Drastically reduced top padding */
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 1;
    text-align: center;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0;
    /* Removing margin completely */
}

.login-logo-img {
    max-width: 250px;
    height: auto;
    display: block;
    /* Ensure it behaves as block to remove inline spacing */
    margin-bottom: 0;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
}

.login-logo-img:hover {
    transform: scale(1.03);
}

/* Obsolete text branding removed as image contains text */


.login-subtitle {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-bottom: 30px;
}

/* Social Buttons */
.login-social-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-google {
    background: #fff;
    color: #333;
    border-color: #ddd;
}

.btn-google:hover {
    background: #f1f1f1;
}

.btn-apple {
    background: #000;
    color: #fff;
    border-color: #333;
}

.btn-apple:hover {
    background: #1a1a1a;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Separator */
.login-separator {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-tertiary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-separator::before,
.login-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.login-separator span {
    padding: 0 10px;
}

/* Inputs */
.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 18px;
    transition: color 0.2s;
}

.input-group input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 12px 12px 12px 42px;
    /* Space for icon */
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.input-group input:focus {
    border-color: var(--primary-color);
    background: rgba(46, 170, 220, 0.05);
}

.input-group input:focus+.input-icon {
    color: var(--primary-color);
}

/* Options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 24px;
}

.forgot-link {
    color: var(--text-secondary);
    text-decoration: none;
}

.forgot-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Submit Button */
.btn-login-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-login-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(46, 170, 220, 0.4);
}

.login-footer {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

/* --- WYSIWYG Editor Styles --- */

.rich-input {
    min-height: 1.5em;
    /* Ensure empty div has height */
    outline: none;
    padding: 0;
    margin: 0;
    display: block;
    width: 100%;
    /* Mimic textarea behavior */
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Placeholder for contenteditable */
.rich-input:empty:before {
    content: attr(placeholder);
    color: var(--text-tertiary);
    /* Matches ::placeholder color */
    pointer-events: none;
    display: block;
    /* For Firefox */
}

/* Toolbar Buttons */
.btn-tool {
    background: transparent;
    border: none;
    color: #eee;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-tool:hover {
    background: rgba(255, 255, 255, 0.1);
}