/* ============================================================
   Notlarım — Rich-text editor
   ============================================================ */

.editor-shell {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--topbar-h));
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1px;
    padding: 6px var(--sp-5);
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--bg) 96%, transparent),
        color-mix(in srgb, var(--bg-subtle) 92%, transparent));
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    position: sticky;
    top: var(--topbar-h);
    z-index: 4;
    box-shadow: 0 1px 0 var(--border), 0 2px 4px -2px rgba(0,0,0,.04);
}
.editor-toolbar .sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 6px;
    align-self: center;
}
.editor-toolbar button {
    position: relative;
    height: 30px;
    min-width: 30px;
    padding: 0 7px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background var(--dur-fast) var(--ease),
                color      var(--dur-fast) var(--ease),
                transform  var(--dur-fast) var(--ease);
}
.editor-toolbar button:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.editor-toolbar button:active { transform: translateY(1px); }
.editor-toolbar button.active {
    background: var(--accent-soft);
    color: var(--accent-text);
}
.editor-toolbar button.active::after {
    content: "";
    position: absolute;
    left: 25%; right: 25%; bottom: 2px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
}

/* Color buttons with bottom color bar */
.editor-toolbar .color-btn { flex-direction: column; gap: 0; padding-bottom: 2px; }
.editor-toolbar .color-btn .color-bar {
    width: 16px; height: 3px;
    border-radius: 2px;
    margin-top: 1px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}

/* Kod bloğu placeholder — boş <code data-placeholder> için hint metni */
.editor-content pre > code[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    font-style: italic;
    pointer-events: none;
}

.editor-color-pop {
    position: absolute;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
}
.editor-color-pop .color-grid {
    display: grid;
    grid-template-columns: repeat(6, 22px);
    gap: 4px;
}
.editor-color-pop button {
    width: 22px; height: 22px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,.1);
    cursor: pointer;
    padding: 0;
    transition: transform var(--dur-fast) var(--ease);
}
.editor-color-pop button:hover { transform: scale(1.15); }
.editor-color-pop button.trans {
    background: linear-gradient(135deg, transparent 47%, var(--danger) 47%, var(--danger) 53%, transparent 53%) !important;
    border-color: var(--border-strong);
}
.editor-color-pop .color-custom {
    border-top: 1px solid var(--border);
    padding-top: 8px;
}
.editor-color-pop .custom-swatch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.editor-color-pop .custom-swatch input[type="color"] {
    width: 22px;
    height: 22px;
    border: 1px solid rgba(0,0,0,.1);
    border-radius: 6px;
    padding: 0;
    cursor: pointer;
    background: conic-gradient(#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00);
}
.editor-color-pop .custom-swatch input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.editor-color-pop .custom-swatch input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.editor-color-pop .custom-swatch:hover { color: var(--text); }
.editor-toolbar select {
    height: 28px;
    width: auto;
    max-width: 110px;
    padding: 0 4px;
    background: transparent;
    border: 0;
    font-size: var(--fs-xs);
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
    -webkit-appearance: menulist;
       -moz-appearance: menulist;
            appearance: menulist;
}
.editor-toolbar select:hover { background: var(--bg-hover); border-radius: var(--r-sm); }
.editor-toolbar select option {
    background: var(--bg);
    color: var(--text);
    font-weight: 500;
    padding: 6px 10px;
}

.editor-wrap {
    flex: 1;
    padding: var(--sp-7) clamp(var(--sp-5), 4vw, var(--sp-8)) var(--sp-10);
    max-width: var(--editor-max);
    margin: 0 auto;
    width: 100%;
}
.crumb {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.crumb-label {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--text-subtle);
    user-select: none;
    white-space: nowrap;
}
.crumb select {
    background: transparent;
    border: 0;
    height: 22px;
    max-width: 140px;
    padding: 0 2px;
    font-size: 12px;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    outline: none;
}
.crumb select:focus { box-shadow: none; }
/* Focus mode (sidebar hidden) OR canvas sidebar collapsed: widen editor */
.app.focus-mode .editor-wrap,
.app.cv-collapsed .editor-wrap {
    max-width: 1700px;
}

.editor-title-row {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}
.editor-title-row .editor-title { flex: 1; min-width: 0; }
.editor-title-row .editor-tags-inline {
    flex: 0 0 auto;
    width: 280px;
    align-self: center;
}
.editor-title {
    width: 100%;
    border: 0;
    background: transparent;
    font-size: 2.25rem;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text);
    padding: var(--sp-3) 0;
    resize: none;
    height: auto;
    min-height: auto;
    overflow: hidden;
    outline: none;
}
@media (max-width: 720px) {
    .editor-title-row { flex-direction: column; gap: var(--sp-2); }
    .editor-title-row .editor-tags-inline { max-width: none; width: 100%; margin-top: 0; }
}
.editor-title:focus { box-shadow: none; border: 0; }
.editor-title::placeholder { color: var(--text-subtle); font-weight: 600; }

.editor-meta {
    display: flex;
    gap: var(--sp-3);
    color: var(--text-subtle);
    font-size: var(--fs-xs);
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border);
}

.editor-content {
    font-size: var(--fs-lg);
    line-height: var(--lh-relaxed);
    color: var(--text);
    outline: none;
    min-height: 60vh;
    padding-bottom: 40vh;
    caret-color: var(--accent);
}
.editor-content:empty::before {
    content: attr(data-placeholder);
    color: var(--text-subtle);
    pointer-events: none;
}

/* Content styles */
.editor-content h1, .editor-content h2, .editor-content h3 {
    font-weight: 700;
    letter-spacing: -.015em;
    line-height: 1.25;
    margin: var(--sp-6) 0 var(--sp-2);
}
.editor-content h1 { font-size: 1.75rem; }
.editor-content h2 { font-size: 1.4rem; }
.editor-content h3 { font-size: 1.15rem; }
.editor-content p { margin: var(--sp-3) 0; }
.editor-content ul, .editor-content ol { padding-left: 1.75em; margin: var(--sp-3) 0; }
.editor-content ul { list-style: disc; }
.editor-content ol { list-style: decimal; }
.editor-content li { margin: var(--sp-1) 0; }
.editor-content blockquote {
    border-left: 3px solid var(--accent);
    padding: var(--sp-2) var(--sp-4);
    color: var(--text-muted);
    margin: var(--sp-4) 0;
    background: var(--bg-subtle);
    border-radius: var(--r-sm);
}
.editor-content code {
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: var(--r-xs);
    font-family: var(--font-mono);
    font-size: .9em;
    color: var(--accent-text);
    border: 1px solid var(--border);
}
.editor-content pre {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--sp-4);
    margin: var(--sp-4) 0;
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    line-height: var(--lh-normal);
    overflow-x: auto;
}
.editor-content pre code {
    background: transparent;
    padding: 0;
    border: 0;
    color: var(--text);
}
.editor-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    cursor: pointer;
}
.editor-content a:hover { text-decoration-thickness: 2px; }
.editor-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--r-md);
    margin: var(--sp-4) 0;
    box-shadow: var(--shadow-sm);
    cursor: zoom-in;
    transition: outline-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
    outline: 2px solid transparent;
}
.editor-content img:hover { box-shadow: var(--shadow-md); }
.editor-content img.img-selected {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--accent-soft);
}

/* Floating image toolbar (Open / Delete) */
.editor-img-toolbar {
    position: absolute;
    z-index: 50;
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
}
.editor-img-toolbar button {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.editor-img-toolbar button:hover { background: var(--bg-hover); color: var(--text); }
.editor-img-toolbar button[data-act="delete"]:hover { background: var(--bg-hover); color: var(--danger); }

/* Floating URL preview on link hover */
.editor-link-tip {
    position: absolute;
    z-index: 50;
    max-width: 360px;
    padding: 6px 10px;
    background: var(--text);
    color: var(--bg);
    font-size: var(--fs-xs);
    font-family: var(--font-mono);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.editor-link-tip.visible { opacity: 1; transform: translateY(0); }
.editor-content hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--sp-6) 0;
}
.editor-content table {
    border-collapse: collapse;
    width: 100%;
    margin: var(--sp-4) 0;
    font-size: var(--fs-sm);
    table-layout: auto;
}
.editor-content th, .editor-content td {
    border: 1px solid var(--border);
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
    vertical-align: top;
    position: relative;
    min-width: 40px;
}
.editor-content th::after, .editor-content td::after {
    content: "";
    position: absolute;
    top: 0; right: -3px; bottom: 0;
    width: 6px;
    cursor: col-resize;
}
.editor-content th::before, .editor-content td::before {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -3px;
    height: 6px;
    cursor: row-resize;
}
.editor-content th {
    background: var(--bg-subtle);
    font-weight: 600;
}
.editor-content ul[data-type="checkbox"] { list-style: none; padding-left: 0; }
.editor-content ul[data-type="checkbox"] > li {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    padding-left: 0;
}
.editor-content ul[data-type="checkbox"] > li > input[type="checkbox"] {
    margin-top: .4em;
    width: 16px; height: 16px;
    accent-color: var(--accent);
    flex-shrink: 0;
}
.editor-content ul[data-type="checkbox"] > li > .cb-text {
    display: inline;
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
/* Highlight fires whenever the real <input> is :checked (sibling),
   or the JS fallback has added the .checked class on the <li>. */
.editor-content ul[data-type="checkbox"] > li.checked > .cb-text,
.editor-content ul[data-type="checkbox"] > li > input[type="checkbox"]:checked ~ .cb-text {
    background-color: rgba(255, 224, 70, .55);
    color: rgba(60, 50, 0, .85);
    padding: 1px 4px;
    margin: 0 -4px;
    border-radius: 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    box-shadow: inset 0 -2px 0 rgba(255, 200, 0, .35);
}
[data-theme="dark"] .editor-content ul[data-type="checkbox"] > li.checked > .cb-text,
[data-theme="midnight"] .editor-content ul[data-type="checkbox"] > li.checked > .cb-text,
[data-theme="solarized-dark"] .editor-content ul[data-type="checkbox"] > li.checked > .cb-text,
[data-theme="nord"] .editor-content ul[data-type="checkbox"] > li.checked > .cb-text,
[data-theme="dark"] .editor-content ul[data-type="checkbox"] > li > input[type="checkbox"]:checked ~ .cb-text,
[data-theme="midnight"] .editor-content ul[data-type="checkbox"] > li > input[type="checkbox"]:checked ~ .cb-text,
[data-theme="solarized-dark"] .editor-content ul[data-type="checkbox"] > li > input[type="checkbox"]:checked ~ .cb-text,
[data-theme="nord"] .editor-content ul[data-type="checkbox"] > li > input[type="checkbox"]:checked ~ .cb-text {
    background-color: rgba(255, 215, 0, .32);
    color: rgba(255, 235, 170, .9);
}

/* Image upload preview */
.editor-img-loading {
    display: inline-block;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: var(--fs-xs);
    border-radius: var(--r-md);
    margin: var(--sp-2) 0;
}

/* Save status indicator */
.save-status {
    font-size: var(--fs-xs);
    color: var(--text-subtle);
    transition: color var(--dur) var(--ease);
}
.save-status.saving  { color: var(--warn); }
.save-status.saved   { color: var(--success); }
.save-status.error   { color: var(--danger); }

/* Word / character counter below editor */
.editor-counter {
    margin-top: var(--sp-4);
    padding: var(--sp-2) 0;
    font-size: var(--fs-xs);
    color: var(--text-subtle);
    text-align: right;
    border-top: 1px dashed var(--border);
    user-select: none;
}

/* Lightbox overlay for inline images */
.editor-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 18, .88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4vh 4vw;
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
    cursor: zoom-out;
}
.editor-lightbox.visible { opacity: 1; }
.editor-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--r-md);
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
    object-fit: contain;
    cursor: default;
}
.editor-lightbox .lb-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
}
.editor-lightbox .lb-close:hover { background: rgba(255,255,255,.22); }
