/* Custom Fonts - Escolar */
@font-face { font-family: 'Mamae Que Nos Faz'; src: url('../fonts/MamaeQueNosFaz.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Morasoft'; src: url('../fonts/Morasoft.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'KG Primary Dots'; src: url('../fonts/KGPrimaryDots.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'KG Primary Dots Lined'; src: url('../fonts/KGPrimaryDotsLined.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Massallera'; src: url('../fonts/massallera.TTF') format('truetype'); font-display: swap; }
@font-face { font-family: 'Escolar'; src: url('../fonts/Escolar_G.TTF') format('truetype'); font-display: swap; }
@font-face { font-family: 'Escolar Dots'; src: url('../fonts/Escolar_P.TTF') format('truetype'); font-display: swap; }
@font-face { font-family: 'Cole Carreira'; src: url('../fonts/ColeCarreira.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Trace'; src: url('../fonts/TRACE___.TTF') format('truetype'); font-display: swap; }

/* Modern Clean UI - ClassroomScreen Inspired */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif;
    user-select: none;
    /* Prevent selection for better app feel */
}

body {
    overflow: hidden;
    background-color: #f5f5f5;
    height: 100vh;
}

.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Layering */
.main-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Lowest layer: Canvas */
}

#drawing-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.widgets-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas unless on elements */
    z-index: 20;
    /* Above canvas */
}

/* Top Left Info */
.top-left-info {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: auto;
    z-index: 30;
    transition: opacity 0.4s;
}


.date-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-flags {
    display: flex;
    gap: 4px;
}

.flag-btn {
    border: none;
    background: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
    opacity: 0.35;
    transition: opacity 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
}

.flag-btn img { border-radius: 3px; display: block; }
.flag-btn:hover { opacity: 0.7; transform: scale(1.15); }
.flag-btn.active { opacity: 1; }

.date-display {
    font-size: 2.2rem;
    font-weight: 700;
    color: #333;
    cursor: pointer;
    transition: transform 0.2s;
}

/* ── Login SeguimientoOA (banner + badge de usuario) ─────────────────────
   inline-flex a propósito: .top-left-info se estira al ancho de .date-row
   (la fecha larga), así que un display:flex normal (block-level) heredaría
   ese ancho completo. inline-flex se ajusta solo a su propio contenido. */
.soa-login-banner {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 10px;
    padding: 6px 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    opacity: 0.75;
    transition: opacity 0.2s, background 0.2s, box-shadow 0.2s;
}
.soa-login-banner:hover {
    opacity: 1;
    background: rgba(255,255,255,0.85);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.soa-login-banner.hidden { display: none; }
.soa-login-body { display: flex; flex-direction: column; gap: 2px; }
.soa-login-text {
    font-size: 0.68rem;
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
}
.soa-login-btn-container { line-height: 0; transform: scale(0.85); transform-origin: left center; }
.soa-login-error {
    align-self: center;
    font-size: 0.75rem;
    color: #dc2626;
    font-weight: 600;
    max-width: 200px;
}
.soa-login-error.hidden { display: none; }
.soa-login-warn {
    margin-left: 6px;
    font-size: 0.85rem;
    cursor: help;
    opacity: 0.8;
}

.soa-user-badge {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 999px;
    padding: 5px 6px 5px 5px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    transition: padding 0.25s ease;
}
.soa-user-badge.hidden { display: none; }
.soa-user-avatar {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.soa-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: max-width 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
}
.soa-logout-btn {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.05);
    cursor: pointer;
    opacity: 0.6;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.soa-logout-btn:hover { opacity: 1; background: rgba(220,38,38,0.12); color: #dc2626; }

/* Colapsado: solo el ícono. El hover (o foco por teclado) lo vuelve a expandir. */
.soa-user-badge.collapsed {
    padding-right: 5px;
    gap: 0;
}
.soa-user-badge.collapsed .soa-user-name,
.soa-user-badge.collapsed .soa-logout-btn {
    max-width: 0;
    opacity: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
}
.soa-user-badge.collapsed:hover,
.soa-user-badge.collapsed:focus-within {
    gap: 8px;
    padding: 5px 6px 5px 5px;
}
.soa-user-badge.collapsed:hover .soa-user-name,
.soa-user-badge.collapsed:focus-within .soa-user-name {
    max-width: 160px;
    opacity: 1;
    pointer-events: auto;
}
.soa-user-badge.collapsed:hover .soa-logout-btn,
.soa-user-badge.collapsed:focus-within .soa-logout-btn {
    max-width: 20px;
    opacity: 0.6;
    pointer-events: auto;
}

.date-display:hover {
    transform: scale(1.02);
}

.date-display.speaking {
    color: #4285f4;
}

/* Toggle UI Button (always visible) */
.toggle-ui-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.7);
    color: #888;
    font-size: 0.9rem;
    cursor: pointer;
    z-index: 200;
    pointer-events: auto;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-ui-btn:hover {
    background: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toggle-ui-btn.active-toggle {
    background: #e74c3c;
    color: white;
}

/* Floating Actions (Right Top) */
.floating-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
    transition: opacity 0.4s;
}


.float-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: #555;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    color: #2c3e50;
}

/* Bottom Toolbar */
.bottom-toolbar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: auto;
    transition: opacity 0.4s, transform 0.4s;
}

.bottom-toolbar.autohide {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.bottom-toolbar:hover,
.bottom-toolbar.autohide:hover {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.toolbar-content {
    background: white;
    padding: 8px 15px;
    border-radius: 50px;
    /* Pill shape */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #555;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tool-button:hover {
    background: #f0f0f0;
    color: #000;
}

.tool-button.active {
    background: #e6f0ff;
    color: #0066cc;
}

.separator {
    width: 1px;
    height: 24px;
    background: #eee;
    margin: 0 5px;
}

.tool-properties {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Color Picker Styling */
#color-picker {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    background: none;
}

#color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

#color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
    border: 2px solid #ddd;
}

/* Widget Panel */
.widgets-panel {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    z-index: 90;
    pointer-events: auto;
    width: 680px;
    max-width: 90vw;
}

.widget-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px 4px;
    border-radius: 10px;
    transition: background 0.2s;
}

.widget-option:hover {
    background: #f0f4ff;
}

.widget-option i {
    font-size: 1.5rem;
    color: #555;
}

.widget-option span {
    font-size: 0.7rem;
    color: #666;
    text-align: center;
    line-height: 1.2;
}

.hidden {
    display: none !important;
}

/* Existing Widget Styles (Keep functionality) */
.widget {
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    pointer-events: auto;
    position: absolute;
    /* Ensure widgets are absolute */
}

.widget-header {
    background: #f8f9fa;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.widget-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.widget-controls button {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    margin-left: 8px;
    transition: color 0.2s;
}

.widget-controls button:hover {
    color: #333;
}

.widget-content {
    padding: 15px;
}

/* Responsive */
@media (max-width: 768px) {
    .date-display {
        font-size: 1.5rem;
    }

    .toolbar-content {
        padding: 5px 10px;
        gap: 4px;
    }

    .tool-button {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .widgets-panel {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        bottom: 90px;
    }
}

/* Text Editor Widget (ClassroomScreen Premium Style) */
.text-editor-widget {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 5000;
    font-family: 'Quicksand', 'Inter', system-ui, sans-serif;
    gap: 8px;
    min-width: 400px;
    max-width: 700px;
    animation: textEditorIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes textEditorIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.text-editor-toolbar {
    background: white;
    padding: 6px 10px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 520px;
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    color: #666;
    display: flex;
    align-items: center;
    padding-right: 8px;
    border-right: 1px solid #eee;
}

.font-selector {
    font-weight: 600;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    min-width: 120px;
    max-width: 160px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    outline: none;
    background: #fafafa;
    padding: 4px 8px;
    transition: border-color 0.2s;
}

.font-selector:hover,
.font-selector:focus {
    border-color: #4285f4;
    background: #fff;
}

.font-size-input {
    width: 42px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: #333;
    outline: none;
    font-size: 13px;
    padding: 4px 2px;
    background: #fafafa;
    transition: border-color 0.2s;
}

.font-size-input:hover,
.font-size-input:focus {
    border-color: #4285f4;
    background: #fff;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: #e0e0e0;
    flex-shrink: 0;
}

.text-editor-toolbar .toolbar-divider {
    display: none;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px;
    border-radius: 8px;
    background: #f8f8f8;
    flex-shrink: 0;
}

.editor-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.editor-btn:hover {
    background: #f0f0f0;
    color: #111;
    transform: scale(1.08);
}

.editor-btn.active {
    background: #e0e7ff;
    color: #4361ee;
    box-shadow: inset 0 0 0 1.5px #c7d2fe;
}

.editor-spacing-wrapper,
.editor-opacity-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #555;
    flex-shrink: 0;
}

.editor-spacing-wrapper svg,
.editor-opacity-wrapper svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.spacing-input {
    width: 36px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    outline: none;
    padding: 2px;
    background: #fafafa;
}

.spacing-input:focus {
    border-color: #4285f4;
}

.opacity-slider {
    width: 50px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #ddd, #4285f4);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4285f4;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.editor-content {
    background: white;
    padding: 20px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    min-height: 120px;
    max-height: 60vh;
    overflow-y: auto;
    width: 100%;
    outline: none;
    border: 2px solid #f0f0f0;
    font-family: 'Quicksand', sans-serif;
    font-size: 28px;
    color: #333;
    resize: none;
    position: relative;
    caret-color: #4285f4;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.15;
}

.editor-content:focus {
    border-color: #4285f4;
    box-shadow: 0 8px 32px rgba(66, 133, 244, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Icons using simple text for now, but styled better */
.icon-bold::before {
    content: "B";
    font-weight: 800;
}

.icon-italic::before {
    content: "I";
    font-style: italic;
    font-weight: 700;
    font-family: serif;
}

.icon-underline::before {
    content: "U";
    text-decoration: underline;
    font-weight: 700;
}

.icon-trash::before {
    content: "🗑";
    font-size: 16px;
}

.icon-move::before {
    content: "✥";
    font-size: 18px;
}

.editor-color-picker {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    background: none;
}

.editor-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.editor-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
    border: 1px solid #ddd;
}

/* Page Navigation */
.page-nav {
    position: absolute;
    bottom: 30px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 6px 12px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    z-index: 100;
    transition: opacity 0.4s, transform 0.4s;
}


.page-nav #page-indicator {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    min-width: 40px;
    text-align: center;
    user-select: none;
}

.page-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #555;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: #f0f0f0;
    color: #000;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.page-btn.add {
    font-size: 1.3rem;
    color: #0066cc;
}

.page-btn.del {
    font-size: 0.85rem;
    color: #cc3333;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* PDF button loading state */
.float-btn.loading {
    pointer-events: none;
    opacity: 0.6;
    animation: pulse-load 1s ease-in-out infinite;
}

@keyframes pulse-load {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Recent PDFs */
.recent-pdfs {
    position: absolute;
    top: 80px;
    left: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 10px;
    pointer-events: auto;
    z-index: 30;
    max-width: 280px;
}

.recent-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recent-close {
    border: none;
    background: none;
    color: #ccc;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 4px;
}

.recent-close:hover {
    color: #666;
    background: #f0f0f0;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 0.85rem;
    color: #333;
    transition: background 0.15s;
    width: 100%;
}

.recent-item:hover {
    background: #f0f4ff;
}

.recent-item i {
    color: #e74c3c;
    font-size: 1rem;
    flex-shrink: 0;
}

.recent-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-item small {
    color: #aaa;
    font-size: 0.7rem;
    flex-shrink: 0;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 30px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 2px;
    background: white;
    padding: 4px 8px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    z-index: 100;
    transition: opacity 0.4s, transform 0.4s;
}


.zoom-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #555;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: #f0f0f0;
    color: #000;
}

.zoom-label {
    border: none;
    background: transparent;
    color: #555;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 48px;
    text-align: center;
}

.zoom-label:hover {
    color: #0066cc;
}

/* Widgets Panel Grid */
.widgets-panel-header {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.widgets-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

/* Floating Widget (iframe) */
.floating-widget {
    position: absolute;
    width: 420px;
    height: 360px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    pointer-events: auto;
    z-index: 10;
    display: flex;
    flex-direction: column;
    resize: none;
}

.fw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    cursor: grab;
    flex-shrink: 0;
}

.fw-header:active { cursor: grabbing; }

.fw-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}

.fw-controls {
    display: flex;
    gap: 4px;
}

.fw-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: #999;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.fw-btn:hover { background: #eee; color: #333; }
.fw-close:hover { background: #fee; color: #e74c3c; }

.fw-body {
    flex: 1;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

.fw-iframe {
    border: none;
    width: 100%;
    height: 100%;
}

.fw-native {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 0 0 12px 12px;
}

.fw-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, #ccc 50%);
    border-radius: 0 0 12px 0;
}

/* Lesson Goal Display */
.lesson-goal-display {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 24px 10px 12px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 1.3rem;
    color: #333;
    z-index: 500;
    pointer-events: auto;
    min-width: 200px;
    max-width: 70vw;
    outline: none;
    display: none;
    cursor: text;
    transition: box-shadow 0.2s;
}

.lesson-goal-display:focus {
    box-shadow: 0 4px 20px rgba(66, 133, 244, 0.3);
    border: 1px solid #4285f4;
}

.lesson-goal-handle {
    display: inline-block;
    cursor: grab;
    color: #bbb;
    margin-right: 8px;
    vertical-align: middle;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.2s;
}

.lesson-goal-handle:hover {
    color: #666;
    background: #f0f0f0;
}

.lesson-goal-handle:active {
    cursor: grabbing;
}

/* Biblioteca Modal */
.biblio-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.biblio-modal.hidden { display: none; }

.biblio-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
}

.biblio-container {
    position: relative;
    background: #1a1a2e;
    border-radius: 20px;
    width: 90vw;
    max-width: 1100px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    animation: popIn 0.25s ease-out;
}

.biblio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px 12px;
    position: sticky;
    top: 0;
    background: #1a1a2e;
    z-index: 2;
}

.biblio-header h2 {
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
}

.biblio-header h2 i {
    margin-right: 10px;
    color: #f59e0b;
}

.biblio-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.biblio-close:hover { background: rgba(255,255,255,0.2); }

.biblio-filters {
    padding: 8px 30px 16px;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    position: sticky;
    top: 60px;
    background: #1a1a2e;
    z-index: 2;
}

.biblio-filter-group label {
    display: block;
    color: #888;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    font-weight: 600;
}

.biblio-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.biblio-chip {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.15);
    background: transparent;
    color: #ccc;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.biblio-chip:hover { border-color: rgba(255,255,255,0.4); color: white; }

.biblio-chip.active {
    color: white;
    border-color: transparent;
    font-weight: 600;
}

.biblio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 10px 30px 30px;
}

.biblio-card {
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.biblio-card:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

.biblio-card.no-id {
    opacity: 0.3;
    cursor: default;
}

.biblio-card.no-id:hover {
    transform: none;
    box-shadow: none;
}

.biblio-cover {
    width: 100%;
    aspect-ratio: 3/4;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.biblio-cover-icon {
    font-size: 3rem;
    opacity: 0.6;
}

.biblio-thumb {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}

.biblio-info {
    padding: 10px 12px 14px;
}

.biblio-title {
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
}

.biblio-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: #999;
}

.biblio-badge {
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
}

.biblio-scanning {
    text-align: center;
    padding: 60px 30px;
    color: #888;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.biblio-scanning p { font-size: 0.9rem; }

.biblio-header-actions {
    display: flex;
    gap: 8px;
}

.biblio-gen-covers,
.biblio-export-covers,
.biblio-refresh {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #888;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.biblio-gen-covers:hover,
.biblio-export-covers:hover,
.biblio-refresh:hover { background: rgba(255,255,255,0.2); color: white; }

.biblio-status { min-height: 20px; }

/* Ruleta Corner */
.sr-trigger-row{display:flex;align-items:center;gap:.6rem}
.sr-mini-badge{display:flex;align-items:center;gap:.5rem;background:#fff;border:1px solid #e2e8f0;border-radius:999px;padding:.3rem .9rem .3rem .35rem;box-shadow:0 4px 16px rgba(0,0,0,.12);cursor:pointer;transition:box-shadow .15s,transform .15s}
.sr-mini-badge:hover{box-shadow:0 6px 20px rgba(79,70,229,.2);transform:translateY(-1px)}
.sr-mini-badge.hidden{display:none}
.sr-mini-avatar{width:32px;height:32px;border-radius:50%;background:linear-gradient(135deg,#4f46e5,#7c3aed);color:#fff;font-size:.72rem;font-weight:800;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.sr-mini-info{display:flex;flex-direction:column;min-width:0}
.sr-mini-label{font-size:.62rem;font-weight:700;color:#7c3aed;text-transform:uppercase;letter-spacing:.04em;line-height:1}
.sr-mini-name{font-size:.82rem;font-weight:800;color:#1e293b;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:240px}
.sr-mini-close{border:none;background:none;color:#cbd5e1;font-size:.7rem;cursor:pointer;padding:2px 4px;margin-left:4px;border-radius:50%;flex-shrink:0}
.sr-mini-close:hover{color:#64748b;background:#f1f5f9}

.sr-wrapper {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.ruleta-trigger {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.45);
    transition: transform 0.18s, box-shadow 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ruleta-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.55);
}

.ruleta-panel {
    width: 280px;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    border: 1px solid #e2e8f0;
}

.ruleta-panel.hidden {
    display: none;
}

.ruleta-panel pizzarra-ruleta-seguimiento {
    display: block;
    width: 100%;
}

/* Background Panel */
.bg-panel{position:absolute;right:54px;top:0;background:#fff;border-radius:14px;box-shadow:0 8px 30px rgba(0,0,0,.2);padding:12px;width:320px;z-index:200;animation:popIn .2s ease-out;max-height:80vh;overflow-y:auto}
.bg-section-label{font-size:.68rem;font-weight:700;color:#999;text-transform:uppercase;letter-spacing:.06em;padding:4px 4px 6px;margin-top:4px}
.bg-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px;margin-bottom:8px}
.bg-option{border:none;background:none;cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:4px;padding:6px;border-radius:10px;transition:background .15s}
.bg-option:hover{background:#f0f4ff}
.bg-preview{width:100%;aspect-ratio:4/3;border-radius:8px;border:2px solid #e2e8f0;display:flex;align-items:center;justify-content:center;font-size:1.2rem;color:#888}
.bg-preview-dark{border-color:#333;color:#666}
.bg-label{font-size:.68rem;color:#666;font-weight:600;text-align:center;line-height:1.2}

/* Sessions Modal */
.sessions-modal{position:fixed;top:0;left:0;width:100%;height:100%;z-index:10000;display:flex;align-items:center;justify-content:center}
.sessions-modal.hidden{display:none}
.sessions-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.5);backdrop-filter:blur(4px)}
.sessions-container{position:relative;background:#fff;border-radius:16px;width:480px;max-width:90vw;max-height:80vh;overflow:hidden;box-shadow:0 20px 60px rgba(0,0,0,.3);display:flex;flex-direction:column;animation:popIn .25s ease-out}
.sessions-header{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #eee}
.sessions-header h2{font-size:1.1rem;font-weight:700;color:#333;display:flex;align-items:center;gap:8px}
.sessions-header h2 i{color:#7c3aed}
.sessions-close{width:32px;height:32px;border-radius:50%;border:none;background:none;color:#999;font-size:1rem;cursor:pointer}
.sessions-close:hover{background:#f0f0f0;color:#333}
.sessions-save-section{padding:12px 20px 0;display:flex;flex-direction:column;gap:8px;border-bottom:1px solid #f5f5f5;padding-bottom:12px}
.sessions-save-row{display:flex;gap:8px;align-items:center}
.sessions-input{flex:1;padding:10px 14px;border:2px solid #e2e8f0;border-radius:10px;font-size:.85rem;color:#334155;outline:none;transition:border-color .2s}
.sessions-input-sm{flex:.8}
.sessions-input:focus{border-color:#7c3aed}
.sessions-select{padding:10px 12px;border:2px solid #e2e8f0;border-radius:10px;font-size:.82rem;color:#334155;background:#fff;outline:none;flex:1;transition:border-color .2s}
.sessions-select:focus{border-color:#7c3aed}
.sessions-filters{padding:8px 20px;border-bottom:1px solid #f5f5f5}
.sessions-filter-select{width:100%;padding:8px 12px;border:1px solid #e2e8f0;border-radius:8px;font-size:.8rem;color:#64748b;background:#f8fafc}
.sessions-group{margin:4px 0;border:1px solid #f0f0f0;border-radius:10px;overflow:hidden}
.sessions-group-label{padding:10px 12px;font-size:.75rem;font-weight:700;color:#7c3aed;background:#faf8ff;cursor:pointer;display:flex;align-items:center;gap:8px;user-select:none;transition:background .15s}
.sessions-group-label:hover{background:#f3f0ff}
.sessions-group-label i{font-size:.65rem;transition:transform .2s}
.sessions-group-label.collapsed i.fa-chevron-down{transform:rotate(-90deg)}
.sessions-group-label .group-count{font-size:.65rem;color:#a78bfa;font-weight:600;margin-left:auto}
.sessions-subgroup{margin:2px 0 2px 16px;border-left:2px solid #ede9fe}
.sessions-subgroup-label{padding:6px 12px;font-size:.68rem;font-weight:600;color:#64748b;cursor:pointer;display:flex;align-items:center;gap:6px;user-select:none}
.sessions-subgroup-label:hover{color:#7c3aed}
.sessions-subgroup-label i{font-size:.55rem;transition:transform .2s}
.sessions-subgroup-label.collapsed i.fa-chevron-down{transform:rotate(-90deg)}
.sessions-group-items{overflow:hidden;transition:max-height .3s ease}
.session-meta-curso{font-size:.65rem;color:#7c3aed;background:#ede9fe;padding:1px 6px;border-radius:4px;margin-left:4px}
.sessions-btn{border:none;border-radius:10px;padding:10px 16px;font-size:.82rem;font-weight:600;cursor:pointer;display:flex;align-items:center;gap:6px;transition:all .15s}
.sessions-btn-save{background:linear-gradient(135deg,#4f46e5,#7c3aed);color:#fff;flex-shrink:0}
.sessions-btn-save:hover{box-shadow:0 4px 12px rgba(124,58,237,.4);transform:translateY(-1px)}
.sessions-new-row{padding:0 20px 12px;border-bottom:1px solid #f5f5f5}
.sessions-btn-new-full{background:#f8fafc;color:#64748b;border:2px dashed #e2e8f0;width:100%;justify-content:center;padding:10px;border-radius:10px}
.sessions-btn-new-full:hover{background:#f1f5f9;border-color:#7c3aed;color:#7c3aed}
.sessions-list{overflow-y:auto;flex:1;padding:8px 12px}
.sessions-empty{text-align:center;padding:40px 20px;color:#999;font-size:.9rem}
.session-item{display:flex;align-items:center;gap:12px;padding:12px;border-radius:10px;cursor:pointer;transition:background .15s;border:1px solid transparent}
.session-item:hover{background:#f8f9ff;border-color:#e2e8f0}
.session-icon{width:40px;height:40px;border-radius:10px;background:linear-gradient(135deg,#ede9fe,#ddd6fe);color:#7c3aed;display:flex;align-items:center;justify-content:center;font-size:1rem;flex-shrink:0}
.session-info{flex:1;min-width:0}
.session-name{font-size:.88rem;font-weight:700;color:#1e293b;line-height:1.3}
.session-meta{font-size:.72rem;color:#94a3b8;margin-top:2px}
.session-delete{width:32px;height:32px;border:none;background:#f8fafc;color:#cbd5e1;border-radius:8px;cursor:pointer;font-size:.78rem;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:all .2s}
.session-delete:hover{background:#fef2f2;color:#ef4444}
.session-delete[data-confirming]{background:#fef2f2;color:#ef4444;animation:pulse-del .5s ease-in-out infinite alternate}
@keyframes pulse-del{from{transform:scale(1)}to{transform:scale(1.15)}}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    display: none !important;
}

.loading-card {
    background: white;
    border-radius: 20px;
    padding: 40px 50px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    min-width: 320px;
    animation: popIn 0.25s ease-out;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #0066cc;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
}

.loading-progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0066cc, #4285f4);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.loading-detail {
    font-size: 0.85rem;
    color: #888;
}

.text-input-container {
    display: none !important;
}
.floating-widget.fw-maximized { top: 0 !important; left: 0 !important; width: 100% !important; height: calc(100% - 90px) !important; border-radius: 0; z-index: 100 !important; }
.floating-widget.fw-maximized .fw-resize-handle { display: none !important; }

/* ── Puntos Dock ──────────────────────────────────────────────── */
.puntos-dock {
    position: fixed; left: 170px; right: 320px; bottom: 95px; height: 72px; z-index: 50;
    overflow: visible;
    background: #0d0f1a; border: 1px solid rgba(124,58,237,0.2);
    border-radius: 18px;
    display: flex; align-items: center; padding: 0 16px; gap: 8px;
    transition: transform 0.3s cubic-bezier(0.16,1,0.3,1), opacity 0.3s;
}
.puntos-dock.hidden { transform: translateY(100%); opacity: 0; pointer-events: none; }

.pd-left {
    display: flex; align-items: center; gap: 8px; padding-right: 10px;
    border-right: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
.pd-curso-select {
    background: rgba(124,58,237,0.1); border: 1px solid rgba(124,58,237,0.3);
    border-radius: 8px; padding: 4px 8px; color: #fff; font-size: 11px;
    font-family: inherit; cursor: pointer; outline: none; max-width: 100px;
}
.pd-curso-select option { background: #111; color: #fff; }
.pd-mini-btns { display: flex; gap: 4px; }
.pd-mini-btn {
    width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03); cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.pd-mini-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }
.pd-goal { display: flex; flex-direction: column; gap: 2px; width: 80px; }
.pd-goal-bar { height: 8px; background: rgba(255,255,255,0.05); border-radius: 4px; overflow: hidden; border: 1px solid rgba(124,58,237,0.15); }
.pd-goal-fill { height: 100%; width: 0%; background: linear-gradient(90deg,#7c3aed,#06b6d4,#10b981); border-radius: 4px; transition: width 0.5s; }
.pd-goal-text { font-size: 11px; color: #a78bfa; text-align: center; font-weight: 700; }

.pd-students {
    flex: 1; display: flex; gap: 4px; align-items: flex-end;
    overflow-x: auto; overflow-y: visible;
    padding: 4px 0 4px; scroll-behavior: smooth;
    margin-top: -55px; padding-top: 55px;
}
.pd-students::-webkit-scrollbar { height: 3px; }
.pd-students::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.3); border-radius: 2px; }

.pd-student {
    display: flex; flex-direction: column; align-items: center; gap: 0px;
    padding: 0px 6px 2px; border-radius: 10px; cursor: pointer; min-width: 60px;
    transition: all 0.15s; border: 1px solid transparent; flex-shrink: 0;
    transform: translateY(-20px);
}
.pd-student:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.1); transform: translateY(-24px) scale(1.05); }
.pd-student .pd-tooltip { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%) scale(0.8); opacity: 0; pointer-events: none; background: linear-gradient(135deg, #1a1a2e, #16213e); border: 1px solid rgba(124,58,237,0.3); border-radius: 10px; padding: 5px 12px; white-space: nowrap; font-size: 11px; font-weight: 600; color: #fff; box-shadow: 0 8px 20px rgba(0,0,0,0.4); transition: all 0.2s cubic-bezier(0.16,1,0.3,1); z-index: 60; }
.pd-student .pd-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #16213e; }
.pd-student:hover .pd-tooltip { opacity: 1; transform: translateX(-50%) scale(1); }
.pd-student.has-pts { background: rgba(16,185,129,0.06); border-color: rgba(16,185,129,0.12); }
.pd-student-avatar { font-size: 36px; }
.pd-student-avatar img { width: 54px; height: 54px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
.pd-student-name { font-size: 9px; color: rgba(255,255,255,0.5); white-space: nowrap; max-width: 58px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.pd-student-pts { font-size: 12px; font-weight: 800; color: rgba(255,255,255,0.25); }
.pd-student-pts.pos { color: #10b981; }

.pd-right {
    display: flex; align-items: center; padding-left: 10px; gap: 6px;
    border-left: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
.pd-all-btn {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 6px 10px; border-radius: 10px; cursor: pointer; border: 1px solid rgba(124,58,237,0.2);
    background: rgba(124,58,237,0.06); font-size: 22px; transition: all 0.15s;
}
.pd-all-btn:hover { background: rgba(124,58,237,0.12); border-color: rgba(124,58,237,0.4); }
.pd-all-btn span { font-size: 7px; color: rgba(124,58,237,0.7); font-weight: 700; }

/* Projector mode — hides all controls */
body.projector-mode .floating-actions,
body.projector-mode .bottom-toolbar,
body.projector-mode .page-nav,
body.projector-mode .zoom-controls,
body.projector-mode .widgets-panel,
body.projector-mode .sr-wrapper,
body.projector-mode .puntos-dock,
body.projector-mode .date-flags { display:none !important; }
body.projector-mode .canvas-wrapper { inset:0 !important; }
body.projector-mode .board-container { padding:0 !important; }
.proj-widget-mirror { border:none !important; box-shadow:0 4px 20px rgba(0,0,0,0.2) !important; border-radius:12px !important; overflow:hidden !important; }
.proj-widget-mirror .fw-header { display:none !important; }
.proj-widget-mirror .fw-resize-handle { display:none !important; }
.proj-widget-mirror .fw-body { position:absolute !important; inset:0 !important; }
body.projector-mode .floating-widget:not(.proj-widget-mirror) { display:none !important; }

.fw-eye { color: #10b981 !important; }
.fw-eye:hover { color: #fff !important; }

@keyframes confettiFall { 0% { opacity:1; transform:translateY(0) rotate(0deg); } 100% { opacity:0; transform:translateY(100vh) rotate(720deg); } }
