/* ========================================
   Notes & Bookmarks Panel
   ======================================== */

/* FAB Button */
.notes-fab {
    position: fixed;
    bottom: 30px;
    left: 90px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.3);
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #f59e0b;
    font-size: 1.1rem;
    cursor: pointer;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-family: 'Tajawal', sans-serif;
}

.notes-fab:hover {
    transform: scale(1.1);
    border-color: #f59e0b;
}

.notes-fab.active {
    background: #6366f1;
    border-color: #6366f1;
    color: white;
}

/* Panel */
.notes-panel {
    position: fixed;
    bottom: 90px;
    left: 30px;
    width: 380px;
    max-height: 70vh;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    z-index: 998;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Tajawal', sans-serif;
}

.notes-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Header */
.notes-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.12);
}

.notes-tabs {
    display: flex;
    gap: 4px;
}

.notes-tab {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notes-tab:hover {
    color: #e2e8f0;
    background: rgba(99, 102, 241, 0.08);
}

.notes-tab.active {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.12);
    font-weight: 700;
}

.notes-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.notes-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Body */
.notes-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.notes-panel-body::-webkit-scrollbar {
    width: 4px;
}

.notes-panel-body::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 4px;
}

/* Empty State */
.notes-empty {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.notes-empty i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.notes-empty h4 {
    color: #94a3b8;
    font-size: 1rem;
    margin-bottom: 6px;
}

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

/* Note Card */
.note-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.note-card:hover {
    border-color: rgba(99, 102, 241, 0.25);
}

.note-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 1px solid rgba(99, 102, 241, 0.08);
}

.note-unit-link {
    color: #6366f1;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.note-unit-link:hover {
    color: #818cf8;
}

.note-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.note-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.note-card-body {
    padding: 10px 12px;
    cursor: pointer;
    min-height: 36px;
}

.note-card-body p {
    color: #cbd5e1;
    font-size: 0.85rem;
    line-height: 1.6;
    margin: 0;
}

.note-card-meta {
    padding: 4px 12px 8px;
}

.note-card-meta small {
    color: #475569;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Note Editor */
.note-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.note-editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.note-back {
    padding: 6px 10px;
    border: none;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.note-back:hover {
    background: rgba(99, 102, 241, 0.2);
}

.note-editor-title {
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 500;
}

.note-editor textarea {
    width: 100%;
    height: 200px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.4);
    color: #e2e8f0;
    padding: 12px;
    font-size: 0.9rem;
    font-family: 'Tajawal', sans-serif;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.note-editor textarea:focus {
    border-color: #6366f1;
}

.note-editor textarea::placeholder {
    color: #475569;
}

/* Editor Footer */
.note-editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.note-save-btn {
    padding: 8px 20px;
    border: none;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.note-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.note-save-status {
    color: #10b981;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Bookmark Card */
.bookmark-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    margin-bottom: 8px;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.bookmark-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(30, 41, 59, 0.7);
}

.bookmark-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.15));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f59e0b;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.bookmark-info {
    flex: 1;
    min-width: 0;
}

.bookmark-info strong {
    display: block;
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 700;
}

.bookmark-info span {
    display: block;
    color: #64748b;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bookmark-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #475569;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.bookmark-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Footer — Add bar */
.notes-panel-footer {
    padding: 10px 12px;
    border-top: 1px solid rgba(99, 102, 241, 0.12);
}

.notes-add-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.notes-add-bar select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.6);
    color: #e2e8f0;
    font-size: 0.8rem;
    font-family: 'Tajawal', sans-serif;
    outline: none;
    cursor: pointer;
}

.notes-add-bar select:focus {
    border-color: #6366f1;
}

.notes-add-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    color: white;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.notes-add-btn:hover {
    transform: scale(1.08);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .notes-panel {
        left: 10px;
        right: 10px;
        width: auto;
        bottom: 80px;
        max-height: 65vh;
    }

    .notes-fab {
        left: 80px;
        bottom: 24px;
    }
}

/* ===== Light Theme ===== */
body.light-theme .notes-fab {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(99, 102, 241, 0.2);
    color: #f59e0b;
}

body.light-theme .notes-panel {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(99, 102, 241, 0.15);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

body.light-theme .notes-panel-header {
    border-bottom-color: rgba(99, 102, 241, 0.1);
}

body.light-theme .notes-tab {
    color: #64748b;
}

body.light-theme .notes-tab.active {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
}

body.light-theme .note-card {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(99, 102, 241, 0.08);
}

body.light-theme .note-card-header {
    background: rgba(99, 102, 241, 0.03);
}

body.light-theme .note-card-body p {
    color: #334155;
}

body.light-theme .note-editor textarea {
    background: rgba(241, 245, 249, 0.8);
    color: #1e293b;
    border-color: rgba(99, 102, 241, 0.12);
}

body.light-theme .bookmark-card {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(99, 102, 241, 0.08);
}

body.light-theme .bookmark-info strong {
    color: #1e293b;
}

body.light-theme .notes-add-bar select {
    background: rgba(241, 245, 249, 0.8);
    color: #1e293b;
    border-color: rgba(99, 102, 241, 0.12);
}

body.light-theme .notes-panel-footer {
    border-top-color: rgba(99, 102, 241, 0.1);
}

body.light-theme .notes-empty {
    color: #94a3b8;
}

body.light-theme .notes-empty h4 {
    color: #64748b;
}

/* Print: hide panel */
@media print {
    .notes-fab,
    .notes-panel {
        display: none !important;
    }
}
