/* TextFlow - Estilos principales */

/* ── Tipografía y fondo base ──────────────────────────────────────── */
html {
    height: 100%;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #ffffff;
    background-image: linear-gradient(180deg, rgba(196, 224, 255, 0.5), #ffffff 364px);
    background-repeat: no-repeat;
    min-height: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    overflow-x: hidden;
}

main {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    overflow-x: hidden;
}

/* ── Navbar blanca ────────────────────────────────────────────────── */
.navbar {
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.navbar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1e40af !important;
}

.navbar-light .navbar-nav .nav-link {
    font-size: 0.88rem;
    font-weight: 500;
    color: #374151;
    padding-left: 0.7rem;
    padding-right: 0.7rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.navbar-light .navbar-nav .nav-link:hover,
.navbar-light .navbar-nav .nav-link:focus {
    color: #1d4ed8;
    background: #eff6ff;
}

.dropdown-menu {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    padding: 0.4rem;
}

.dropdown-item {
    border-radius: 6px;
    font-size: 0.875rem;
    padding: 0.45rem 0.85rem;
    font-weight: 500;
}

/* ── Tarjetas generales ───────────────────────────────────────────── */
.card {
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

.card.border {
    border-color: #b2b5b8 !important;
}

.card.shadow-sm {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06) !important;
}

/* ── Tarjeta libro 3D ─────────────────────────────────────────────── */
.book-card-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.book-card-wrap:hover {
    color: inherit;
    text-decoration: none;
}

.book-cover-box {
    width: 100%;
    margin-bottom: 0.6rem;
}

.book-cover-inner {
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(to bottom, #60a5fa, #1d4ed8);
    position: relative;
}

.book-cover-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-no-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.65);
    font-size: 2.2rem;
}

.book-title {
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: #1f2937;
}

/* ── Badges de dificultad ─────────────────────────────────────────── */
.diff-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-block;
}

/* Numérico (1/2/3/4) */
.diff-1 { background: #d1fae5; color: #065f46; }
.diff-2 { background: #dbeafe; color: #1e40af; }
.diff-3 { background: #ffedd5; color: #9a3412; }
.diff-4 { background: #fee2e2; color: #991b1b; }

/* Strings (compat textflow-node) */
.diff-easy         { background: #d1fae5; color: #065f46; }
.diff-standard     { background: #dbeafe; color: #1e40af; }
.diff-intermediate { background: #ffedd5; color: #9a3412; }
.diff-advanced     { background: #fee2e2; color: #991b1b; }

/* ── Avatar de iniciales ──────────────────────────────────────────── */
.initials-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #60a5fa, #1d4ed8);
    flex-shrink: 0;
}

.initials-avatar.lg {
    width: 80px;
    height: 80px;
    font-size: 1.8rem;
}

/* ── Hero de página ───────────────────────────────────────────────── */
.page-hero {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 50%, #60a5fa 100%);
    border-radius: 16px;
    color: #fff;
    padding: 2rem 2rem;
    margin-bottom: 2rem;
}

.page-hero h2, .page-hero h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ── Contenido de lección ─────────────────────────────────────────── */
.lesson-content {
    line-height: 1.85;
    font-size: 1.05rem;
    color: #1e293b;
}

.lesson-content h1,
.lesson-content h2,
.lesson-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.lesson-content img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

.lesson-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.lesson-content table th,
.lesson-content table td {
    border: 1px solid #dee2e6;
    padding: 0.5rem 0.75rem;
}

.lesson-content table th {
    background-color: #f8f9fa;
}

.lesson-content blockquote {
    border-left: 4px solid #2563eb;
    padding: 0.75rem 1rem;
    color: #6c757d;
    font-style: italic;
    margin: 1rem 0;
    background: #f8faff;
    border-radius: 0 8px 8px 0;
}

/* ── Tablas ───────────────────────────────────────────────────────── */
.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
}

.table-hover tbody tr:hover {
    background: #f0f7ff;
}

/* ── Formularios ──────────────────────────────────────────────────── */
.form-control,
.form-select {
    border-radius: 8px;
    font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #2563eb;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.form-control:focus-visible,
.form-select:focus-visible,
.form-control.is-valid:focus,
.form-control.is-invalid:focus,
.form-select.is-valid:focus,
.form-select.is-invalid:focus,
.was-validated .form-control:valid:focus,
.was-validated .form-control:invalid:focus,
.was-validated .form-select:valid:focus,
.was-validated .form-select:invalid:focus {
    box-shadow: none !important;
    outline: none;
}

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ── Botones ──────────────────────────────────────────────────────── */
.btn {
    border-radius: 8px;
    font-weight: 500;
}

.btn-primary {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

/* ── Barras de progreso ───────────────────────────────────────────── */
.progress {
    border-radius: 20px;
}

.progress-bar {
    border-radius: 20px;
}

/* ── Editor Quill ─────────────────────────────────────────────────── */
#quill-editor {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.75;
}

.ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #f8faff;
    padding: 8px 12px;
    border-radius: 12px 12px 0 0;
}

.ql-container.ql-snow {
    border: none;
    font-size: inherit;
}

.ql-editor {
    min-height: 420px;
    padding: 1.25rem 1.5rem;
    color: #1e293b;
}

.ql-editor.ql-blank::before {
    color: #9ca3af;
    font-style: normal;
}

.ql-editor h1, .ql-editor h2, .ql-editor h3 {
    font-weight: 700;
}

.ql-editor blockquote {
    border-left: 4px solid #2563eb;
    background: #f8faff;
    padding: 0.75rem 1rem;
    border-radius: 0 8px 8px 0;
    color: #6c757d;
}

/* ── Footer ───────────────────────────────────────────────────────── */
footer {
    margin-top: auto;
}

.footer-link:hover {
    color: #2563eb !important;
}

/* ── Drag & Drop ─────────────────────────────────────────────────── */
.drag-handle:hover {
    color: #2563eb !important;
}

.drag-handle:active {
    cursor: grabbing !important;
}

/* ── Utility ──────────────────────────────────────────────────────── */
.py-25 { padding-top: 0.625rem !important; padding-bottom: 0.625rem !important; }

/* ── School action links ──────────────────────────────────────────── */
.school-action-link {
    -webkit-transition: background 0.12s;
    transition: background 0.12s;
    color: #1e293b;
}

.school-action-link:hover {
    background: #eff6ff;
}

/* ── Admin layout (sidebar) ───────────────────────────────────────── */
body.admin-body {
    background: #f0f4fb;
    background-image: none;
    display: block;
    overflow-x: hidden;
}

.admin-wrapper {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 240px;
    -ms-flex-negative: 0;
        flex-shrink: 0;
    background: #fff;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.admin-sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e40af;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.admin-sidebar-brand:hover {
    color: #1e40af;
    text-decoration: none;
}

.admin-sidebar-section {
    padding: 1rem 1.25rem 0.3rem;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
}

.admin-sidebar .admin-nav-link {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 0.65rem;
    padding: 0.48rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    margin: 1px 0.5rem;
    -webkit-transition: background 0.15s, color 0.15s;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.admin-sidebar .admin-nav-link i {
    width: 18px;
    text-align: center;
    -ms-flex-negative: 0;
        flex-shrink: 0;
    font-size: 0.95rem;
    opacity: 0.75;
}

.admin-sidebar .admin-nav-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
    text-decoration: none;
}

.admin-sidebar .admin-nav-link:hover i {
    opacity: 1;
}

.admin-sidebar .admin-nav-link.active {
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
    border-left: 3px solid #2563eb;
    padding-left: calc(1rem - 3px);
}

.admin-sidebar .admin-nav-link.active i {
    opacity: 1;
}

.admin-sidebar-footer {
    margin-top: auto;
    padding: 0.875rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.admin-sidebar-user {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 0.65rem;
}

.admin-sidebar-user .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #1d4ed8);
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    -ms-flex-negative: 0;
        flex-shrink: 0;
}

.admin-sidebar-user .user-info {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    min-width: 0;
}

.admin-sidebar-user .user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-sidebar-user .user-role {
    font-size: 0.72rem;
    color: #9ca3af;
}

/* Main area */
.admin-main {
    margin-left: 240px;
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    padding: 0.7rem 1.5rem;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: justify;
        -ms-flex-pack: justify;
            justify-content: space-between;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 1rem;
}

.admin-topbar-left {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.admin-topbar-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    color: #374151;
    cursor: pointer;
    font-size: 1.2rem;
}

.admin-topbar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-topbar-right {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    gap: 0.5rem;
    -ms-flex-negative: 0;
        flex-shrink: 0;
}

/* Content */
.admin-content {
    padding: 1.5rem;
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
}

/* Overlay for mobile */
.admin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99;
}

/* Responsive */
@media (max-width: 991.98px) {
    .admin-sidebar {
        -webkit-transform: translateX(-100%);
                transform: translateX(-100%);
        -webkit-transition: -webkit-transform 0.25s ease;
        transition: -webkit-transform 0.25s ease;
        transition: transform 0.25s ease;
        transition: transform 0.25s ease, -webkit-transform 0.25s ease;
    }

    .admin-sidebar.show {
        -webkit-transform: translateX(0);
                transform: translateX(0);
    }

    .admin-overlay.show {
        display: block;
    }

    .admin-main {
        margin-left: 0;
    }

    .admin-topbar-toggle {
        display: block;
    }

    .admin-content {
        padding: 1rem;
    }
}

/* ── Letter-fill question inputs ──────────────────────────────────── */
.letter-fill-wrap {
    display: -webkit-inline-box;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: end;
    -ms-flex-align: end;
    align-items: flex-end;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    line-height: 2.2rem;
}

.letter-fill-wrap .lf-text {
    font-size: 1rem;
    line-height: 2.2rem;
}

.letter-fill-input {
    width: 1.7rem;
    max-width: 1.7rem;
    height: 2rem;
    text-align: center;
    border: none;
    border-bottom: 2px solid #6366f1;
    background: transparent;
    font-size: 1rem;
    font-weight: 600;
    color: #1e1b4b;
    padding: 0;
    outline: none;
    border-radius: 0;
    margin-right: 4px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.letter-fill-input:focus {
    border-bottom-color: #4f46e5;
    background: #f5f3ff;
}

