/* static/css/notes/notes-widget.css */

/* Плавающая кнопка */
.notes-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #607bf7;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(96, 123, 247, 0.4);
    z-index: 1500;
    transition: transform .15s, background .15s;
}
.notes-fab:hover { background: #7f96fa; transform: translateY(-2px); }
.notes-fab:active { transform: translateY(0); }

@media (max-width: 768px) {
    .notes-fab {
        display: none;
    }
}

/* Панель */
.notes-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 35%;
    max-width: 100vw;
    height: 70vh;
    background: #1e1e24;
    color: #fff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -8px 32px rgba(0,0,0,.5);
    transform-origin: right bottom;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
    transition:
        transform .40s cubic-bezier(.4, 0, .6, 1),
        opacity   .30s ease-in;
    z-index: 1600;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notes-panel.open {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
    transition:
        transform .4s cubic-bezier(.2, .8, .2, 1),
        opacity   .3s ease-out;
}

.notes-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
    min-height: 52px;
    position: relative;
}
.notes-panel-title-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    text-align: center;
    line-height: 1.2;
}

.notes-panel-title { font-size: 1.4rem; }

.notes-panel-actions { display: flex; gap: 8px; align-items: center; }

.notes-panel-title-editor { display: none; }
.notes-panel.editing .notes-panel-title-list   { display: none; }
.notes-panel.editing .notes-panel-title-editor { display: inline; }

.notes-icon-btn {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    transition: background .15s, color .15s;
}
.notes-icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* Две канвы */
.notes-canvas {
    position: absolute;
    top: 56px;           /* высота шапки */
    left: 0; right: 0; bottom: 0;
    overflow-y: auto;
    padding: 12px;
    transition: transform .25s ease-out, opacity .25s;
}
.notes-canvas-list    { transform: translateX(0);    opacity: 1; }
.notes-canvas-editor  { transform: translateX(100%); opacity: 0; pointer-events: none; }
.notes-panel.editing .notes-canvas-list   { transform: translateX(-100%); opacity: 0; pointer-events: none; }
.notes-panel.editing .notes-canvas-editor { transform: translateX(0);    opacity: 1; pointer-events: auto; }

/* Список заметок */
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-item {
    position: relative;
    padding-right: 36px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    position: relative;
    transition: background .15s, border-color .15s;
}
.note-item:hover { background: rgba(255,255,255,.08); }
.note-item.pinned { border-color: rgba(96,123,247,.5); }
.note-item.pinned::before {
    content: '';
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    background: #607bf7;
    border-radius: 0 3px 3px 0;
}
.note-item-title {
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-item-preview {
    font-size: .8rem;
    color: #aaa;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.note-item-meta {
    font-size: .7rem;
    color: #666;
    margin-top: 6px;
}

.notes-editor { display: flex; flex-direction: column; height: 100%; }
.notes-editor-title {
    width: 100%;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-bottom: none;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 10px 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    outline: none;
}

.notes-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 6px;
    border-left: 1px solid rgba(255,255,255,.08);
    border-right: 1px solid rgba(255,255,255,.08);
    border-top: none;
    border-bottom: none;
    background: rgba(255,255,255,.03);
    flex-shrink: 0;
    flex-wrap: wrap;
    border-radius: 0;
}

.notes-editor-content {
    flex: 1;
    min-height: 200px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    padding: 10px 25px;
    color: #fff;
    line-height: 1.5;
    outline: none;
    resize: none;
    font-family: inherit;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-color) var(--scrollbar-bg);
}
.notes-editor-content:empty::before,
.notes-editor-content:has(> br:only-child)::before {
    content: attr(data-placeholder);
    color: #666;
    pointer-events: none;
}

.tb-btn {
    background: transparent;
    border: none;
    color: #bbb;
    cursor: pointer;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    transition: background .12s, color .12s;
}
.tb-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.tb-btn:active { background: rgba(255,255,255,.14); }

.tb-sep {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,.1);
    margin: 0 4px;
}

.tb-btn.active {
    background: rgba(96,123,247,.25);
    color: #7f96fa;
}
.tb-btn:disabled {
    opacity: .3;
    cursor: default;
    pointer-events: none;
}

.notes-editor:focus-within .notes-editor-title,
.notes-editor:focus-within .notes-editor-toolbar,
.notes-editor:focus-within .notes-editor-content {
    border-color: #607bf7;
}

.notes-editor-footer {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.notes-editor-footer .spacer { flex: 1; }
.notes-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,.15);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    transition: background .15s, border-color .15s;
}
.notes-btn:hover { background: rgba(255,255,255,.06); }
.notes-btn.primary { background: #607bf7; border-color: #607bf7; }
.notes-btn.primary:hover { background: #7f96fa; border-color: #7f96fa; }
.notes-btn.danger { color: #ff6b6b; border-color: rgba(255,107,107,.4); }
.notes-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Пустое состояние */
.notes-empty {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-size: .9rem;
}

.notes-icon-btn.spinning svg {
    animation: notes-spin .8s linear infinite;
}
@keyframes notes-spin {
    from { transform: rotate(0); }
    to   { transform: rotate(360deg); }
}

.notes-panel-title-editor,
.notes-panel-back { display: none; }
.notes-panel.editing .notes-panel-title-list { display: none; }
.notes-panel.editing .notes-panel-title-editor { display: inline; }
.notes-panel.editing .notes-panel-back { display: flex; }
.notes-panel.editing .notes-icon-btn.js-new-note { display: none; }
.notes-panel.editing .js-refresh { display: none; }

.notes-panel .js-save-note { display: none; }
.notes-panel.editing .js-save-note { display: inline-flex; }

.js-save-note:disabled {
    opacity: 0.35;
    cursor: default;
    color: #666;
}
.js-save-note:disabled:hover {
    background: transparent;
    color: #666;
}

.js-save-note:not(:disabled) {
    color: #607bf7;
}
.js-save-note:not(:disabled):hover {
    color: #7f96fa;
    background: rgba(96,123,247,.12);
}

.js-save-note.dirty-pulse:not(:disabled) {
    animation: save-pulse 1.4s ease-in-out infinite;
}
@keyframes save-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

.notes-pin-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color .15s, background .15s;
    z-index: 1;
}
.notes-pin-btn:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

/* по умолчанию — контур (откреплено) */
.notes-pin-btn .icon-pin-on  { display: none; }
.notes-pin-btn .icon-pin-off { display: block; }

/* закреплённая заметка — залитый синий */
.note-item.pinned .notes-pin-btn { color: #607bf7; }
.note-item.pinned .notes-pin-btn .icon-pin-on  { display: block; }
.note-item.pinned .notes-pin-btn .icon-pin-off { display: none; }

.notes-editor-status {
    display: none;
    font-size: .7rem;
    color: #666;
    margin-top: 2px;
    min-height: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.notes-editor-status:not(:empty) {
    display: block;
}
.notes-editor-status.dirty { color: #ffb84d; }
.notes-editor-status.saved { color: #4caf50; }

.notes-panel .js-delete-note { display: none; }
.notes-panel.editing .js-delete-note {
    display: inline-flex;
    color: #ff6b6b;
}
.notes-panel.editing .js-delete-note:hover {
    background: rgba(255,107,107,.12);
    color: #ff8a8a;
}

.notes-panel.editing .js-close-panel { display: none; }

.notes-editor-content b,
.notes-editor-content strong {
    font-weight: 700;
}

.notes-editor-content i,
.notes-editor-content em {
    font-style: italic;
}

.notes-editor-content u {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.notes-editor-content s,
.notes-editor-content strike,
.notes-editor-content del {
    text-decoration: line-through;
}

.notes-editor-content code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: rgba(255,255,255,.08);
    padding: 1px 4px;
    border-radius: 4px;
}

.notes-editor-content ul,
.notes-editor-content ol {
    padding-left: 20px;
    margin: 4px 0;
}

.notes-editor-content li {
    margin: 2px 0;
}