/* Custom Editor Toolbar */
#editor-toolbar {
    background: rgba(58, 58, 58, 0.9) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(85, 85, 85, 0.6) !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4),
                0 1px 0 rgba(255, 255, 255, 0.1) inset !important;
    margin-bottom: 10px !important;
    align-items: center !important;
}

#editor-toolbar button {
    background: rgba(70, 70, 70, 0.6);
    border: 1px solid rgba(90, 90, 90, 0.5);
    color: #e0e0e0;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    font-family: sans-serif;
    font-size: 13px;
    min-width: 36px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-weight: 500;
    letter-spacing: 0.2px;
}

#editor-toolbar button:hover {
    background: rgba(0, 123, 255, 0.8);
    border-color: rgba(0, 123, 255, 0.6);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4),
                0 0 0 1px rgba(0, 123, 255, 0.3);
}

#editor-toolbar button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
}

/* Toolbar divider */
#editor-toolbar .toolbar-divider {
    width: 1px;
    height: 24px;
    background: linear-gradient(to bottom, transparent, rgba(85, 85, 85, 0.8), transparent);
    margin: 0 4px;
    align-self: center;
}

/* Tooltip for toolbar buttons */
#editor-toolbar button[title]:hover::after {
    content: attr(title);
    position: fixed;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10000;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    pointer-events: none;
    font-weight: 500;
    border: 1px solid rgba(80, 80, 80, 0.5);
}

/* Custom Editor Content Area */
#editor {
    border: 1px solid rgba(85, 85, 85, 0.6);
    padding: 20px;
    min-height: 400px;
    background: transparent;
    color: #eee;
    border-radius: 10px;
    outline: none;
    line-height: 1.7;
    transition: all 0.3s ease;
}

#editor:focus {
    border-color: rgba(0, 123, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Editor page title input */
#editor-page-title {
    width: calc(100% - 24px);
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 1.4em;
    font-weight: 600;
    border: 1px solid rgba(85, 85, 85, 0.6);
    border-radius: 8px;
    background: rgba(50, 50, 50, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: #fff;
    transition: all 0.25s ease;
}

#editor-page-title::placeholder {
    color: rgba(200, 200, 200, 0.5);
}

#editor-page-title:focus {
    outline: none;
    border-color: rgba(0, 123, 255, 0.4);
    background: rgba(55, 55, 55, 0.8);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.08);
}

/* Code blocks in editor - visible during editing */
#editor pre.simple-code-block,
#editor pre.code-block {
    background-color: #1e1e1e;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 12px;
    margin: 1em 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #d4d4d4;
    position: relative;
}

#editor pre.simple-code-block::before,
#editor pre.code-block::before {
    content: 'Code';
    position: absolute;
    top: 0;
    right: 0;
    background: #444;
    color: #aaa;
    padding: 2px 8px;
    font-size: 11px;
    border-bottom-left-radius: 4px;
}

#editor code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background-color: #1e1e1e;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

#editor pre code {
    background: transparent;
    padding: 0;
}

/* Blockquotes in editor - clearly visible */
#editor blockquote {
    border-left: 4px solid #888;
    margin: 1em 0;
    padding: 12px 18px;
    background-color: rgba(136, 136, 136, 0.1);
    border-radius: 0 4px 4px 0;
    color: #aaa;
    font-style: italic;
}

#editor blockquote::before {
    content: 'Цитата';
    display: block;
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

/* GitHub-style admonitions in editor */
#editor .admonition {
    border-left: 4px solid;
    padding: 0;
    margin: 1em 0;
    border-radius: 0 4px 4px 0;
    position: relative;
    overflow: hidden;
}

#editor .admonition-type {
    display: block;
    padding: 10px 16px;
    margin: 0;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

#editor .admonition-type:hover {
    background: rgba(0,0,0,0.08);
    filter: brightness(1.1);
}

#editor .admonition-type::after {
    content: '  (клик для смены типа)';
    font-size: 10px;
    opacity: 0.5;
    font-weight: normal;
    text-transform: none;
    font-style: italic;
}

#editor .admonition-content {
    padding: 14px 18px;
    color: #eee;
    white-space: normal;
    word-wrap: break-word;
}

#editor .admonition-content br {
    line-height: 1.5;
}

#editor .admonition-note {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.08);
}

#editor .admonition-note .admonition-type {
    background: rgba(0, 123, 255, 0.15);
    color: #007bff;
}

#editor .admonition-tip {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.08);
}

#editor .admonition-tip .admonition-type {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

#editor .admonition-important {
    border-color: #8b5cf6;
    background-color: rgba(139, 92, 246, 0.08);
}

#editor .admonition-important .admonition-type {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

#editor .admonition-warning {
    border-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.12);
}

#editor .admonition-warning .admonition-type {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

#editor .admonition-caution {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.08);
}

#editor .admonition-caution .admonition-type {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Details/Summary in editor */
#editor details {
    border: 1px solid #444;
    border-radius: 4px;
    margin: 1em 0;
    overflow: hidden;
    background: rgba(255,255,255,0.02);
}

#editor details[open] {
    border-color: #007bff;
}

#editor summary {
    background: rgba(0, 123, 255, 0.15);
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    position: relative;
    color: #0095ff;
    transition: background-color 0.2s;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#editor summary:focus {
    background: rgba(0, 123, 255, 0.25);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

#editor summary:hover {
    background: rgba(0, 123, 255, 0.2);
}

#editor summary::-webkit-details-marker {
    display: none;
}

#editor summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 8px;
    transform: rotate(0deg);
    transition: transform 0.2s;
    font-size: 10px;
    color: #0095ff;
}

#editor details[open] summary::before {
    transform: rotate(90deg);
}

#editor details > div:not(summary) {
    padding: 16px;
    min-height: 80px;
    margin: 0;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid #444;
}

#editor details .details-content {
    padding: 16px;
    min-height: 80px;
    margin: 0;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid #444;
    white-space: normal;
    word-wrap: break-word;
}

#editor details .details-content br {
    line-height: 1.5;
}

#editor details > div:empty::before {
    content: 'Введите текст спойлера...';
    color: #666;
    font-style: italic;
}

#editor details .details-content:empty::before {
    content: 'Введите текст спойлера...';
    color: #666;
    font-style: italic;
}

#editor details > :last-child {
    margin-bottom: 0;
}

/* Headers in editor */
#editor h1, #editor h2, #editor h3, #editor h4, #editor h5, #editor h6 {
    color: #0095ff;
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

#editor h1 { font-size: 2em; border-bottom: 2px solid #444; padding-bottom: 0.3em; }
#editor h2 { font-size: 1.6em; border-bottom: 1px solid #444; padding-bottom: 0.3em; }
#editor h3 { font-size: 1.4em; }
#editor h4 { font-size: 1.2em; }
#editor h5 { font-size: 1.1em; }
#editor h6 { font-size: 1em; color: #888; }

/* Lists in editor */
#editor ul, #editor ol {
    margin: 1em 0;
    padding-left: 2em;
}

#editor li {
    margin: 0.5em 0;
}

/* Links in editor */
#editor a {
    color: #007bff;
    text-decoration: underline;
}

/* Images in editor */
#editor img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em 0;
    border-radius: 4px;
}

/* Tables in editor */
#editor table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    border: 1px solid #444;
}

#editor th, #editor td {
    border: 1px solid #444;
    padding: 8px 12px;
    text-align: left;
}

#editor th {
    background-color: #444;
    color: #fff;
    font-weight: 600;
}

#editor tr:nth-child(even) {
    background-color: rgba(255,255,255,0.05);
}

#editor tr:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

/* ==================== Light Theme ==================== */

body:not(.dark-theme) #editor-toolbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(224, 224, 224, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

body:not(.dark-theme) #editor-toolbar button {
    color: #495057;
}

body:not(.dark-theme) #editor-toolbar button:hover {
    background: rgba(233, 236, 239, 0.8);
    border-color: rgba(206, 212, 218, 0.6);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

body:not(.dark-theme) #editor-toolbar button[title]:hover::after {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #212529;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body:not(.dark-theme) #editor {
    border: 1px solid rgba(224, 224, 224, 0.5);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    color: #212529;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

body:not(.dark-theme) #editor:focus {
    border-color: rgba(0, 123, 255, 0.5);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05),
                0 0 0 3px rgba(0, 123, 255, 0.1);
}

body:not(.dark-theme) #editor h1,
body:not(.dark-theme) #editor h2,
body:not(.dark-theme) #editor h3,
body:not(.dark-theme) #editor h4,
body:not(.dark-theme) #editor h5,
body:not(.dark-theme) #editor h6 {
    color: #172b4d;
}

body:not(.dark-theme) #editor h1 {
    border-bottom-color: #e0e0e0;
}

body:not(.dark-theme) #editor h2 {
    border-bottom-color: #e0e0e0;
}

body:not(.dark-theme) #editor pre.simple-code-block,
body:not(.dark-theme) #editor pre.code-block {
    background-color: #f6f8fa;
    border-color: #e0e0e0;
    color: #24292e;
}

body:not(.dark-theme) #editor pre.simple-code-block::before,
body:not(.dark-theme) #editor pre.code-block::before {
    background: #e0e0e0;
    color: #666;
}

body:not(.dark-theme) #editor code {
    background-color: #f6f8fa;
}

body:not(.dark-theme) #editor blockquote {
    border-left-color: #adb5bd;
    background-color: rgba(173, 181, 189, 0.1);
    color: #6c757d;
}

body:not(.dark-theme) #editor blockquote::before {
    color: #adb5bd;
}

body:not(.dark-theme) #editor .admonition-note {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.06);
}

body:not(.dark-theme) #editor .admonition-note .admonition-type {
    background: rgba(0, 123, 255, 0.1);
    color: #007bff;
}

body:not(.dark-theme) #editor .admonition-tip {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.06);
}

body:not(.dark-theme) #editor .admonition-tip .admonition-type {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

body:not(.dark-theme) #editor .admonition-important {
    border-color: #8b5cf6;
    background-color: rgba(139, 92, 246, 0.06);
}

body:not(.dark-theme) #editor .admonition-important .admonition-type {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

body:not(.dark-theme) #editor .admonition-warning {
    border-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.08);
}

body:not(.dark-theme) #editor .admonition-warning .admonition-type {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

body:not(.dark-theme) #editor .admonition-caution {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.06);
}

body:not(.dark-theme) #editor .admonition-caution .admonition-type {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

body:not(.dark-theme) #editor details {
    border-color: #e0e0e0;
    background: rgba(248, 249, 250, 0.5);
}

body:not(.dark-theme) #editor details[open] {
    border-color: #007bff;
}

body:not(.dark-theme) #editor summary {
    background: rgba(0, 123, 255, 0.08);
    color: #007bff;
}

body:not(.dark-theme) #editor summary:focus {
    background: rgba(0, 123, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

body:not(.dark-theme) #editor summary:hover {
    background: rgba(0, 123, 255, 0.12);
}

body:not(.dark-theme) #editor summary::before {
    color: #007bff;
}

body:not(.dark-theme) #editor details > div:not(summary) {
    background: rgba(248, 249, 250, 0.5);
    border-top-color: #e0e0e0;
}

body:not(.dark-theme) #editor table {
    border-color: #e0e0e0;
}

body:not(.dark-theme) #editor th,
body:not(.dark-theme) #editor td {
    border-color: #e0e0e0;
}

body:not(.dark-theme) #editor th {
    background-color: #f6f8fa;
    color: #24292e;
}

body:not(.dark-theme) #editor tr:nth-child(even) {
    background-color: rgba(246, 248, 250, 0.5);
}

body:not(.dark-theme) #editor tr:hover {
    background-color: rgba(0, 123, 255, 0.06);
}
