/**
 * NotesAi — Recent drawer (#chatSidebar)
 * Same shell geometry as the hamburger `.canvas-nav-panel` (full-height right drawer).
 */

.notesai-workspace #chatDrawerBackdrop.canvas-nav-backdrop {
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

.notesai-workspace #chatSidebar.canvas-chat-sidebar {
    --ln-sidebar-bg: #ffffff;
    --ln-sidebar-border: #e6e9ef;
    --ln-sidebar-title: #6b7280;
    --ln-sidebar-text: #1f2937;
    --ln-sidebar-muted: #64748b;
    --ln-sidebar-card-bg: #f9fafb;
    --ln-sidebar-card-border: #e5e7eb;
    --ln-sidebar-card-hover: color-mix(in srgb, #f9fafb, #ffffff 35%);
    --ln-sidebar-card-hover-border: #cbd5e1;
    --ln-sidebar-active-bg: #eef2ff;
    --ln-sidebar-active-border: color-mix(in srgb, #4f46e5, #ffffff 68%);
    --ln-sidebar-active-text: #3730a3;
    --ln-sidebar-shadow:
        -8px 0 28px rgba(15, 23, 42, 0.12),
        -1px 0 0 rgba(15, 23, 42, 0.06);

    /* Match hamburger `.canvas-nav-panel` position + size */
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    left: auto !important;
    height: 100% !important;
    width: 100% !important;
    max-width: min(360px, 92vw) !important;
    padding: 84px 0 20px !important;
    border-radius: 14px 0 0 14px !important;
    border: none !important;
    border-left: 1px solid var(--ln-sidebar-border) !important;
    background: var(--ln-sidebar-bg) !important;
    box-shadow: var(--ln-sidebar-shadow) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    display: block !important;
    box-sizing: border-box !important;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 10052;
}

/* Keep layout for slide animation while [hidden] is set */
.notesai-workspace #chatSidebar.canvas-chat-sidebar[hidden] {
    display: block !important;
    pointer-events: none;
}

.notesai-workspace #chatSidebar.canvas-chat-sidebar.is-open,
.notesai-workspace #chatSidebar.canvas-chat-sidebar.open {
    transform: translateX(0);
    pointer-events: auto;
}

/* —— Header (same absolute chrome as hamburger) —— */
.notesai-workspace #chatSidebar .canvas-nav-panel-header {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    flex-shrink: 0;
    min-height: 60px;
    padding: 11px 12px 11px 16px;
    background: var(--ln-sidebar-bg);
    border-bottom: 1px solid var(--ln-sidebar-border);
    align-items: flex-start;
    box-sizing: border-box;
}

.notesai-workspace #chatSidebar .canvas-chat-sidebar-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.notesai-workspace #chatSidebar .canvas-chat-sidebar-title {
    text-transform: none;
    letter-spacing: -0.02em;
    font-size: 1.0625rem;
    font-weight: 650;
    color: #0f172a;
    line-height: 1.2;
}

.notesai-workspace #chatSidebar .canvas-chat-sidebar-subtitle {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    font-weight: 500;
    color: #94a3b8;
    letter-spacing: 0.01em;
    text-transform: none;
}

.notesai-workspace #chatSidebar .chat-new-thread-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 4px 11px;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.2;
    box-shadow: none;
}

.notesai-workspace #chatSidebar .chat-new-thread-btn:hover {
    background: #e0e7ff;
    border-color: #a5b4fc;
    color: #3730a3;
}

.notesai-workspace #chatSidebar .chat-new-thread-plus {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.notesai-workspace #chatSidebar .canvas-chat-sidebar-close {
    width: 32px;
    height: 32px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #fff;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0;
    cursor: pointer;
}

.notesai-workspace #chatSidebar .canvas-chat-sidebar-close svg {
    width: 15px;
    height: 15px;
}

.notesai-workspace #chatSidebar .canvas-chat-sidebar-close:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

/* —— Body —— */
.notesai-workspace #chatSidebar .canvas-chat-sidebar-body {
    min-height: 100% !important;
    height: auto !important;
    overflow: visible;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
}

/* —— Filter (sticky top of body) —— */
.notesai-workspace #chatSidebar .chat-filter-row {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0;
    padding: 12px 14px 10px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
}

.notesai-workspace #chatSidebar .chat-filter-row-inner {
    gap: 8px;
    align-items: center;
}

.notesai-workspace #chatSidebar .chat-filter-search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.notesai-workspace #chatSidebar .chat-filter-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: #94a3b8;
    pointer-events: none;
}

.notesai-workspace #chatSidebar .chat-filter-search.sidebar-filter {
    margin-bottom: 0;
    width: 100%;
    height: 36px;
    padding: 0 12px 0 34px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 13px;
    color: #0f172a;
    box-sizing: border-box;
}

.notesai-workspace #chatSidebar .chat-filter-search.sidebar-filter::placeholder {
    color: #94a3b8;
}

.notesai-workspace #chatSidebar .chat-filter-search.sidebar-filter:focus {
    outline: none;
    border-color: #a5b4fc;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.16);
}

/* Hide native search clear styling that can look messy */
.notesai-workspace #chatSidebar .chat-filter-search.sidebar-filter::-webkit-search-decoration,
.notesai-workspace #chatSidebar .chat-filter-search.sidebar-filter::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.notesai-workspace #chatSidebar .chat-filter-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.notesai-workspace #chatSidebar .chat-filter-toggle svg,
.notesai-workspace #chatSidebar .chat-filter-icon {
    width: 16px;
    height: 16px;
    display: block;
}

.notesai-workspace #chatSidebar .chat-filter-toggle:hover,
.notesai-workspace #chatSidebar .chat-filter-toggle[aria-expanded="true"] {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

.notesai-workspace #chatSidebar .chat-filter-hint,
.notesai-workspace #chatSidebar .chat-filter-panel-hint,
.notesai-workspace #chatSidebar .visually-hidden,
.notesai-workspace #chatSidebar .ln-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.notesai-workspace #chatSidebar .chat-filter-panel {
    margin-top: 10px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e8edf5;
    background: #f8fafc;
}

.notesai-workspace #chatSidebar .chat-filter-field {
    margin-bottom: 10px;
}

.notesai-workspace #chatSidebar .chat-filter-field:last-child {
    margin-bottom: 0;
}

.notesai-workspace #chatSidebar .chat-filter-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.02em;
}

.notesai-workspace #chatSidebar .chat-filter-select,
.notesai-workspace #chatSidebar .chat-filter-date {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 13px;
    color: #0f172a;
    box-sizing: border-box;
}

.notesai-workspace #chatSidebar .chat-filter-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.notesai-workspace #chatSidebar .chat-filter-panel-actions {
    margin-top: 4px;
}

.notesai-workspace #chatSidebar .chat-filter-reset {
    width: 100%;
    min-height: 32px;
    font-size: 12px;
}

.notesai-workspace #chatSidebar .chat-active-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0 14px 10px;
    background: #fff;
}

.notesai-workspace #chatSidebar .chat-active-filter-bar[hidden] {
    display: none !important;
}

.notesai-workspace #chatSidebar .chat-active-filter-pill {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: #4338ca;
    background: #eef2ff;
    border-radius: 8px;
    padding: 6px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notesai-workspace #chatSidebar .chat-active-filter-clear {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
}

.notesai-workspace #chatSidebar .chat-active-filter-clear:hover {
    color: #0f172a;
}

/* —— Collapsible sections —— */
.notesai-workspace #chatSidebar .canvas-chat-sidebar-sections {
    padding: 4px 10px 16px;
}

.notesai-workspace #chatSidebar .sidebar-section {
    border-bottom: 1px solid #f1f5f9;
    margin: 0;
    padding: 0 0 2px;
}

.notesai-workspace #chatSidebar .sidebar-section:last-child {
    border-bottom: none;
}

.notesai-workspace #chatSidebar .sidebar-section-toggle {
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.75rem;
    font-weight: 650;
    color: #64748b;
    min-height: 36px;
    padding: 8px 6px;
    border-radius: 8px;
}

.notesai-workspace #chatSidebar .sidebar-section-toggle:hover {
    background: rgba(15, 23, 42, 0.03);
    color: #334155;
}

.notesai-workspace #chatSidebar .sidebar-chevron {
    font-size: 9px;
    color: #94a3b8;
}

.notesai-workspace #chatSidebar .sidebar-section-body {
    padding: 0 0 6px;
}

.notesai-workspace #chatSidebar .sidebar-list li {
    margin-bottom: 1px;
}

.notesai-workspace #chatSidebar .sidebar-link {
    border: none !important;
    background: transparent !important;
    border-radius: 10px;
    padding: 8px 10px;
    min-height: 0;
    box-shadow: none !important;
    font-size: 13px;
    line-height: 1.35;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notesai-workspace #chatSidebar .sidebar-link:hover,
.notesai-workspace #chatSidebar .sidebar-link:focus-visible {
    background: rgba(15, 23, 42, 0.045) !important;
    border-color: transparent !important;
    outline: none;
}

.notesai-workspace #chatSidebar .sidebar-muted {
    font-size: 12px;
    color: #94a3b8;
    padding: 8px 10px;
    margin: 0;
}

@media (max-width: 768px) {
    .notesai-workspace #chatSidebar.canvas-chat-sidebar {
        width: 15rem !important;
        max-width: 82vw !important;
    }
}
