/* ==========================================================================
   MARKDOWN & MATH NOTE STUDIO STYLESHEET
   Signature Manjaro Teal & Glassmorphic Workspace
   ========================================================================== */

/* --- CSS Variables & Theming Tokens --- */
:root {
    --editor-bg: #070b14;
    --editor-panel: rgba(13, 20, 36, 0.95);
    --editor-panel-border: rgba(22, 160, 133, 0.2);
    --editor-canvas-bg: #0c1424;
    --editor-canvas-text: #f1f5f9;
    --editor-canvas-border: rgba(22, 160, 133, 0.28);
    --editor-canvas-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 1px rgba(22, 160, 133, 0.4);
    
    --manjaro-teal: #1abc9c;
    --manjaro-dark-teal: #16a085;
    --manjaro-glow: rgba(22, 160, 133, 0.35);
    --accent-cyan: #06b6d4;
    --accent-amber: #f59e0b;
}

/* Theme 1: Obsidian Dark Studio */
body.theme-obsidian {
    --editor-bg: #060a12;
    --editor-panel: rgba(11, 18, 32, 0.96);
    --editor-panel-border: rgba(22, 160, 133, 0.22);
    --editor-canvas-bg: #09101f;
    --editor-canvas-text: #f8fafc;
    --editor-canvas-border: rgba(22, 160, 133, 0.3);
    --editor-canvas-shadow: 0 16px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(22, 160, 133, 0.2);
}

/* Theme 2: Nordic Dark Slate */
body.theme-slate {
    --editor-bg: #0b1120;
    --editor-panel: rgba(15, 23, 42, 0.96);
    --editor-panel-border: rgba(56, 189, 248, 0.2);
    --editor-canvas-bg: #1e293b;
    --editor-canvas-text: #f8fafc;
    --editor-canvas-border: rgba(148, 163, 184, 0.25);
    --editor-canvas-shadow: 0 16px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(56, 189, 248, 0.15);
}

/* Theme 3: Minimal Paper */
body.theme-paper {
    --editor-bg: #090e1a;
    --editor-panel: rgba(13, 20, 36, 0.96);
    --editor-panel-border: rgba(255, 255, 255, 0.1);
    --editor-canvas-bg: #ffffff;
    --editor-canvas-text: #1e293b;
    --editor-canvas-border: rgba(0, 0, 0, 0.08);
    --editor-canvas-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* --- Global Reset & App Layout --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--editor-bg);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.editor-app-layout {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   LEFT SIDEBAR: DOCUMENT MANAGER
   ========================================================================== */
.editor-sidebar-left {
    width: 290px;
    background: var(--editor-panel);
    border-right: 1px solid var(--editor-panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 1.2rem;
    box-sizing: border-box;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.editor-brand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.editor-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #ffffff;
}

.editor-brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px var(--manjaro-glow));
}

.editor-brand-info {
    display: flex;
    flex-direction: column;
}

.editor-brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff;
}

.editor-brand-tag {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--manjaro-teal);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-collapse-btn {
    background: transparent;
    border: none;
    color: var(--muted-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 6px;
    border-radius: 4px;
    transition: 0.2s;
}

.sidebar-collapse-btn:hover {
    color: var(--manjaro-teal);
    background: rgba(22, 160, 133, 0.12);
}

/* Document Search Filter */
.doc-search-wrap {
    position: relative;
    margin-bottom: 1rem;
}

.doc-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-color);
    font-size: 0.85rem;
    pointer-events: none;
}

.doc-search-wrap input {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 7px 10px 7px 32px;
    color: #ffffff;
    font-size: 0.82rem;
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    transition: 0.2s;
}

.doc-search-wrap input:focus {
    border-color: var(--manjaro-teal);
    box-shadow: 0 0 10px var(--manjaro-glow);
}

/* Section Header */
.doc-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 0.6rem;
    padding: 0 4px;
}

.icon-text-btn {
    background: transparent;
    border: none;
    color: var(--manjaro-teal);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: 0.2s;
}

.icon-text-btn:hover {
    background: rgba(22, 160, 133, 0.15);
}

/* Document File List */
.editor-file-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-right: 4px;
}

.editor-file-list::-webkit-scrollbar {
    width: 4px;
}
.editor-file-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.file-tab {
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.88rem;
    transition: all 0.18s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    position: relative;
}

.file-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, 0.08);
}

.file-tab.active {
    background: rgba(22, 160, 133, 0.15);
    color: #ffffff;
    border-color: rgba(22, 160, 133, 0.5);
    box-shadow: inset 3px 0 0 var(--manjaro-teal);
    font-weight: 500;
}

.tab-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tab-title-wrap i {
    font-size: 0.8rem;
    color: var(--manjaro-teal);
}

.tab-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: 0.18s;
}

.file-tab:hover .tab-actions,
.file-tab.active .tab-actions {
    opacity: 1;
}

.delete-doc {
    font-size: 0.8rem;
    color: var(--muted-color);
    padding: 3px 5px;
    border-radius: 4px;
    transition: 0.18s;
}

.delete-doc:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

/* Sidebar Footer */
.editor-sidebar-footer {
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.storage-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--muted-color);
    padding: 2px 4px;
}

.editor-tool-shortcuts {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    margin-bottom: 2px;
}

.tool-chip {
    flex: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 0.75rem;
    color: var(--muted-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.tool-chip:hover {
    background: rgba(22, 160, 133, 0.15);
    border-color: var(--manjaro-teal);
    color: #ffffff;
}

.tool-chip svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
    display: inline-block;
    vertical-align: middle;
}

.text-teal {
    color: var(--manjaro-teal) !important;
}

/* ==========================================================================
   CENTER WORKSPACE: QUICK TOOLBAR & PAPER STAGE
   ========================================================================== */
.editor-center-workspace {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: transparent;
}

/* Quick Action Toolbar */
.editor-quick-toolbar {
    height: 48px;
    background: var(--editor-panel);
    border-bottom: 1px solid var(--editor-panel-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.2rem;
    box-sizing: border-box;
    z-index: 5;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
    color: #cbd5e1;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.84rem;
    transition: 0.18s;
}

.toolbar-btn:hover {
    background: rgba(22, 160, 133, 0.2);
    border-color: rgba(22, 160, 133, 0.4);
    color: #ffffff;
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 4px;
}

.toolbar-pill-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    padding: 5px 11px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.18s;
}

.toolbar-pill-btn:hover {
    background: rgba(22, 160, 133, 0.2);
    border-color: var(--manjaro-teal);
    color: #ffffff;
}

/* Scroll Stage */
.editor-scroll-stage {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    padding: 2.5rem 1.5rem 4rem;
    box-sizing: border-box;
}

.editor-scroll-stage::-webkit-scrollbar {
    width: 6px;
}
.editor-scroll-stage::-webkit-scrollbar-track {
    background: transparent;
}
.editor-scroll-stage::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    transition: background 0.2s ease;
}
.editor-scroll-stage::-webkit-scrollbar-thumb:hover {
    background: var(--manjaro-teal);
}

/* Paper Theme Stage Scrollbar */
body.theme-paper .editor-scroll-stage::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
}
body.theme-paper .editor-scroll-stage::-webkit-scrollbar-thumb:hover {
    background: var(--manjaro-teal);
}

/* The Paper / Canvas Container */
.editor-paper-container {
    background-color: var(--editor-canvas-bg);
    color: var(--editor-canvas-text);
    width: 820px;
    min-height: 800px;
    max-width: 100%;
    border: 1px solid var(--editor-canvas-border);
    border-radius: 8px;
    box-shadow: var(--editor-canvas-shadow);
    padding: 40px 50px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, width 0.2s ease;
}

/* Document Title Field */
.doc-title-field {
    background: transparent;
    border: none;
    outline: none;
    color: inherit;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    width: 100%;
    padding: 0 0 10px 0;
    box-sizing: border-box;
    font-family: inherit;
}

.doc-title-field::placeholder {
    opacity: 0.4;
}

.doc-title-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin-bottom: 24px;
}

body.theme-paper .doc-title-divider {
    background: rgba(0, 0, 0, 0.08);
}

/* The Textarea Editor */
#typly-editor {
    flex-grow: 1;
    background: transparent;
    color: inherit;
    border: none;
    outline: none;
    resize: none;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    min-height: 600px;
    font-size: 18px;
    line-height: 1.65;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    tab-size: 4;
}

#typly-editor::-webkit-scrollbar {
    width: 5px;
}
#typly-editor::-webkit-scrollbar-track {
    background: transparent;
}
#typly-editor::-webkit-scrollbar-thumb {
    background: rgba(22, 160, 133, 0.25);
    border-radius: 6px;
}
body.theme-paper #typly-editor::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
}
body.theme-paper #typly-editor::-webkit-scrollbar-thumb:hover {
    background: var(--manjaro-teal);
}

#typly-editor::placeholder {
    opacity: 0.35;
}

/* Bottom Status Bar */
.editor-bottom-bar {
    height: 32px;
    background: var(--editor-panel);
    border-top: 1px solid var(--editor-panel-border);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.2rem;
    font-size: 0.72rem;
    color: var(--muted-color);
    z-index: 5;
}

.status-indicators {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-sep {
    opacity: 0.4;
}

.save-status {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--manjaro-teal);
    font-weight: 500;
}

/* ==========================================================================
   RIGHT SIDEBAR: INSPECTOR & CONTROLS
   ========================================================================== */
.editor-sidebar-right {
    width: 290px;
    background: var(--editor-panel);
    border-left: 1px solid var(--editor-panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 1.4rem;
    box-sizing: border-box;
    flex-shrink: 0;
    overflow-y: auto;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.editor-sidebar-right::-webkit-scrollbar {
    width: 4px;
}
.editor-sidebar-right::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.widget-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted-color);
    font-weight: 600;
    margin-bottom: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.widget-title i {
    color: var(--manjaro-teal);
    font-size: 0.8rem;
}

/* Metrics Grid */
.metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 1.8rem;
}

.metric-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
}

.metric-card strong {
    font-size: 1.1rem;
    color: #ffffff;
    font-family: var(--font-mono);
    font-weight: 600;
}

.metric-card span {
    font-size: 0.7rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Controls */
.control-group {
    margin-bottom: 1.2rem;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #e2e8f0;
    margin-bottom: 0.45rem;
    font-weight: 500;
}

.control-group label span {
    color: var(--manjaro-teal);
    font-family: var(--font-mono);
    font-size: 0.76rem;
}

.dark-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 8px 10px;
    border-radius: 6px;
    outline: none;
    font-size: 0.82rem;
    font-family: inherit;
    box-sizing: border-box;
    cursor: pointer;
    transition: 0.2s;
}

.dark-input:focus {
    border-color: var(--manjaro-teal);
    box-shadow: 0 0 8px var(--manjaro-glow);
}

.dark-input optgroup {
    background: #0f172a;
    color: var(--manjaro-teal);
    font-weight: 600;
}

.dark-input option {
    background: #090e1a;
    color: #f8fafc;
    font-weight: 400;
}

/* Custom Sliders */
.range-slider {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    border-radius: 2px;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    background: var(--manjaro-teal);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px var(--manjaro-glow);
    transition: transform 0.18s ease;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    background: #2dd4bf;
}

/* Theme Picker */
.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 1.8rem;
}

.theme-opt-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--muted-color);
    font-size: 0.72rem;
    transition: 0.18s;
}

.theme-opt-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.theme-opt-btn.active {
    border-color: var(--manjaro-teal);
    color: #ffffff;
    background: rgba(22, 160, 133, 0.15);
    box-shadow: 0 0 10px var(--manjaro-glow);
}

.theme-preview {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.theme-preview.obsidian { background: #09101f; }
.theme-preview.slate { background: #1e293b; }
.theme-preview.paper { background: #ffffff; border-color: #cbd5e1; }

/* Export Buttons Grid */
.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    padding: 9px 8px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.76rem;
    transition: 0.18s;
    text-decoration: none;
}

.action-btn i {
    font-size: 1rem;
    color: var(--manjaro-teal);
}

.action-btn:hover {
    background: rgba(22, 160, 133, 0.15);
    border-color: var(--manjaro-teal);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(22, 160, 133, 0.2);
}

/* Distraction Free Mode */
body.distraction-free .editor-sidebar-left,
body.distraction-free .editor-sidebar-right,
body.distraction-free .editor-quick-toolbar,
body.distraction-free .editor-bottom-bar {
    display: none !important;
}

body.distraction-free .editor-scroll-stage {
    padding: 4rem 1.5rem;
}

/* Toast Notifications */
.editor-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #090e1a;
    color: #ffffff;
    border: 1px solid var(--manjaro-teal);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.82rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 12px var(--manjaro-glow);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(10px);
    transition: 0.25s ease;
    pointer-events: none;
    z-index: 100;
}

.editor-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile & Tablet Adjustments */
@media (max-width: 992px) {
    .editor-sidebar-right {
        display: none;
    }
    .editor-sidebar-left {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .editor-sidebar-left {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 50;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
    }
    .editor-sidebar-left.open {
        left: 0;
    }
    .editor-paper-container {
        padding: 24px 20px;
    }
    .doc-title-field {
        font-size: 1.4rem;
    }
}