:root {
    --duo-green: #58cc02;
    --duo-green-shadow: #58a700;
    --duo-red: #ff4b4b;
    --duo-red-shadow: #ea2b2b;
    --duo-blue: #1cb0f6;
    --duo-blue-shadow: #1899d6;
    --duo-gray: #e5e5e5;
    --duo-gray-shadow: #c4c4c4;
    --bg-main: #f5f6fa;
    --bg-gray: #e5e5e5;
    --text-main: #3c3c3c;
    --duo-purple: #8c00ff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.4s ease;
}

/* Fondo amarillo Piolín para el éxito */
body.success-bg {
    background-color: #ffd700 !important; 
}

.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

/* ==================== */
/*      MAP VIEW        */
/* ==================== */
.map-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow-y: auto;
    padding-right: 10px; /* scrollbar padding */
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.map-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Menú Hamburguesa */
.hamburger-menu {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 45px;
    background-color: white;
    min-width: 210px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    border-radius: 10px;
    z-index: 10;
    overflow: hidden;
}

.dropdown-content button {
    color: var(--text-main);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.dropdown-content button:hover {
    background-color: #f1f1f1;
}

.dropdown-content.show {
    display: block;
}

.life-controls {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
}

.life-controls button {
    background: white;
    border: none;
    width: 20px;
    height: 16px;
    font-size: 14px;
    font-weight: bold;
    color: var(--duo-purple);
    cursor: pointer;
    line-height: 1;
}

.life-controls button:first-child {
    border-radius: 5px 5px 0 0;
    border-bottom: 1px solid #ccc;
}

.life-controls button:last-child {
    border-radius: 0 0 5px 5px;
}

.map-header h2 {
    color: white;
    font-weight: 800;
}

.blocks-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    padding-bottom: 40px;
}

.block-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.block-title {
    color: white;
    width: 100%;
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    font-weight: 800;
    margin-bottom: 30px;
}

.block-1 .block-title { background-color: var(--duo-green); box-shadow: 0 4px 0 var(--duo-green-shadow); }
.block-2 .block-title { background-color: #ffc800; box-shadow: 0 4px 0 #d9a900; }
.block-3 .block-title { background-color: var(--duo-red); box-shadow: 0 4px 0 var(--duo-red-shadow); }
.block-extra .block-title { background-color: var(--duo-blue); box-shadow: 0 4px 0 var(--duo-blue-shadow); }

.level-nodes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    position: relative;
}

.level-node {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--duo-gray);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    font-weight: 900;
    color: white;
    box-shadow: 0 6px 0 var(--duo-gray-shadow);
    transition: transform 0.1s;
    user-select: none;
}

.level-node.named-node {
    width: auto;
    min-width: 150px;
    height: auto;
    border-radius: 20px;
    padding: 15px 30px;
    font-size: 20px;
}

/* Estados de los niveles */
.level-node.locked {
    color: #afafaf;
    cursor: not-allowed;
}

.level-node.completed {
    background-color: #ffc800;
    box-shadow: 0 6px 0 #d9a900;
    cursor: pointer;
}

.level-node.active {
    background-color: var(--duo-green);
    box-shadow: 0 6px 0 var(--duo-green-shadow);
    cursor: pointer;
}

.level-node.active:hover, .level-node.completed:hover {
    transform: translateY(-2px);
}
.level-node.active:active, .level-node.completed:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 transparent;
}

/* ==================== */
/*   EXERCISE VIEW      */
/* ==================== */
.exercise-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* TOP BAR */
.top-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #afafaf;
    cursor: pointer;
    font-weight: bold;
}

.close-btn:hover { color: #888; }

.progress-bar-container {
    flex-grow: 1;
    height: 16px;
    background-color: var(--duo-gray);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--duo-green);
    width: 20%; /* Progreso inicial */
    border-radius: 10px;
    transition: width 0.4s ease-in-out;
}

.remaining-counter {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 900;
    font-size: 18px;
    color: var(--duo-blue);
}

.hearts-container {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    font-size: 18px;
    color: var(--duo-red);
}

/* EXERCISE AREA */
.exercise-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding-right: 10px; /* padding for scrollbar */
}

.exercise-title {
    font-size: 24px;
    font-weight: 800;
}

.exercise-instruction {
    font-size: 18px;
    line-height: 1.5;
}

/* PALABRAS CLICKABLES EN LA INSTRUCCIÓN */
.instruction-clickable {
    color: var(--duo-blue);
    font-weight: 800;
    cursor: pointer;
    border-bottom: 2px dashed var(--duo-blue);
    transition: all 0.2s;
    padding: 2px 4px;
    border-radius: 4px;
}

.instruction-clickable:hover {
    background-color: #e0f0ff;
}

.instruction-clickable.added {
    background-color: var(--duo-green);
    color: white;
    border-bottom-color: transparent;
}

/* SCHEMA VISUALIZER */
.schema-container {
    background-color: var(--bg-gray);
    border: 2px solid var(--duo-gray);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 10px;
}

.schema-container h3 {
    font-size: 14px;
    color: #afafaf;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.schema-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.schema-tag {
    background-color: white;
    border: 2px solid var(--duo-gray);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 800;
    color: var(--duo-blue);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, color 0.2s;
}

.schema-tag:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
}

.schema-tag:active {
    transform: translateY(0);
}

.schema-tag span.desc {
    font-weight: normal;
    color: #777;
    margin-left: 6px;
    font-size: 12px;
}

/* ==================== */
/*       MODALS         */
/* ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.dict-list {
    font-size: 15px;
    color: var(--text-main);
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px;
}

.dict-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dict-list li {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f5f5f5;
    line-height: 1.4;
}

.dict-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.dict-list strong {
    color: var(--duo-purple);
    font-size: 16px;
}

.code-editor-container {
    flex-grow: 1;
    margin-bottom: 20px;
}

#sql-input {
    width: 100%;
    height: 100px;
    min-height: 150px;
    border: 2px solid var(--duo-gray);
    border-radius: 15px;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--duo-blue);
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

#sql-input:focus {
    border-color: var(--duo-blue);
}

.show-answer-btn {
    background: none;
    border: none;
    color: var(--duo-blue);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 10px;
    text-transform: uppercase;
    transition: color 0.2s;
}

.show-answer-btn:hover {
    color: var(--duo-blue-shadow);
    text-decoration: underline;
}

/* HINT CONTAINER (Fórmula) */
.hint-container {
    padding: 10px 15px;
    background-color: #ffdde0;
    color: var(--duo-red);
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    border: 2px solid var(--duo-red-shadow);
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

/* BOTTOM BAR */
.bottom-bar {
    border-top: 2px solid var(--duo-gray);
    padding: 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.feedback-message {
    display: none; /* Oculto por defecto */
}

/* CONTENEDOR DE BOTONES */
.button-container {
    display: flex;
    gap: 15px;
    width: 100%;
}

/* BOTÓN SALTAR (Estilo secundario) */
.skip-btn {
    flex: 1; /* Ocupa el espacio equitativamente */
    background-color: #8c00ff;
    color: white;
    border: none;
    padding: 15px 15px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 15px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.1s;
    box-shadow: 0 4px 0 #6a00c4;
}

.skip-btn:hover {
    background-color: #9d2aff;
}

.skip-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #6a00c4;
}

/* BOTÓN DUOLINGO 3D PRINCIPAL */
.check-btn {
    flex: 2; /* El botón comprobar es más ancho */
    background-color: var(--duo-gray);
    color: #afafaf;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 800;
    border-radius: 15px;
    width: 100%;
    cursor: not-allowed;
    text-transform: uppercase;
    box-shadow: 0 4px 0 var(--duo-gray-shadow);
    transition: all 0.1s;
}

/* Estado activo del botón */
.check-btn.active {
    background-color: var(--duo-green);
    color: white;
    box-shadow: 0 4px 0 var(--duo-green-shadow);
    cursor: pointer;
}

.check-btn.active:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--duo-green-shadow);
}
