/* Base & Reset */
* { box-sizing: border-box; }

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar { display: none; }
/* Hide scrollbar for IE, Edge and Firefox */
html, body { -ms-overflow-style: none; scrollbar-width: none; }

body { margin: 0; font-family: sans-serif; background-color: #f6f6f6; color: #202122; }
button { font-family: inherit; }

/* Icons */
.icon { width: 20px; height: 20px; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; vertical-align: middle; }
.icon-xs { width: 14px; height: 14px; vertical-align: middle; }

/* Layout */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.main-content { flex: 1; width: 100%; overflow-x: hidden; }

/* Header */
.header { background: #fff; border-bottom: 1px solid #a2a9b1; height: 56px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1000; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.header-left, .header-right { display: flex; align-items: center; gap: 8px; }

.logo { display: flex; align-items: center; gap: 8px; font-family: 'Linux Libertine', Georgia, serif; font-size: 1.25rem; font-weight: bold; background: none; border: none; cursor: pointer; color: #000; padding: 0; }
.logo-icon { width: 32px; height: 32px; background: #000; color: #fff; display: flex; align-items: center; justify-content: center; font-family: sans-serif; font-size: 14px; font-weight: bold; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.logo-text { display: none; }
@media(min-width: 600px) { .logo-text { display: block; } }

.separator { width: 1px; height: 24px; background: #e5e7eb; margin: 0 4px; }

/* Navigation */
.nav-controls { display: flex; align-items: center; gap: 2px; margin-right: 8px; }
.nav-btn { background: none; border: none; cursor: pointer; color: #6b7280; padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; }
.nav-btn:hover { background: #f3f4f6; color: #000; }
.nav-btn:disabled { color: #e5e7eb; cursor: default; }
.nav-btn:disabled:hover { background: none; }

/* Search Popup */
.search-popup {
    position: fixed; top: 64px; right: 16px;
    background: white; padding: 8px 12px; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #e5e7eb;
    display: flex; align-items: center; gap: 8px;
    z-index: 999;
    animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.search-input { border: 1px solid #d1d5db; border-radius: 4px; padding: 6px 10px; font-size: 14px; width: 200px; outline: none; transition: border-color 0.2s; }
.search-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.1); }

.search-count { font-size: 12px; color: #6b7280; min-width: 50px; text-align: center; font-variant-numeric: tabular-nums; }
.search-divider { width: 1px; height: 20px; background: #e5e7eb; }

mark.search-match { background-color: #fde047; color: black; padding: 0 1px; border-radius: 2px; }
mark.search-match.active { background-color: #f97316; color: white; outline: 2px solid rgba(249, 115, 22, 0.4); }

/* Buttons */
.btn { border: none; background: transparent; cursor: pointer; border-radius: 999px; padding: 8px; display: flex; align-items: center; justify-content: center; gap: 4px; transition: background 0.1s; color: #4b5563; }
.btn:hover { background-color: #f3f4f6; color: #000; }

.btn-primary { border: none; cursor: pointer; background-color: #2563eb; color: white; padding: 8px 16px; font-weight: bold; font-size: 0.875rem; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s; box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2); text-decoration: none; }
.btn-primary:hover { background-color: #1d4ed8; color: white; box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.btn-lg { padding: 14px 36px; font-size: 1.125rem; }
.btn-lg:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4); }

.btn-text { padding: 6px 12px; color: #2563eb; border-radius: 999px; }
.btn-text:hover { background-color: #eff6ff; }

.btn-admin { background-color: #fffbeb; color: #b45309; border: 1px solid #fcd34d; padding: 6px 12px; font-size: 0.75rem; font-weight: bold; border-radius: 999px; }
.btn-admin:hover { background-color: #fef3c7; }

/* Wiki Page */
.page-container { max-width: 960px; margin: 0 auto; background: #fff; min-height: 100vh; border-left: 1px solid #e5e7eb; border-right: 1px solid #e5e7eb; }
@media(min-width: 640px) { .page-container { margin-top: 24px; border-radius: 4px; min-height: auto; box-shadow: 0 1px 2px rgba(0,0,0,0.05); } }

.page-content-wrapper { padding: 24px; }
@media(min-width: 768px) { .page-content-wrapper { padding: 40px; } }

.page-title { font-family: 'Linux Libertine', Georgia, serif; font-size: 2rem; border-bottom: 1px solid #a2a9b1; margin: 0 0 0.5rem 0; padding-bottom: 0.5rem; font-weight: normal; color: #000; line-height: 1.2; }
@media(min-width: 768px) { .page-title { font-size: 2.5rem; } }

.page-meta { font-size: 0.75rem; color: #6b7280; display: flex; justify-content: space-between; margin-bottom: 2rem; align-items: center; }
.delete-btn { color: #ef4444; background: #fef2f2; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 0.75rem; }
.delete-btn:hover { background: #fee2e2; }

/* Wiki Content */
.wiki-content { font-family: sans-serif; line-height: 1.6; color: #202122; font-size: 1rem; }
.wiki-text { white-space: pre-wrap; margin-bottom: 1rem; }
.wiki-content p { margin: 0.5rem 0 1rem; }
.wiki-content h1, .wiki-content h2, .wiki-content h3 { font-family: 'Linux Libertine', Georgia, serif; border-bottom: 1px solid #a2a9b1; margin-top: 1.5em; margin-bottom: 0.5em; padding-bottom: 0.25em; font-weight: normal; overflow: hidden; clear: both; }
.wiki-content h1 { font-size: 1.8em; }
.wiki-content h2 { font-size: 1.5em; }
.wiki-content h3 { font-size: 1.2em; font-weight: bold; border-bottom: none; }
.wiki-content a { color: #2563eb; text-decoration: underline; cursor: pointer; }
.wiki-content a:hover { color: #1d4ed8; }
.wiki-content a:visited { color: #7c3aed; }

/* Wiki Images */
.wiki-image-wrapper { margin-bottom: 1rem; border: 1px solid #c8ccd1; background: #f8f9fa; padding: 3px; text-align: center; display: table; }
.wiki-image { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.wiki-caption { font-size: 0.85rem; line-height: 1.4; padding: 4px; color: #202122; display: table-caption; caption-side: bottom; text-align: left; }

.align-left { float: left; margin-right: 1.5rem; margin-bottom: 1rem; clear: left; }
.align-right { float: right; margin-left: 1.5rem; margin-bottom: 1rem; clear: right; }
.align-center { margin: 0 auto 1.5rem; clear: both; }

.size-sm { width: 200px; }
.size-md { width: 400px; }
.size-lg { width: 600px; }
.size-full { width: 100%; }

/* Mobile responsive image sizes */
@media(max-width: 600px) {
    .size-sm, .size-md, .size-lg { width: 100%; max-width: 100%; }
    .align-left, .align-right { float: none; margin: 1rem auto; display: table; }
}

/* Other Blocks */
.wiki-divider { border: 0; border-top: 1px solid #a2a9b1; margin: 1.5rem 0; height: 1px; }
.wiki-html-block { margin: 1rem 0; }
.wiki-html-block a { color: #2563eb; text-decoration: underline; cursor: pointer; }
.wiki-html-block a:hover { color: #1d4ed8; }
.wiki-html-block a:visited { color: #7c3aed; }

/* Editor */
.editor-container { max-width: 800px; margin: 0 auto; padding: 16px; padding-bottom: 100px; }
.editor-header { background: #fff; padding: 20px; border-radius: 8px; border-left: 4px solid #3b82f6; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 24px; }
.editor-title-label { display: block; font-size: 0.75rem; font-weight: bold; color: #9ca3af; text-transform: uppercase; margin-bottom: 4px; }
.title-input { font-size: 1.75rem; font-family: serif; font-weight: bold; width: 100%; border: none; border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; outline: none; margin-bottom: 8px; }
.slug-display { font-size: 0.75rem; color: #9ca3af; }

.editor-block { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 16px; position: relative; transition: border 0.2s; }
.editor-block:hover { border-color: #60a5fa; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.block-controls { position: absolute; right: 8px; top: -12px; display: flex; gap: 4px; background: #fff; border: 1px solid #e5e7eb; border-radius: 4px; padding: 2px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.editor-block:hover .block-controls { opacity: 1; pointer-events: auto; }
@media(max-width: 640px) { .block-controls { opacity: 1; pointer-events: auto; position: static; margin-bottom: 10px; justify-content: flex-end; border: none; box-shadow: none; padding: 0; background: transparent; } }

.control-btn { padding: 4px; border-radius: 4px; border: none; background: transparent; cursor: pointer; color: #6b7280; display: flex; align-items: center; justify-content: center; }
.control-btn:hover { background: #f3f4f6; color: #000; }
.control-btn.danger { color: #ef4444; }
.control-btn.danger:hover { background: #fee2e2; }

/* Editor Fields */
.heading-row { display: flex; gap: 8px; align-items: center; }
.type-select { border: 1px solid #d1d5db; border-radius: 4px; padding: 6px; font-size: 0.875rem; background: #f9fafb; cursor: pointer; }
.heading-text { flex: 1; border: none; border-bottom: 1px solid #d1d5db; padding: 6px; font-family: serif; font-weight: bold; font-size: 1.25rem; outline: none; background: transparent; }
.heading-text:focus { border-color: #3b82f6; }

.body-textarea { width: 100%; min-height: 100px; padding: 12px; border: none; background: #f9fafb; border-left: 3px solid transparent; outline: none; resize: vertical; font-family: sans-serif; line-height: 1.6; border-radius: 4px; font-size: 1rem; }
.body-textarea:focus { background: #fff; border-left-color: #3b82f6; box-shadow: inset 0 0 0 1px #e5e7eb; }

.img-editor { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.img-preview { width: 100px; flex-shrink: 0; position: relative; }
.img-thumb { width: 100px; height: 100px; object-fit: cover; border-radius: 4px; border: 1px solid #e5e7eb; background: #f3f4f6; }
.img-remove { position: absolute; top: -6px; left: -6px; background: white; border: 1px solid #e5e7eb; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #ef4444; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

.img-controls { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 200px; }
.control-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.control-group { display: flex; flex-direction: column; gap: 4px; }
.control-label { font-size: 0.7rem; font-weight: bold; color: #6b7280; text-transform: uppercase; }

.btn-group { display: flex; border: 1px solid #e5e7eb; border-radius: 4px; overflow: hidden; }
.group-btn { padding: 4px 8px; border: none; background: #f9fafb; cursor: pointer; font-size: 0.75rem; color: #6b7280; border-right: 1px solid #e5e7eb; }
.group-btn:last-child { border-right: none; }
.group-btn:hover { background: #f3f4f6; }
.group-btn.active { background: #fff; color: #2563eb; font-weight: bold; box-shadow: inset 0 0 4px rgba(0,0,0,0.05); }

.caption-input { width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.875rem; outline: none; }

.html-editor-area { width: 100%; min-height: 120px; font-family: monospace; font-size: 0.85rem; padding: 12px; border: 1px solid #333; background: #1e1e1e; color: #0f0; border-radius: 4px; }
.divider-preview { height: 1px; background: #a2a9b1; margin: 20px 0; width: 100%; position: relative; }
.divider-preview::after { content: "Horizontal Rule"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: #fff; padding: 0 8px; color: #9ca3af; font-size: 0.75rem; }

/* Toolbar */
.bottom-toolbar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid #e5e7eb; padding: 8px 16px; box-shadow: 0 -4px 10px rgba(0,0,0,0.05); z-index: 50; }
.toolbar-inner { max-width: 400px; margin: 0 auto; display: flex; justify-content: space-around; align-items: center; }
.tool-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; cursor: pointer; color: #6b7280; transition: transform 0.1s; }
.tool-btn:active { transform: scale(0.95); }
.tool-btn:hover { color: #2563eb; }
.tool-icon-bg { background: #f3f4f6; padding: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
.tool-label { font-size: 10px; font-weight: bold; }
.hidden-file { display: none; }

/* Views */
.center-view { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; padding: 16px; }
.card { background: #fff; padding: 24px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); width: 100%; max-width: 400px; border: 1px solid #e5e7eb; }
.card-header { font-size: 1.5rem; font-weight: bold; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; color: #111; }
.card-text { font-size: 0.875rem; color: #6b7280; margin-bottom: 16px; }
.input-field { width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 4px; margin-bottom: 16px; outline: none; font-size: 1rem; }
.input-field:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.btn-full { width: 100%; padding: 10px; background: #2563eb; color: white; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; font-size: 1rem; }
.btn-full:hover { background: #1d4ed8; }
.link-cancel { background: none; border: none; color: #6b7280; font-size: 0.875rem; cursor: pointer; text-decoration: underline; margin-top: 16px; display: block; width: 100%; text-align: center; }

.search-container { max-width: 800px; margin: 0 auto; padding: 20px; }
.search-title { font-size: 1.5rem; font-weight: bold; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.search-list { border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; overflow: hidden; }
.search-item { padding: 16px; border-bottom: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background 0.1s; }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #eff6ff; }
.item-title { font-family: serif; font-size: 1.125rem; color: #2563eb; margin-bottom: 4px; }
.item-meta { font-size: 0.75rem; color: #9ca3af; }

.empty-state { text-align: center; padding: 40px; color: #9ca3af; font-style: italic; }
.not-found-view { padding: 60px 24px; border: 1px solid #e5e7eb; background-color: #fff; margin-top: 24px; border-radius: 12px; text-align: center; max-width: 600px; margin-left: auto; margin-right: auto; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.not-found-icon { width: 80px; height: 80px; background: #eff6ff; color: #2563eb; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 24px; }
.not-found-title { font-family: 'Linux Libertine', Georgia, serif; font-size: 2.2rem; margin: 0 0 16px; color: #111; line-height: 1.2; }
.sys-msg { color: #4b5563; font-size: 1.1rem; line-height: 1.6; margin-bottom: 40px; max-width: 480px; margin-left: auto; margin-right: auto; }
.create-link { color: #2563eb; text-decoration: none; font-weight: bold; }
.create-link:hover { text-decoration: underline; }
.create-btn-wrapper { margin-top: 0; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.secondary-actions { margin-top: 32px; font-size: 0.9rem; color: #9ca3af; }
.secondary-actions a { color: #6b7280; }

.clearfix::after { content: ""; clear: both; display: table; }

/* Resize Handles */
.resizable { position: relative; }
.resize-handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 10; opacity: 0; transition: opacity 0.2s; }
.resize-handle:hover, .resizable:hover .resize-handle { opacity: 1; }
.resize-handle-left { left: -4px; background: linear-gradient(to right, transparent, rgba(37, 99, 235, 0.3), transparent); }
.resize-handle-right { right: -4px; background: linear-gradient(to right, transparent, rgba(37, 99, 235, 0.3), transparent); }
.resize-handle::before { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 4px; height: 40px; background: #2563eb; border-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* Mobile: disable resize on small screens */
@media(max-width: 600px) {
    .resize-handle { display: none; }
}

