/* ============================================
   Notes Widget — Floating Chat Memo
   ============================================ */

/* Session card badge icon */
.notes-badge-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: #2dd4bf;
    vertical-align: middle;
    margin-left: 4px;
}
.notes-badge-count {
    position: absolute;
    top: -5px;
    right: -7px;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    background: #2dd4bf;
    color: #0f172a;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 14px;
}

/* Toggle button */
#notesToggleBtn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: grab;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: background 0.2s, transform 0.2s;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
#notesToggleBtn:hover {
    background: var(--primary-hover);
}
#notesToggleBtn:active {
    cursor: grabbing;
}

/* Badge */
#notesBadge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 18px;
}
#notesBadge.visible { display: flex; }

/* Panel */
.notes-panel {
    position: fixed;
    width: 320px;
    max-height: 480px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}
.notes-panel.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Header */
.notes-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}
.notes-header-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.notes-header-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}
.notes-header-btn:hover { color: var(--text-primary); background: var(--bg-secondary); }
.notes-header-btn--danger:hover { color: var(--danger); }

/* Messages area */
#notesMessages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
    max-height: 340px;
}

/* Empty state */
.notes-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

/* Message bubble */
.notes-msg {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 8px 12px;
    max-width: 100%;
    word-wrap: break-word;
}
.notes-msg-text {
    font-size: 13px;
    color: var(--text-primary);
    white-space: pre-wrap;
    line-height: 1.4;
}
.notes-msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}
/* Action buttons (edit + delete) */
.notes-msg-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.notes-msg:hover .notes-msg-actions { opacity: 1; }

.notes-msg-edit,
.notes-msg-del {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notes-msg-del {
    font-size: 14px;
    line-height: 1;
}
.notes-msg-edit:hover { color: var(--primary); background: var(--bg-tertiary); }
.notes-msg-del:hover { color: var(--danger); background: var(--bg-tertiary); }

/* Edit mode */
.notes-msg--editing { background: var(--bg-tertiary); }
.notes-edit-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    padding: 6px 8px;
    resize: none;
    min-height: 32px;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
    box-sizing: border-box;
}
.notes-edit-input:focus { outline: none; }
.notes-edit-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 6px;
}
.notes-edit-save,
.notes-edit-cancel {
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    padding: 3px 10px;
    font-weight: 600;
}
.notes-edit-save {
    background: var(--primary);
    color: #fff;
}
.notes-edit-save:hover { background: var(--primary-hover); }
.notes-edit-cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.notes-edit-cancel:hover { background: var(--bg-tertiary); border-color: var(--text-muted); }

/* Input area */
.notes-input-area {
    display: flex;
    align-items: flex-end;
    padding: 8px 12px 12px;
    border-top: 1px solid var(--border-color);
    gap: 8px;
}
#notesInput {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    padding: 8px 10px;
    resize: none;
    min-height: 36px;
    max-height: 80px;
    line-height: 1.4;
    font-family: inherit;
}
#notesInput::placeholder { color: var(--text-muted); }
#notesInput:focus { outline: none; border-color: var(--primary); }
#notesSendBtn {
    background: var(--primary);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
#notesSendBtn:hover { background: var(--primary-hover); }

/* ── Browse view ── */
.notes-browse-search {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-bottom: 8px;
    background: var(--bg-primary);
}
.notes-browse-search-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    padding: 7px 10px;
    font-family: inherit;
    box-sizing: border-box;
}
.notes-browse-search-input::placeholder { color: var(--text-muted); }
.notes-browse-search-input:focus { outline: none; border-color: var(--primary); }

.notes-browse-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notes-browse-item {
    padding: 8px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.notes-browse-item:hover { background: var(--bg-secondary); }
.notes-browse-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notes-browse-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Read view ── */
.notes-msg--readonly {
    cursor: default;
}
.notes-msg--readonly .notes-msg-del { display: none; }

.notes-read-group {
    display: inline-block;
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 400px) {
    .notes-panel {
        left: 8px;
        right: 8px;
        width: auto;
        bottom: 80px;
    }
}
