:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --code-bg: #f5f5f5;
    --table-header-bg: #e0e0e0;
    --border-color: #000000;
}

[data-bs-theme="dark"] {
    --bg-color: #000000;
    --text-color: #ffb366;
    --code-bg: #1e1e2e;
    --table-header-bg: #1a1a1a;
    --border-color: #ff8c00;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: "IBM Plex Mono", "Courier New", monospace;
    font-size: 1.15rem;
    line-height: 1.6;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

[data-bs-theme="dark"] body {
    text-shadow: 0 0 5px rgba(255, 140, 0, 0.5);
}

.content-wrapper {
    display: flex;
    flex: 1;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    padding: 0 0.5rem;
}

.main-content {
    flex-grow: 1;
    padding: 0 1rem;
    min-width: 0;
}

@media (max-width: 767.98px) {
    .content-wrapper {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
    }
}

@media (min-width: 992px) {
    .container-fluid {
        padding-left: 0;
        padding-right: 0;
    }
    .main-content {
        padding-left: 0.1rem;
        padding-right: 0.1rem;
    }
    .sidebar {
        width: 220px;
        padding-left: 0;
    }
}

/* XX-Large screens: cap the width */
@media (min-width: 1400px) {
    .content-wrapper {
        max-width: 1320px;
        margin-left: auto;
        margin-right: auto;
    }
}

a {
    text-decoration: none;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.post-content p {
    margin-bottom: 1rem;
}

.editor-preview pre,
.editor-preview .codehilite pre,
.post-content pre,
.preview-pane pre {
    background: var(--code-bg) !important;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
}

.editor-preview code,
.editor-preview .codehilite code,
.post-content code,
.preview-pane code {
    background: var(--code-bg) !important;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.post-content pre code,
.preview-pane pre code {
    background: none !important;
    padding: 0;
}

.post-content blockquote {
    border-left: 4px solid #0d6efd;
    padding-left: 1rem;
    margin-left: 0;
    color: #6c757d;
}

.post-content table {
    width: 100%;
    margin-bottom: 1rem;
}

.post-content table th,
.post-content table td {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
}

.post-content table th {
    background: var(--table-header-bg);
}

.post-content img {
    max-width: 100%;
    height: auto;
}


.editor-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 0;
    position: relative;
}

.editor-container.preview-only-mode {
    gap: 0 !important;
}

.editor-pane, .preview-pane {
    width: 100%;
    border: none;
    border-radius: 0.375rem;
    padding: 0;
    background: var(--bg-color);
    overflow: hidden;
}

.editor-pane.preview-only-mode,
.editor-pane.preview-only-mode .CodeMirror,
.editor-pane.preview-only-mode .CodeMirror-sizer,
.editor-pane.preview-only-mode .CodeMirror-scroll {
    min-height: 400px !important;
}

.CodeMirror {
    height: calc(100vh - 550px) !important;
    min-height: 400px !important;
}

.CodeMirror-scroll {
    min-height: 400px !important;
    overflow-y: auto !important;
}

.editor-toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    opacity: 1 !important;
}

.form-actions-sticky {
    position: sticky;
    bottom: 0;
    background: var(--bg-color);
    padding: 1rem 0;
    z-index: 10;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

body.editor-fullscreen .form-actions-sticky,
.EasyMDEContainer.fullscreen .form-actions-sticky {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1001 !important;
    padding: 1rem 2rem !important;
    background: var(--bg-color) !important;
    border-top: 1px solid var(--border-color) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
}

body.editor-fullscreen .CodeMirror,
body.editor-fullscreen .CodeMirror-scroll,
.EasyMDEContainer.fullscreen .CodeMirror,
.EasyMDEContainer.fullscreen .CodeMirror-scroll {
    height: calc(100vh - 120px) !important;
    min-height: auto !important;
}

body.editor-fullscreen,
.EasyMDEContainer.fullscreen {
    overflow: hidden !important;
}

body.editor-fullscreen .editor-toolbar,
.EasyMDEContainer.fullscreen .editor-toolbar {
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1100 !important;
}

body.editor-fullscreen .editor-container,
.EasyMDEContainer.fullscreen .editor-container {
    padding-top: 102px;
    padding-bottom: 80px;
    height: 100vh;
    overflow-y: auto;
}

body.editor-fullscreen .navbar,
body.editor-fullscreen nav.navbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1001 !important;
    display: flex !important;
}

body.editor-fullscreen footer,
body.editor-fullscreen .site-footer {
    display: none !important;
}

body.editor-fullscreen .container,
body.editor-fullscreen .container-fluid {
    max-width: 100% !important;
}

.CodeMirror-fullscreen .CodeMirror-lines {
    padding-top: 3em !important;
    padding-bottom: 1em !important;
}

.editor-preview-side {
    padding-top: 3em !important;
    padding-bottom: 3.5em !important;
}

[data-bs-theme="dark"] div.CodeMirror,
[data-bs-theme="dark"] .CodeMirror,
[data-bs-theme="dark"] .editor-toolbar,
[data-bs-theme="dark"] .editor-toolbar *,
[data-bs-theme="dark"] .EasyMDEContainer,
[data-bs-theme="dark"] .editor-toolbar i,
[data-bs-theme="dark"] .editor-toolbar .fa,
[data-bs-theme="dark"] .editor-toolbar button,
[data-bs-theme="dark"] .editor-toolbar a,
[data-bs-theme="dark"] .editor-toolbar span,
[data-bs-theme="dark"] .editor-toolbar svg,
[data-bs-theme="dark"] .EasyMDEContainer .editor-preview,
[data-bs-theme="dark"] .editor-preview,
[data-bs-theme="dark"] div.editor-preview,
[data-bs-theme="dark"] .editor-preview-side,
body[data-bs-theme="dark"] .editor-preview-side {
    background: #333333 !important;
    color: #ffffff !important;
    border-color: #555555 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

[data-bs-theme="dark"] .editor-preview-side h1,
[data-bs-theme="dark"] .editor-preview-side h2,
[data-bs-theme="dark"] .editor-preview-side h3,
[data-bs-theme="dark"] .editor-preview-side h4,
[data-bs-theme="dark"] .editor-preview-side h5,
[data-bs-theme="dark"] .editor-preview-side h6,
[data-bs-theme="dark"] .preview-pane h1,
[data-bs-theme="dark"] .preview-pane h2,
[data-bs-theme="dark"] .preview-pane h3,
[data-bs-theme="dark"] .preview-pane h4,
[data-bs-theme="dark"] .preview-pane h5,
[data-bs-theme="dark"] .preview-pane h6 {
    color: #fbbf24 !important;
}

[data-bs-theme="dark"] .editor-preview-side a,
[data-bs-theme="dark"] .preview-pane a {
    color: #1dd15e !important;
}

[data-bs-theme="dark"] .editor-preview-side blockquote,
[data-bs-theme="dark"] .preview-pane blockquote {
    border-left-color: #555555 !important;
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] .preview-pane table th,
[data-bs-theme="dark"] .preview-pane table td {
    border-color: #555555 !important;
}

[data-bs-theme="dark"] .preview-pane table thead th {
    background: var(--table-header-bg) !important;
}

.editor-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.hidden-textarea {
    display: none !important;
}

/* Blocked/Readonly input styles */
.form-control[readonly],
.form-control[readonly]:focus {
    caret-color: transparent;
    background-color: #e2e3e5;
}

[data-bs-theme="dark"] .form-control[readonly],
[data-bs-theme="dark"] .form-control[readonly]:focus {
    background-color: #3d3d3d;
}

/* Form Label styles */
.form-label,
.form-title,
.author-name {
    font-weight: bold;
}

.form-label,
.form-title,
.author-name {
    color: #264eb2;
}

[data-bs-theme="dark"] .form-label {
    color: #1dd15e;
}

[data-bs-theme="dark"] .form-title,
[data-bs-theme="dark"] .author-name {
    color: #ff8c00;
}

/* Dark mode headers */
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h2,
[data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4,
[data-bs-theme="dark"] h5,
[data-bs-theme="dark"] h6 {
    color: #ff8c00;
    text-shadow: 0 0 8px rgba(255, 140, 0, 0.8);
}


/* Retro Flair */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    z-index: 10000;
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    opacity: 0.03;
}

[data-bs-theme="dark"] body::after {
    opacity: 0.3;
}

[data-bs-theme="dark"] .card, 
[data-bs-theme="dark"] .navbar,
[data-bs-theme="dark"] footer {
    border: 1px solid var(--border-color) !important;
}

[data-bs-theme="light"] .card {
    border: 1px solid #000;
    border-radius: 0;
    box-shadow: 5px 5px 0 #000;
}

[data-bs-theme="light"] .card-header {
    background-color: #000080 !important;
    color: #fff !important;
    border-radius: 0;
    font-weight: bold;
}

[data-bs-theme="light"] .navbar {
    background-color: #c0c0c0 !important;
    border-bottom: 2px solid #000;
}

[data-bs-theme="light"] .navbar .navbar-brand,
[data-bs-theme="light"] .navbar .nav-link {
    color: #000 !important;
}

[data-bs-theme="dark"] a {
    color: #ffb366 !important;
}

[data-bs-theme="dark"] a:hover {
    color: #ffffff !important;
}
