/* =========================================================
   MY NOTES WIDGET
   Floating notes panel available on lesson pages.
   Auto-saves per-lesson notes to the browser (localStorage)
   and lets the user download them as a PDF named after the
   lesson/tutorial title.
========================================================= */

#notesToggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 10050;

    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;

    background: #2f6fed;
    color: #fff;

    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow: 0 6px 18px rgba(47, 111, 237, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#notesToggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(47, 111, 237, 0.45);
}

#notesBackdrop {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    z-index: 10040;

    background: rgba(15, 23, 42, 0.35);

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#notesBackdrop.show {
    opacity: 1;
    pointer-events: auto;
}

#notesPanel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10050;

    width: 300px;
    max-width: 85vw;

    background: #fff;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
    border-right: 1px solid #e7ebf3;

    display: flex;
    flex-direction: column;
    overflow-y: auto;

    transform: translateX(-100%);
    pointer-events: none;
    transition: transform 0.22s ease;
}

#notesPanel.open {
    transform: translateX(0);
    pointer-events: auto;
}

.notes-header {
    background: #2f6fed;
    color: #fff;

    padding: 14px 16px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notes-header-title {
    font-weight: 600;
    font-size: 0.98rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    opacity: 0.85;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
}

.notes-close-btn:hover {
    opacity: 1;
}

.notes-subtitle {
    padding: 10px 16px 0 16px;
    font-size: 0.78rem;
    color: #6b7280;
}

.notes-body {
    padding: 10px 16px 16px 16px;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#notesTextarea {
    width: 100%;
    flex: 1;
    min-height: 220px;
    resize: none;

    border: 1px solid #dde3ee;
    border-radius: 10px;
    padding: 12px 14px;

    font-size: 0.9rem;
    line-height: 1.5;
    color: #1f2937;

    outline: none;
}

#notesTextarea:focus {
    border-color: #2f6fed;
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

.notes-save-indicator {
    position: absolute;
    right: 26px;
    bottom: 32px;

    width: 20px;
    height: 20px;
    border-radius: 50%;

    background: #16a34a;
    color: #fff;

    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;

    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.notes-save-indicator.show {
    opacity: 1;
    transform: scale(1);
}

.notes-footer {
    display: flex;
    gap: 10px;
    padding: 0 16px 16px 16px;
}

.notes-btn {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.notes-btn-primary {
    background: #1f2937;
    color: #fff;
}

.notes-btn-primary:hover {
    background: #111827;
}

.notes-btn-secondary {
    background: #f1f4f9;
    color: #1f2937;
}

.notes-btn-secondary:hover {
    background: #e5e9f2;
}

@media (max-width: 992px) {

    /* Below 992px, the mobile bottom nav's "Notes" icon opens this
       same panel (see navbar.js), so the floating round button is
       hidden to avoid duplicating it and overlapping the bottom nav. */

    #notesToggle {
        display: none;
    }
}

@media (max-width: 576px) {

    #notesPanel {
        width: 100vw;
    }

    .notes-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}