:root {
    --primary: #39A900;
    --primary-hover: #2e8800;
    --bg-light: #f0f4f8;
    --card-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(57, 169, 0, 0.15);
    --text-main: #1a202c;
    --text-muted: #4a5568;
    --populito-bg: rgba(57, 169, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background Animations */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: rgba(57, 169, 0, 0.2);
    top: -100px;
    right: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: rgba(0, 50, 0, 0.1);
    bottom: -150px;
    left: -100px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.8);
    top: 50%;
    left: 50%;
    animation-delay: -10s;
}

@keyframes move {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(100px, 50px) scale(1.1);
    }
}

/* Main Container */
.container {
    width: 95%;
    max-width: 1400px;
    /* Mayor ancho máximo */
    min-height: 90vh;
    /* Altura mínima en lugar de fija */
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 1;
    padding: 2rem 0;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.brand h1 {
    font-size: 1.8rem;
    font-weight: 600;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    font-weight: 600;
}

#page-indicator {
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Layout: Dos Columnas */
.main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1.8fr 1fr;
    /* Más espacio al visual (iframe) */
    gap: 3rem;
    /* Mayor separación */
    min-height: 0;
}

/* Panel Visual */
.visual-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.viewer-card {
    flex: 1;
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    padding: 0;
    /* Sin padding para que el iframe sea total */
}

.image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-container {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

#page-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-transition {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
}

/* Panel de Interacción */
.interaction-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    justify-content: center;
}

.content-card-wrapper {
    display: none;
    /* Ya no se usa a la derecha */
}

#content-frame {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 24px;
    background: transparent;
}

/* Populito Styles */
.populito-card {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.populito-avatar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.populito-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    overflow: hidden;
    border: 3px solid var(--glass-border);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.2);
}

.character-selector {
    display: flex;
    gap: 6px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.char-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.char-btn[data-char="populito"] {
    background-image: url('images/populito.png');
    background-size: cover;
}

.char-btn[data-char="populita_joven"] {
    background-image: url('images/populita_joven.png');
    background-size: cover;
}

.char-btn[data-char="popu_madre"] {
    background-image: url('images/popu_madre.png');
    background-size: cover;
}

.char-btn[data-char="populo_anciano"] {
    background-image: url('images/populo_anciano.png');
    background-size: cover;
}

.char-btn[data-char="populita_indigena"] {
    background-image: url('images/populita_indigena.png');
    background-size: cover;
}

.char-btn:hover {
    transform: scale(1.2);
}

.char-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

.populito-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.populito-bubble {
    background: var(--populito-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 0 24px 24px 24px;
    position: relative;
    flex: 1;
}

.populito-bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 20px;
    border-style: solid;
    border-width: 10px 10px 10px 0;
    border-color: transparent var(--glass-border) transparent transparent;
}

.populito-bubble p {
    font-size: 1rem;
    color: var(--text-main);
    font-style: italic;
}

/* Animaciones de Revelación */
.text-reveal {
    animation: reveal 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Controles Inferiores */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.audio-progress-container {
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    cursor: pointer;
    overflow: hidden;
    transition: height 0.2s ease;
}

.progress-bar:hover {
    height: 8px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, var(--primary), #818cf8);
    transition: width 0.1s linear;
}

.audio-time {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 1rem 2rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
    background: var(--glass-border);
    border-color: var(--text-muted);
}

.play-group {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.play-btn {
    background: var(--primary);
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.play-btn:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.speed-select {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
}

/* Audio Waves */
.audio-waves {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.audio-waves span {
    width: 3px;
    background: var(--primary);
    border-radius: 2px;
    animation: wave 1s infinite ease-in-out;
}

.audio-waves span:nth-child(1) {
    height: 10px;
    animation-delay: 0.1s;
}

.audio-waves span:nth-child(2) {
    height: 18px;
    animation-delay: 0.2s;
}

.audio-waves span:nth-child(3) {
    height: 14px;
    animation-delay: 0.3s;
}

.audio-waves span:nth-child(4) {
    height: 10px;
    animation-delay: 0.4s;
}

@keyframes wave {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.5);
    }
}

.hidden {
    display: none;
}

.icon-btn {
    cursor: pointer;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: white;
    padding: 5px;
    border-radius: 5px;
    position: absolute;
    top: 1rem;
    right: 1rem;
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .container {
        height: auto;
        padding: 2rem 0;
        overflow-y: auto;
    }

    .interaction-panel {
        order: 2;
    }

    .visual-panel {
        order: 1;
        aspect-ratio: 16/9;
    }
}