/* ═══════════════════════════════════════════════════════════
   BLOC-NOTES INTELLIGENT — App Stylesheet
   Premium 3-panel notepad UI
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-app: #f0f2f5;
    --bg-sidebar: #ffffff;
    --bg-list: #ffffff;
    --bg-editor: #ffffff;
    --bg-hover: #f7f8fa;
    --bg-active: #eff6ff;
    --bg-input: #f7f8fa;
    --border: #e5e7eb;
    --border-focus: #3b82f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #dbeafe;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --critical: #dc2626;
    --purple: #8b5cf6;
    --nestor-purple: #7c3aed;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ─── App Layout ─── */
.app {
    display: grid;
    grid-template-columns: 240px 320px 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ─── Panel Sidebar (Notebooks) ─── */
.panel-notebooks {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

.brand-name {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.3px;
}

.brand-name span {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.15rem;
}

.notebook-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.notebook-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
}

.notebook-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notebook-item.active {
    background: var(--bg-active);
    color: var(--accent);
    font-weight: 600;
}

.notebook-icon {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.notebook-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.notebook-nestor {
    font-size: 0.55rem;
    color: var(--nestor-purple);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-new-notebook {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0.5rem;
    padding: 0.6rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
}

.btn-new-notebook:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ─── Panel Notes List ─── */
.panel-notes {
    background: var(--bg-list);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-bar {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    transition: all var(--transition);
    outline: none;
}

.search-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: #fff;
}

.search-wrapper {
    position: relative;
}

.search-wrapper::before {
    content: '🔍';
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    pointer-events: none;
}

.filters-bar {
    display: flex;
    gap: 0.3rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.filter-chip {
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-sans);
    color: var(--text-secondary);
}

.filter-chip:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.filter-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.filter-chip.active-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.filter-chip.active-success { background: var(--success); color: #fff; border-color: var(--success); }
.filter-chip.active-purple { background: var(--purple); color: #fff; border-color: var(--purple); }

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.note-card {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 2px;
    border: 1px solid transparent;
}

.note-card:hover {
    background: var(--bg-hover);
}

.note-card.active {
    background: var(--bg-active);
    border-color: var(--accent);
}

.note-card.done {
    opacity: 0.55;
}

.note-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.3;
}

.note-card.done .note-title {
    text-decoration: line-through;
}

.note-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.35rem;
    line-height: 1.4;
}

.note-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.note-tag {
    padding: 0.08rem 0.4rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--accent-light);
    color: var(--accent);
}

.note-tag.tag-bug { background: #fef2f2; color: #dc2626; }
.note-tag.tag-urgent { background: #fef3c7; color: #d97706; }
.note-tag.tag-idea { background: #f0fdf4; color: #16a34a; }
.note-tag.tag-nestor { background: #f5f3ff; color: #7c3aed; }

.note-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: auto;
}

.priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.priority-dot.critical { background: var(--critical); }
.priority-dot.high { background: var(--danger); }
.priority-dot.medium { background: var(--warning); }
.priority-dot.low { background: var(--success); }

.pin-icon {
    font-size: 0.65rem;
}

.nestor-badge {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--nestor-purple);
    background: #f5f3ff;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
}

.btn-new-note {
    margin: 0.5rem;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex-shrink: 0;
    font-family: var(--font-sans);
}

.btn-new-note:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.notes-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 0.5rem;
    padding: 2rem;
    text-align: center;
}

.notes-empty .empty-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

.notes-empty p {
    font-size: 0.85rem;
}

/* ─── Panel Editor ─── */
.panel-editor {
    background: var(--bg-editor);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.editor-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.toolbar-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.toolbar-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.toolbar-btn.danger:hover {
    background: #fef2f2;
    border-color: var(--danger);
    color: var(--danger);
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

.toolbar-spacer { flex: 1; }

.toolbar-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 0.75rem;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
}

.toolbar-select:focus {
    border-color: var(--border-focus);
}

.editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.5rem;
}

.editor-title {
    font-size: 1.5rem;
    font-weight: 800;
    border: none;
    outline: none;
    width: 100%;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    font-family: var(--font-sans);
    background: transparent;
    margin-bottom: 0.25rem;
}

.editor-title::placeholder {
    color: var(--text-muted);
}

.editor-tags-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.editor-tag {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.editor-tag .remove-tag {
    margin-left: 0.2rem;
    font-size: 0.6rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition);
}

.editor-tag:hover .remove-tag {
    opacity: 1;
}

.tag-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.7rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    min-width: 60px;
}

.tag-input::placeholder {
    color: var(--text-muted);
}

.editor-content {
    flex: 1;
    border: none;
    outline: none;
    width: 100%;
    resize: none;
    font-size: 0.9rem;
    line-height: 1.7;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: transparent;
}

.editor-content::placeholder {
    color: var(--text-muted);
}

.editor-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.editor-footer .save-status {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.editor-footer .save-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.editor-footer .save-dot.unsaved {
    background: var(--warning);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.nestor-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
    background: transparent;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.nestor-toggle:hover {
    border-color: var(--nestor-purple);
    color: var(--nestor-purple);
}

.nestor-toggle.active {
    background: #f5f3ff;
    border-color: var(--nestor-purple);
    color: var(--nestor-purple);
}

.nestor-toggle .toggle-track {
    width: 28px;
    height: 14px;
    border-radius: 7px;
    background: var(--border);
    position: relative;
    transition: all var(--transition);
}

.nestor-toggle.active .toggle-track {
    background: var(--nestor-purple);
}

.nestor-toggle .toggle-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all var(--transition);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.nestor-toggle.active .toggle-thumb {
    left: 16px;
}

/* ─── Editor Empty State ─── */
.editor-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 0.75rem;
    padding: 2rem;
}

.editor-empty .empty-icon {
    font-size: 3rem;
    opacity: 0.3;
}

.editor-empty h3 {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.editor-empty p {
    font-size: 0.85rem;
    text-align: center;
    max-width: 280px;
    line-height: 1.5;
}

/* ─── Utilities ─── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
    }
    .panel-notebooks {
        display: none;
    }
    .panel-notes {
        border-right: none;
    }
    .panel-editor {
        display: none;
    }
    .panel-editor.mobile-show {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 100;
    }
}

/* ─── Animations ─── */
.note-card {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h3 {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.modal input, .modal select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    margin-bottom: 0.75rem;
    outline: none;
}

.modal input:focus, .modal select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.modal-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    transition: all var(--transition);
}

.modal-btn:hover {
    background: var(--bg-hover);
}

.modal-btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.modal-btn.primary:hover {
    background: var(--accent-hover);
}
