/* Fuentes */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Patrick+Hand&display=swap');
@import url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic.css');

body {
    font-family: 'Outfit', sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
}

.font-hand,
.font-hand * {
    font-family: 'Patrick Hand', cursive !important;
}

.font-hand {
    font-size: 1.15em;
}

.font-verdana,
.font-verdana * {
    font-family: Verdana, Geneva, sans-serif !important;
}

.font-calibri,
.font-calibri * {
    font-family: Calibri, 'Candara', 'Segoe', 'Segoe UI', optmizedLegibility, sans-serif !important;
}

.font-opendyslexic,
.font-opendyslexic * {
    font-family: 'OpenDyslexic', sans-serif !important;
}

.font-inter,
.font-inter * {
    font-family: 'Outfit', sans-serif !important;
}

.font-comicsans,
.font-comicsans * {
    font-family: 'Comic Sans MS', 'Comic Sans', cursive !important;
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.glass-panel {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.05);
}

/* Animated Background Blobs */
.blob {
    position: absolute;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float-blob 10s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: #818cf8;
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: #c084fc;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: #f472b6;
    animation-delay: -2s;
}

@keyframes float-blob {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 50px) scale(1.1);
    }
}

/* Custom Scrollbar */
.custom-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Tabs Styling */
.tab-btn {
    position: relative;
    color: #64748b;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: #4f46e5;
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #4f46e5;
    border-radius: 2px;
}

/* Toggle Switch Profesional */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background-color: #4f46e5;
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(18px);
}

.toggle-force input:checked+.toggle-slider {
    background-color: #f59e0b;
    /* Amber 500 for forced state */
}

/* Estilos matemáticos para Fracciones */
.fraction {
    display: inline-block;
    vertical-align: middle;
    margin: 0 0.2rem;
    text-align: center;
    font-size: 0.9em;
    font-family: inherit !important;
}

.fraction>span {
    display: block;
    padding-top: 0.15em;
}

.fraction span.numerator {
    border-bottom: 2px solid currentColor;
}

.fraction span.denominator {
    border-top: 0px;
}

/* Division Rep (Galera) */
.division-galera {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-family: inherit !important;
}

.galera-divisor {
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    padding: 0 0.5rem 0.1rem 0.4rem;
    min-width: 1.5rem;
    line-height: 1.1;
}

/* Powers and Roots Styling */
.power-term {
    display: inline-block;
    font-family: inherit !important;
}

.root-term {
    display: inline-block;
    white-space: nowrap;
    font-family: inherit !important;
}

.radicand {
    border-top: 1px solid currentColor;
    padding-top: 1px;
    padding-left: 1px;
}

/* Cuadrícula de papel */
.grid-paper {
    background-color: #fff;
    background-image:
        linear-gradient(#e5e7eb 1px, transparent 1px),
        linear-gradient(90deg, #e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
    width: 100%;
    border: 1px solid #e5e7eb;
}

/* Estilos Verticales */
.vertical-op {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: inherit !important;
    font-weight: bold;
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 0.5rem 1rem;
    padding-left: 1rem;
}

.vertical-row,
.vertical-last {
    width: 100%;
    text-align: right;
    position: relative;
}

.vertical-last {
    border-bottom: 2px solid #1f2937;
    padding-bottom: 0.1rem;
    margin-bottom: 0.1rem;
}

.op-symbol {
    position: absolute;
    right: 100%;
    top: 0;
    margin-right: 0.4rem;
    font-weight: normal;
    font-size: 1.2rem;
    line-height: 1.3;
    white-space: nowrap;
}

/* Input Box para Término Perdido */
.missing-box {
    display: inline-block;
    width: 3rem;
    height: 2rem;
    border: 2px dashed #a5b4fc;
    border-radius: 4px;
    vertical-align: middle;
    margin: 0 4px;
    background-color: #fdfbff;
}

/* Filter selection highlight */
.num-btn input:checked+span {
    background-color: #ffedd5;
    /* orange-100 */
    border-color: #fdba74;
    /* orange-300 */
    color: #ea580c;
    /* orange-600 */
}

/* Stepper buttons hover effect */
.stepper-btn:active {
    transform: scale(0.95);
}

/* Toast Notifications */
.toast {
    animation: toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1), toast-out 0.4s 3s forwards;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    pointer-events: auto;
    max-width: 320px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.toast-warning {
    background: rgba(255, 251, 235, 0.85);
    /* Amber 50 */
    border-left: 4px solid #f59e0b;
    /* Amber 500 */
}

.toast-info {
    background: rgba(239, 246, 255, 0.85);
    /* Blue 50 */
    border-left: 4px solid #3b82f6;
    /* Blue 500 */
}

@keyframes toast-in {
    from {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0) scale(1);
        opacity: 1;
    }

    to {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }
}


/* WOW Buttons */
.btn-wow-primary {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    border: none;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.btn-wow-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.btn-wow-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(15, 23, 42, 0.4);
}

.btn-wow-primary:hover::before {
    opacity: 1;
}

.btn-wow-primary:active {
    transform: translateY(0);
}

.btn-wow-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #334155;
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(4px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-wow-secondary:hover {
    background: #fff;
    color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.15);
    border-color: #e0e7ff;
}

.btn-wow-secondary:active {
    transform: translateY(0);
}

.scale-wrapper {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top center;
}

/* SKELETON SCREEN */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #f8f8f8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-box {
    height: 100px;
    width: 100%;
}

/* IMPRESIÓN */
@media print {
    @page {
        margin: 1cm;
        size: A4;
    }

    .scale-wrapper,
    #exam-container,
    #answer-sheet-container {
        transform: none !important;
        transform-origin: top center !important;
    }

    body,
    #main-content,
    .overflow-x-auto {
        display: block !important;
        overflow: visible !important;
        height: auto !important;
        background: white !important;
    }

    #sidebar,
    #floating-actions,
    .mobile-header,
    .no-print,
    .blob,
    .glass-panel {
        display: none !important;
    }

    #main-content {
        margin: 0;
        padding: 0;
        width: 100%;
        background: white;
    }

    #exam-container,
    #answer-sheet-container {
        box-shadow: none;
        border: none;
        padding: 0;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0;
        transform: none !important;
    }

    #answer-sheet-container {
        break-before: page !important;
        page-break-before: always !important;
        margin-top: 0;
        display: block !important;
    }

    .operation-wrapper {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .grid-paper {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        border: 1px solid #ccc;
    }

    .page-break-before {
        break-before: page;
        page-break-before: always;
    }
}

/* TEMPLATE CAROUSEL */
.template-card {
    min-width: 130px;
    width: 130px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.2);
    border-color: #818cf8;
}

.template-card:active {
    transform: scale(0.98);
}
