/* css/notebook.css */

.notebook-overlay {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9000;
    background: var(--bg-container);
    display: none;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    /* ← "all" → "transform" */
    border-top: 1px solid var(--border);
    overflow: hidden;
}

.notebook-overlay.active {
    display: flex;
    overflow: hidden;
    /* ← El overlay NO hace scroll, solo el área de texto */
    overscroll-behavior: contain;
    touch-action: pan-y;
}

/* Estado Minimizado: Pestaña lateral derecha */
.notebook-overlay.minimized {
    top: 50%;
    right: 0;
    left: auto;
    bottom: auto;
    width: 60px;
    height: 180px;
    transform: translateY(-50%);
    border-radius: 20px 0 0 20px;
    padding: 10px;
    cursor: pointer;
    background: var(--accent);
    color: white;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    z-index: 9001;
}

.notebook-overlay.minimized:hover {
    width: 70px;
}

.notebook-overlay.minimized .note-editor-container {
    display: none;
}

.notebook-minimized-trigger {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 10px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.notebook-overlay.minimized .notebook-minimized-trigger {
    display: flex;
}

/* Contenedor del Editor en Overlay */
.note-editor-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.note-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.note-title-input {
    flex: 1;
    font-size: 1.5rem;
    font-weight: 600;
    font-family: 'Playfair Display', serif;
    color: var(--text-main);
    background: transparent;
    border: none;
    outline: none;
    padding: 5px 0;
}

.note-title-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

.editor-controls {
    display: flex;
    gap: 8px;
}

.btn-editor-control {
    background: transparent;
    border: 1px solid transparent;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
}

.btn-editor-control:hover {
    background: var(--bg-filters);
    border-color: var(--border);
    color: var(--text-main);
}

/* Ajustes al toolbar */
.note-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-container);
    border-radius: 10px;
    border: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

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

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

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

.toolbar-select {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    appearance: none;
}

.toolbar-select:hover {
    background: var(--bg-filters);
    border-color: var(--border);
}

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

.note-content-editable {
    flex: 1;
    min-height: 300px;
    background: transparent;
    border: none;
    padding: 10px 5px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-main);
    outline: none;
    overflow-y: auto;
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-break: break-word;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.note-content-editable ul,
.note-content-editable ol {
    padding-left: 20px;
    margin-bottom: 10px;
}

.note-content-editable ul {
    list-style-type: disc;
}

.note-content-editable ol {
    list-style-type: decimal;
}

.note-content-editable li {
    margin-bottom: 5px;
}

.note-content-editable[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-muted);
    pointer-events: none;
    display: block;
    /* For Firefox */
    font-style: italic;
}

.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.btn-delete-note {
    background: transparent;
    color: #e74c3c;
    border: 1px solid transparent;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-note:hover {
    background: rgba(231, 76, 60, 0.1);
    border-color: rgba(231, 76, 60, 0.3);
}

/* Notebook Container (Lista en el panel de usuario) */
.notebook-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.notebook-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-new-note {
    background: var(--accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

/* Listado de notas */
.note-item {
    background: var(--bg-filters);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.note-item:hover {
    border-color: var(--accent);
    background: var(--bg-container);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Desktop Mode Refinement */
#notebookDesktopContent {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#notebookDesktopContent .note-editor-container {
    padding: 15px;
    height: 100%;
    max-width: none;
    margin: 0;
}

.note-title-input.desktop-title {
    font-size: 1.4rem;
    padding: 10px 0;
    margin-bottom: 5px;
    border-bottom: 2px solid var(--accent);
    border-radius: 0;
    background: transparent;
}

#notebookDesktopContent .note-content-editable {
    border: none;
    box-shadow: none;
    padding: 10px 5px;
    /* Pequeño margen lateral para visibilidad del cursor */
    outline: none;
}

#notebookDesktopContent .note-editor-toolbar {
    position: static;
    margin-bottom: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .notebook-overlay {
        top: 50px;
        padding: 0;
        padding-bottom: 0;
    }

    .notebook-overlay .note-editor-container {
        padding: 0;
        gap: 0;
        height: 100%;
        overflow: hidden;
        /* El contenedor NO hace scroll */
    }

    .notebook-overlay .note-editor-header {
        padding: 12px 15px;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        /* No se encoge */
    }

    .notebook-overlay .note-editor-toolbar {
        position: static;
        /* Flujo normal, fuera del scroll */
        flex-shrink: 0;
        /* No se encoge ni desaparece */
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid var(--border);
        justify-content: center;
        flex-wrap: wrap;
        padding: 6px 10px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
        z-index: 10;
        margin: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .notebook-overlay .note-content-editable {
        flex: 1;
        overflow-y: auto;
        /* SOLO el texto hace scroll */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 15px;
        min-height: 0;
        /* Necesario para que flex+overflow funcione */
    }

    .notebook-overlay .editor-footer {
        flex-shrink: 0;
        padding: 10px 15px;
        border-top: 1px solid var(--border);
    }

    /* Fix teclado iOS: JS ajustará height/top dinámicamente */
    .notebook-overlay.keyboard-open {
        transition: none;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
    }
}