/* Estilos para la vista de resolución de ejercicios */

#resolver-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #2c3e50;
    position: relative;
}

/* Barra superior */
.resolver-header {
    background: #1e3a8a;
    color: white;
    padding: 0.22rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 1001;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    min-height: 40px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    flex: 1 1 auto;
}

.btn-volver {
    background: rgba(255,255,255,0.15);
    color: white;
    padding: 0.24rem 0.58rem;
    border-radius: 0.375rem;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.77rem;
    line-height: 1;
    flex-shrink: 0;
}

.btn-volver:hover {
    background: rgba(255,255,255,0.25);
    text-decoration: none;
}

.ejercicio-titulo {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    line-height: 1;
}

.resolver-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.08rem;
}

.resolver-meta-item {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    color: #e2e8f0;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
    justify-content: flex-end;
    min-width: 0;
    flex-shrink: 0;
}

.header-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.header-title-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.resolver-meta-right {
    justify-content: flex-start;
}

.resolver-mode-badge {
    border-radius: 999px;
    padding: 0.16rem 0.4rem;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.ejercicio-tiempo {
    background: rgba(255,255,255,0.15);
    padding: 0.22rem 0.58rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-family: monospace;
    font-size: 0.82rem;
    line-height: 1;
}

.btn {
    padding: 0.28rem 0.62rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    line-height: 1;
}

.btn-primary {
    background: white;
    color: #1e3a8a;
}

.btn-primary:hover {
    background: #f0f0f0;
}

.resolver-save-state {
    min-width: 4.5rem;
    color: #dcfce7;
    font-size: 0.72rem;
    text-align: right;
}

.resolver-save-state.error { color: #fecaca; }

.resolver-course-arrow-icon { background: transparent; border: 0; }
.resolver-course-arrow {
    display: block;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 16px solid var(--course-color, #ea580c);
    transform-origin: 50% 50%;
    filter: drop-shadow(0 1px 1px rgba(255,255,255,.9));
}

.resultado-intento {
    display: none;
    margin-top: 0.8rem;
    padding: 0.75rem;
    border-radius: 0.45rem;
    line-height: 1.45;
}

.resultado-intento.visible { display: block; }
.resultado-intento.correcto { color: #166534; background: #f0fdf4; border: 1px solid #86efac; }
.resultado-intento.error { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }
.resultado-intento .btn { display: inline-block; margin-top: 0.65rem; }
.opcion-item.bloqueada { cursor: default; pointer-events: none; }
.notas-calculo-label { display:block; margin-top:0.85rem; color:#1e3a8a; font-size:0.82rem; font-weight:700; }
.notas-calculo { width:100%; margin-top:0.35rem; padding:0.55rem; resize:vertical; border:1px solid #cbd5e1; border-radius:0.4rem; font:0.8rem/1.4 monospace; }
.practice-guide {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 2200;
    width: min(620px, calc(100vw - 32px));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid #1d4ed8;
    border-radius: 8px;
    background: #fff;
    color: #172554;
    box-shadow: 0 8px 28px rgba(15, 23, 42, .28);
}
.practice-guide-copy { display: grid; gap: 3px; min-width: 0; }
.practice-guide-copy strong { font-size: .88rem; }
.practice-guide-copy span { font-size: .78rem; line-height: 1.35; }
.practice-guide-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.practice-guide button { border: 0; border-radius: 6px; padding: .45rem .7rem; cursor: pointer; font-weight: 700; }
.practice-guide-skip { color: #334155; background: #e2e8f0; }
.practice-guide-next { color: #fff; background: #1d4ed8; }
.practice-guide-target { outline: 4px solid #f59e0b !important; outline-offset: 3px; }

@media (max-width: 640px) {
    .practice-guide { bottom: 10px; align-items: stretch; flex-direction: column; gap: 9px; }
    .practice-guide-actions { justify-content: flex-end; }
}

/* Paneles flotantes */
.panel-flotante {
    position: absolute;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 999;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    max-width: 90vw;
    transition: none;
    resize: both;
    overflow: hidden;
}

.panel-enunciado {
    top: 62px;
    right: 26px;
    width: 400px;
    height: auto;
    max-height: calc(100vh - 74px);
}

.panel-pasos {
    top: 62px;
    left: 26px;
    width: 500px;
    height: 400px;
    max-height: calc(100vh - 74px);
    resize: both;
}

/* Indicador de redimensión */
.panel-pasos::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, transparent 50%, #1e3a8a 50%);
    pointer-events: none;
    opacity: 0.5;
}

.panel-flotante.collapsed .panel-body {
    display: none;
}

.panel-flotante.collapsed {
    height: auto;
}

.panel-header {
    background: #1e3a8a;
    color: white;
    padding: 0.58rem 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
    border-radius: 0.5rem 0.5rem 0 0;
}

.panel-flotante.collapsed .panel-header {
    border-radius: 0.5rem;
}

.panel-header span {
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-toggle-collapse {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0 0.35rem;
    line-height: 1;
    width: 24px;
    height: 24px;
    border-radius: 0.25rem;
    transition: background 0.2s;
}

.btn-toggle-collapse:hover {
    background: rgba(255,255,255,0.3);
}

.panel-body {
    padding: 0.72rem 0.8rem 0.8rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.panel-enunciado .panel-body {
    display: block;
}

/* Scrollbar personalizado para paneles */
.panel-body::-webkit-scrollbar {
    width: 8px;
}

.panel-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 0.5rem 0;
}

.panel-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.panel-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Enunciado */
.enunciado-texto {
    margin-bottom: 1rem;
    line-height: 1.5;
    color: #333;
    font-size: 0.85rem;
}

.opciones-respuesta {
    margin-top: 1rem;
}

.opciones-respuesta h4 {
    font-size: 0.9rem;
    color: #1e3a8a;
    margin-bottom: 0.5rem;
}

.opcion-item {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.6rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.opcion-item:hover {
    background: #e9ecef;
    border-color: #1e3a8a;
}

.opcion-item.selected {
    background: #e7f3ff;
    border-color: #1e3a8a;
    font-weight: 600;
}

.opcion-item.correcta {
    background: #d1e7dd;
    border-color: #198754;
    box-shadow: 0 0 0 1px rgba(25, 135, 84, 0.18);
}

.opcion-item.incorrecta {
    background: #f8d7da;
    border-color: #dc3545;
}

.panel-enunciado.solucion-revelada .opciones-respuesta h4 {
    color: #166534;
}

.solucion-estado {
    display: none;
    margin-top: 0.75rem;
    padding: 0.65rem 0.8rem;
    border-radius: 0.45rem;
    background: #ecfdf3;
    border: 1px solid #b7e4c7;
    color: #166534;
    font-size: 0.83rem;
    line-height: 1.4;
}

.solucion-estado.visible {
    display: none;
}

/* Panel de pasos */
.pasos-navegacion {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.12rem 0 0.22rem;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 0.28rem;
    flex-shrink: 0;
}

.paso-hover-tiempo {
    min-height: 0.9rem;
    margin: 0 0 0.3rem;
    color: #475569;
    font-size: 0.71rem;
    font-weight: 600;
}

.pasos-lista {
    flex: 1;
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.1rem 0;
}

.pasos-lista::-webkit-scrollbar {
    height: 6px;
}

.pasos-lista::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.pasos-lista::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.paso-num {
    min-width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    border: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 0.78rem;
}

.paso-num:hover {
    background: #dee2e6;
}

.paso-num.activo {
    background: #1e3a8a;
    color: white;
    border-color: #1e3a8a;
    transform: scale(1.04);
}

.paso-num.completado {
    background: #198754;
    color: white;
    border-color: #198754;
}

.btn-paso {
    background: #1e3a8a;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    font-size: 0.85rem;
}

.btn-paso-flecha {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 11px;
    font-size: 1.35rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.btn-paso-flecha svg {
    width: 22px;
    height: 22px;
    display: block;
}

.btn-paso-flecha path {
    fill: none;
    stroke: currentColor;
    stroke-width: 3.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-paso:hover:not(:disabled) {
    background: #1e40af;
}

.btn-paso:disabled {
    background: #6c757d;
    opacity: 0.5;
    cursor: not-allowed;
}

.paso-contenido {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

.paso-contenido::-webkit-scrollbar {
    width: 8px;
}

.paso-contenido::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.paso-contenido::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#paso-titulo {
    color: #1e3a8a;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

#paso-descripcion {
    color: #495057;
    line-height: 1.5;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

#paso-calculos {
    background: #f8f9fa;
    border-left: 4px solid #1e3a8a;
    padding: 0.75rem;
    border-radius: 0.25rem;
    margin-top: 0.75rem;
}

#paso-calculos h4 {
    font-size: 0.9rem;
    color: #1e3a8a;
    margin-bottom: 0.5rem;
}

.calculos-cabecera {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.calculos-cabecera::before {
    content: '';
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #2563eb;
    box-shadow: 0 0 0 3px #dbeafe;
}

.calculo-item {
    position: relative;
    margin-bottom: 0.65rem;
    padding: 0.65rem 0.7rem 0.65rem 2.15rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.45rem;
    background: #fff;
}

.calculo-item::before {
    content: attr(data-calculo-orden);
    position: absolute;
    top: 0.65rem;
    left: 0.65rem;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #dbeafe;
    color: #1d4ed8;
    font: 700 0.65rem/1 system-ui, sans-serif;
}

.calculo-item:last-child {
    margin-bottom: 0;
}

.calculo-titulo {
    margin-bottom: 0.3rem;
    color: #1e3a8a;
    font-size: 0.78rem;
    font-weight: 700;
}

.calculo-formula {
    font-weight: 600;
    color: #1e3a8a;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.calculo-operacion {
    font-family: 'Courier New', monospace;
    color: #495057;
    margin-left: 1rem;
    font-size: 0.8rem;
}

.calculo-sustitucion {
    margin: 0.2rem 0 0.25rem;
    color: #475569;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
}

.calculo-explicacion {
    color: #6c757d;
    font-style: italic;
    margin-left: 1rem;
    font-size: 0.8rem;
}

/* Resultado legible del paso (visualizacion.mensaje) */
#paso-mensaje {
    background: #eff6ff;
    border-left: 4px solid #2563eb;
    color: #1e3a8a;
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    border-radius: 0.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

/* Tabla del paso de resumen (visualizacion.datos) */
#paso-resumen {
    background: #f0fdf4;
    border-left: 4px solid #16a34a;
    padding: 0.75rem;
    border-radius: 0.25rem;
    margin-top: 0.75rem;
}

#paso-resumen h4 {
    font-size: 0.9rem;
    color: #166534;
    margin-bottom: 0.5rem;
}

.resumen-fila {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid #dcfce7;
    font-size: 0.85rem;
}

.resumen-fila:last-child {
    border-bottom: none;
}

.resumen-label {
    color: #495057;
}

.resumen-valor {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #166534;
    text-align: right;
}

/* Aviso cuando el paso declara trazado pero le falta la geometria */
#paso-aviso-trazado {
    background: #fffbeb;
    border-left: 4px solid #d97706;
    color: #92400e;
    padding: 0.6rem 0.75rem;
    border-radius: 0.25rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    font-style: italic;
}

/* Contenedor de la carta - pantalla completa sin barra lateral */
#resolver-container #loading {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2c3e50;
    color: white;
    font-size: 1.2rem;
    z-index: 998;
}

#resolver-container #container {
    position: absolute;
    top: 40px;
    left: 0 !important;
    right: 0;
    bottom: 0;
    width: 100vw !important;
    height: calc(100vh - 40px) !important;
    margin: 0;
}

#resolver-container #ruler-controls {
    top: 78px;
    bottom: auto;
    left: clamp(28px, 22vw, 430px);
}

/* Ajustes para el reloj de simulación en modo resolver */
#simulation-clock {
    top: 44px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 58, 138, 0.9);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
}

.resolver-ship-cross-icon {
    background: transparent;
    border: none;
    width: 18px !important;
    height: 18px !important;
}

.resolver-ship-cross {
    position: relative;
    display: block;
    width: 18px;
    height: 18px;
}

.resolver-ship-cross::before,
.resolver-ship-cross::after {
    content: "";
    position: absolute;
    left: 8px;
    top: 1px;
    width: 2px;
    height: 16px;
    background: var(--cross-color, #1d4ed8);
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.resolver-ship-cross::before {
    transform: rotate(45deg);
}

.resolver-ship-cross::after {
    transform: rotate(-45deg);
}

@media (max-width: 1100px) {
    .resolver-header {
        padding: 0.18rem 0.55rem;
    }

    .header-right {
        gap: 0.35rem;
    }

    .header-title-row {
        gap: 0.22rem;
    }

    .resolver-meta-item {
        font-size: 0.58rem;
    }
}

/* Herramienta de compás */
#compas-tool, #compas-animacion {
    position: absolute;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 1002;
}

.compas-brazo {
    position: absolute;
    width: 2px;
    background: #dc2626;
    transform-origin: top center;
    top: 10px;
    left: 9px;
    box-shadow: 0 0 4px rgba(220, 38, 38, 0.5);
}

.compas-punta {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #dc2626;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    left: 10px;
    box-shadow: 0 0 6px rgba(220, 38, 38, 0.7);
}

.compas-centro {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #1e3a8a;
    border-radius: 50%;
    top: 4px;
    left: 4px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Responsive */
@media (max-width: 768px) {
    .panel-flotante {
        max-width: calc(100% - 40px);
    }

    .panel-enunciado {
        right: 10px;
        max-height: 50vh;
    }

    .panel-pasos {
        left: 10px;
        top: auto;
        bottom: 10px;
        max-height: 50vh;
        max-width: calc(100% - 20px);
    }

    .ejercicio-titulo {
        font-size: 0.9rem;
    }

    .header-left, .header-right {
        gap: 0.5rem;
    }
}
