/* ================================
   TAB NAVIGATION SYSTEM
   ================================ */

.tab-navigation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0;
    background: var(--color-principal);
    padding: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.tab-button {
    flex: 1;
    max-width: 200px;
    padding: 15px 30px;
    background: transparent;
    color: var(--color-secundario);
    opacity: 0.7;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tab-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transition: left 0.3s ease;
}

.tab-button:hover::before {
    left: 0;
}

.tab-button:hover {
    color: var(--color-secundario);
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.05);
}

.tab-button.active {
    color: var(--color-secundario);
    opacity: 1;
    border-bottom-color: var(--color-secundario);
    background: rgba(255, 255, 255, 0.15);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background: var(--color-secundario);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* ================================
   TAB CONTENT
   ================================ */

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-in;
    padding-top: 85px; /* Space for fixed tab navigation */
    min-height: 100vh;
    position: relative;
    z-index: 2; /* Por encima de los fondos decorativos */
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-content.active {
    display: block;
}

/* Background específico para cada tab */
#tab-panelito {
    background: #87CEEB; /* Fallback color */
    position: relative;
    overflow: hidden;
}

/* Canvas Background for Animations */
.background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none; /* Allow clicks to pass through to elements below */
}

/* Canvas Overlay for Panelito Effects */
.panelito-effects-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 15; /* Above avatar but below controls */
    pointer-events: none;
}

/* Asegurar que fullscreen-container tenga contexto de posición */
#tab-panelito .fullscreen-container {
    position: relative;
    z-index: 10; /* Above canvas */
}

#tab-experimento {
    background: var(--color-gris-claro);
    position: relative;
}

#tab-juegos {
    background: var(--color-gris-claro);
    position: relative;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================
   SPLIT SCREEN (EXPERIMENTO TAB)
   ================================ */

.split-screen {
    display: flex;
    min-height: calc(100vh - 85px);
    background: transparent; /* Sin background, usa el del tab */
}

.split-left {
    flex: 0 0 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--color-principal);
    border-right: 3px solid var(--color-accent-azul);
}

.split-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--color-secundario);
    overflow-y: auto;
}

/* Avatar Container (Smaller for Experimento) */
.avatar-container-small {
    transform: scale(0.6);
    transform-origin: center center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-container-small .avatar-main {
    position: relative;
    margin: 0 auto;
}

/* ================================
   SENSOR INTERFACE
   ================================ */

.sensor-container {
    width: 100%;
    max-width: 700px;
    background: var(--color-secundario);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.sensor-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 24px;
}

/* Sensor Controls */
.sensor-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.sensor-button {
    padding: 10px 20px;
    border: 2px solid var(--color-gris-medio);
    background: var(--color-secundario);
    color: var(--color-gris-oscuro);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.sensor-button:hover {
    background: var(--color-gris-claro);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.sensor-button.primary {
    background: var(--color-accent-azul);
    color: var(--color-secundario);
    border-color: var(--color-accent-azul);
}

.sensor-button.primary:hover {
    background: #2196f3;
    border-color: #2196f3;
}

.sensor-button.secondary {
    background: var(--color-gris-oscuro);
    color: var(--color-secundario);
    border-color: var(--color-gris-oscuro);
}

.sensor-button.secondary:hover {
    background: #616161;
    border-color: #616161;
}

.sensor-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Bluetooth Status */
.bluetooth-status {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.bluetooth-status.connected {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.bluetooth-status.disconnected {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

/* Voltage Readings */
.voltage-readings {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.voltage-display {
    flex: 1;
    background: var(--color-gris-claro);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 3px solid;
    min-width: 150px;
}

.voltage-display.sensor1 {
    border-color: var(--color-accent-azul);
}

.voltage-display.sensor2 {
    border-color: var(--color-error);
}

.voltage-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 600;
}

.voltage-value {
    font-size: 32px;
    font-weight: bold;
}

.voltage-display.sensor1 .voltage-value {
    color: var(--color-accent-azul);
}

.voltage-display.sensor2 .voltage-value {
    color: var(--color-error);
}

/* Graph Container */
.graph-container {
    background: var(--color-secundario);
    border: 2px solid var(--color-gris-medio);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    overflow: hidden;
}

#sensorCanvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* Graph Legend */
.graph-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
}

.legend-color {
    width: 30px;
    height: 4px;
    border-radius: 2px;
}

/* Info Message */
.info-message {
    background: rgba(74, 144, 226, 0.1);
    border: 2px solid var(--color-accent-azul);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    text-align: center;
}

.info-message p {
    margin: 8px 0;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

.info-message strong {
    color: var(--color-accent-azul);
}

.info-message code {
    background: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: #d63384;
    font-size: 13px;
}

/* ================================
   COMING SOON PAGE (JUEGOS)
   ================================ */

.coming-soon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 85px);
    color: white;
    text-align: center;
    padding: 40px;
}

.coming-soon-container h1 {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.coming-soon-container p {
    font-size: 20px;
    max-width: 600px;
    line-height: 1.6;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.coming-soon-icon {
    font-size: 120px;
    margin: 30px 0;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.coming-soon-subtitle {
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 20px;
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

@media (max-width: 1024px) {
    .split-screen {
        flex-direction: column;
        min-height: calc(100vh - 85px);
    }

    .split-left {
        flex: 0 0 auto;
        min-height: 40vh;
        height: auto;
        border-right: none;
        border-bottom: 3px solid rgba(255, 255, 255, 0.3);
    }

    .split-right {
        flex: 1;
        min-height: 60vh;
        height: auto;
    }

    .avatar-container-small {
        transform: scale(0.5);
    }
}

@media (max-width: 768px) {
    .tab-content {
        padding-top: 75px; /* Menor padding para tabs más pequeños */
    }

    .tab-button {
        padding: 12px 20px;
        font-size: 14px;
        max-width: 150px;
    }

    .sensor-container {
        padding: 15px;
    }

    .sensor-container h2 {
        font-size: 20px;
    }

    .voltage-readings {
        flex-direction: column;
    }

    .voltage-value {
        font-size: 24px;
    }

    .sensor-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .sensor-button {
        width: 100%;
    }

    .coming-soon-container {
        min-height: calc(100vh - 75px);
    }

    .coming-soon-container h1 {
        font-size: 32px;
    }

    .coming-soon-container p {
        font-size: 16px;
    }

    .coming-soon-icon {
        font-size: 80px;
    }

    .avatar-container-small {
        transform: scale(0.4);
    }

    .split-left {
        min-height: 30vh;
    }

    .split-screen {
        min-height: calc(100vh - 75px);
    }
}

@media (max-width: 480px) {
    .tab-button {
        padding: 10px 15px;
        font-size: 12px;
        max-width: 120px;
    }

    .tab-navigation {
        padding: 0;
    }

    #sensorCanvas {
        max-width: 100%;
        height: auto;
    }

    .manual-input {
        flex-direction: column;
    }

    .avatar-container-small {
        transform: scale(0.3);
    }
}

/* ================================
   TRIVIA GAME STYLES (JUEGOS TAB)
   ================================ */

.trivia-container {
    width: 100%;
    max-width: 700px;
    background: var(--color-secundario);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.trivia-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 25px;
    font-size: 26px;
    font-weight: bold;
}

/* Trivia Stats */
.trivia-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    padding: 15px;
    background: var(--color-principal);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.stat-item {
    text-align: center;
    color: var(--color-secundario);
}

.stat-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
    opacity: 0.9;
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: bold;
}

/* Question Card */
.question-card {
    background: linear-gradient(135deg, var(--color-gris-claro) 0%, var(--color-gris-medio) 100%);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.question-number {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent-azul);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-text {
    font-size: 20px;
    line-height: 1.6;
    color: #333;
    font-weight: 500;
}

/* Answer Buttons */
.answer-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.answer-btn {
    flex: 1;
    padding: 20px;
    font-size: 18px;
    font-weight: bold;
    border: 3px solid;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.true-btn {
    background: var(--color-success);
    color: var(--color-secundario);
    border-color: var(--color-success);
}

.true-btn:hover:not(.disabled) {
    background: #6ba82d;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(124, 179, 66, 0.4);
}

.false-btn {
    background: var(--color-error);
    color: var(--color-secundario);
    border-color: var(--color-error);
}

.false-btn:hover:not(.disabled) {
    background: #d32f2f;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(229, 57, 53, 0.4);
}

.answer-btn.correct {
    background: var(--color-success) !important;
    border-color: var(--color-success) !important;
    animation: correctPulse 0.6s ease;
}

.answer-btn.incorrect {
    background: var(--color-gris-oscuro) !important;
    border-color: var(--color-gris-oscuro) !important;
    opacity: 0.6;
    animation: shake 0.5s ease;
}

.answer-btn.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

/* Feedback Message */
.feedback-message {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback-message.correct {
    background: rgba(124, 179, 66, 0.15);
    border: 2px solid var(--color-success);
}

.feedback-message.incorrect {
    background: rgba(229, 57, 53, 0.15);
    border: 2px solid var(--color-error);
}

.feedback-icon {
    font-size: 48px;
    font-weight: bold;
    flex-shrink: 0;
}

.feedback-message.correct .feedback-icon {
    color: var(--color-success);
}

.feedback-message.incorrect .feedback-icon {
    color: var(--color-error);
}

.feedback-text {
    flex: 1;
    color: #333;
    font-size: 16px;
    line-height: 1.5;
}

.feedback-text strong {
    display: block;
    margin-bottom: 5px;
    font-size: 18px;
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.game-btn {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--color-accent-azul);
    color: var(--color-secundario);
    border-color: var(--color-accent-azul);
}

.game-btn:hover {
    background: #2196f3;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(74, 144, 226, 0.4);
}

.game-btn.secondary {
    background: var(--color-gris-oscuro);
    border-color: var(--color-gris-oscuro);
}

.game-btn.secondary:hover {
    background: #616161;
    box-shadow: 0 6px 15px rgba(117, 117, 117, 0.4);
}

.game-btn.primary {
    background: var(--color-principal);
    border: none;
    font-size: 18px;
    padding: 18px 40px;
}

.game-btn.primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(48, 57, 69, 0.5);
}

/* Results Screen */
.results-screen {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.results-screen h3 {
    font-size: 32px;
    color: var(--color-accent-azul);
    margin-bottom: 30px;
}

.final-score {
    background: var(--color-principal);
    border-radius: 15px;
    padding: 40px;
    margin-bottom: 30px;
    color: var(--color-secundario);
    box-shadow: 0 10px 30px rgba(48, 57, 69, 0.3);
}

.score-label {
    font-size: 18px;
    margin-bottom: 15px;
    opacity: 0.9;
}

.score-number {
    font-size: 72px;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.score-total {
    font-size: 24px;
    opacity: 0.9;
}

.performance-message {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

/* Responsive Design for Trivia */
@media (max-width: 768px) {
    .trivia-container {
        padding: 20px;
    }

    .trivia-container h2 {
        font-size: 22px;
    }

    .question-text {
        font-size: 18px;
    }

    .answer-buttons {
        flex-direction: column;
    }

    .answer-btn {
        width: 100%;
        padding: 18px;
    }

    .stat-value {
        font-size: 24px;
    }

    .score-number {
        font-size: 56px;
    }

    .feedback-message {
        flex-direction: column;
        text-align: center;
    }

    .feedback-icon {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .trivia-container {
        padding: 15px;
    }

    .trivia-container h2 {
        font-size: 20px;
    }

    .question-text {
        font-size: 16px;
    }

    .answer-btn {
        font-size: 16px;
        padding: 15px;
    }

    .trivia-stats {
        flex-direction: column;
        gap: 15px;
    }

    .game-controls {
        flex-direction: column;
    }

    .game-btn {
        width: 100%;
    }
}
