/* =====================================================================
 * ESTILOS DE LA ENCUESTA PÚBLICA (MICROSOFT / GOOGLE FORMS INSPIRADO)
 * ===================================================================== */

:root {
    --primary-color: #007BFF;
    --primary-hover: #0056B3;
    --brand-navy: #002D62;
    --accent-light: #00AEEF;
    --bg-color: #F0F4F8;
    --card-bg: #FFFFFF;
    --text-color: #002D62;
    --text-muted: #666666;
    --border-color: #E2E8F0;
    --input-bg: #F8FAFC;
    --input-focus: #FFFFFF;
    
    /* Variables de satisfacción */
    --promoter-color: #2D3748;
    --star-active: #FFB020;
    
    /* Sombras y Bordes */
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --transition-speed: 0.3s;
}

/* Variables del Modo Oscuro */
body.dark-mode {
    --bg-color: #0F172A;
    --card-bg: #1E293B;
    --text-color: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: #334155;
    --input-bg: #0F172A;
    --input-focus: #1E293B;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* Reset y General */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.survey-body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* Loader */
.survey-loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toggle Modo Oscuro */
.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background-color: var(--card-bg);
    color: var(--primary-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    z-index: 1000;
    transition: transform 0.2s ease, background-color var(--transition-speed) ease;
}
.dark-mode-toggle:hover {
    transform: scale(1.1);
}

/* Wrapper */
.survey-wrapper {
    width: 100%;
    max-width: 680px;
    margin: 40px auto;
}

/* Tarjeta Principal */
.survey-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: background-color var(--transition-speed) ease;
    border-top: 8px solid var(--primary-color);
}

/* Barra de progreso superior */
.progress-bar-container {
    height: 6px;
    background-color: var(--border-color);
    width: 100%;
    position: relative;
}
.progress-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cabecera */
.survey-header {
    padding: 35px 35px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}
.company-logo {
    font-size: 2.8rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    animation: rotateLogo 8s linear infinite;
    display: inline-block;
}
@keyframes rotateLogo {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.survey-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
}
.survey-header .subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
}
.survey-meta-badge {
    display: inline-block;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 30px;
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Contenido del Cuerpo */
.survey-body-content {
    padding: 30px 35px;
}

/* Estados Especiales: Agradecimiento / Error */
.state-container {
    padding: 20px 0;
}
.success-icon {
    color: #10B981;
}
.error-icon {
    color: #EF4444;
}
.info-icon {
    color: var(--primary-color);
}
.state-title {
    font-size: 1.6rem;
    font-weight: 600;
}
.state-text {
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.6;
    max-width: 480px;
    margin: 0 auto;
}

/* Burbuja en línea de Alya en Éxito */
.alya-inline-bubble {
    display: flex;
    align-items: center;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 15px 20px;
    max-width: 420px;
    margin: 25px auto 0;
}
.alya-inline-bubble .alya-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-right: 15px;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid var(--primary-color);
    background-color: #FFFFFF;
}
.alya-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(1.35);
}
.alya-inline-bubble .alya-speech {
    font-size: 1rem;
    text-align: left;
    font-style: italic;
    line-height: 1.4;
}

/* Preguntas / Tarjetas de Formulario (Wizard Style) */
.form-question-card {
    display: none;
    padding: 25px 0;
}
.form-question-card.active {
    display: block;
    animation: slideInCard 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

@keyframes shakeCard {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}
.shake-card {
    animation: shakeCard 0.4s ease-in-out;
}
.question-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
}
.question-title .required {
    color: #EF4444;
}
.question-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* Estilo de Estrellas (★ ★ ★ ★ ★) */
.star-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 8px;
}
.star-rating input {
    display: none;
}
.star-rating label {
    font-size: 2.2rem;
    color: var(--border-color);
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
}
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
    color: var(--star-active);
}
.star-rating label:hover {
    transform: scale(1.2);
}
/* Cambiar ícono a estrella rellena cuando está seleccionado o hover */
.star-rating input:checked ~ label i,
.star-rating label:hover i,
.star-rating label:hover ~ label i {
    font-weight: 900;
}

/* Escala NPS (0 - 10) */
.nps-scale-wrapper {
    margin-top: 10px;
}
.nps-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}
.nps-options {
    display: flex;
    justify-content: space-between;
    gap: 5px;
}
.nps-option {
    flex: 1;
    text-align: center;
}
.nps-option input {
    display: none;
}
.nps-option label {
    display: block;
    padding: 10px 0;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    color: var(--text-color);
}
.nps-option label:hover {
    background-color: var(--border-color);
    transform: translateY(-2px);
}
.nps-option input:checked + label {
    background-color: var(--primary-color);
    color: #FFFFFF;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(20, 117, 170, 0.3);
}

/* Inputs de Texto */
.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    transition: all 0.2s ease;
    resize: vertical;
}
.form-control:focus {
    outline: none;
    background-color: var(--input-focus);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(20, 117, 170, 0.15);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-block {
    width: 100%;
}
.btn-lg {
    padding: 15px 30px;
    font-size: 1.1rem;
}
.btn-primary {
    background-color: var(--primary-color);
    color: #FFFFFF;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 117, 170, 0.2);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-primary:disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Pie de Página */
.survey-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* =====================================================================
 * WIDGET DE ASISTENTE VIRTUAL ALYA (BOT FLOTANTE)
 * ===================================================================== */

.alya-widget {
    position: fixed;
    bottom: 30px;
    right: 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 999;
}

/* Globo de diálogo de Alya */
.alya-speech-bubble {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    border-radius: 18px;
    padding: 15px 20px;
    max-width: 250px;
    margin-bottom: 12px;
    position: relative;
    animation: fadeInUp 0.4s ease forwards;
    transform-origin: bottom center;
    text-align: center;
}
.alya-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: calc(50% - 7.5px);
    width: 15px;
    height: 15px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transform: translateY(50%) rotate(45deg);
}

/* Animación de Escritura (Typing indicator) */
.alya-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 0;
}
.alya-typing span {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.alya-typing span:nth-child(1) { animation-delay: -0.32s; }
.alya-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.alya-text {
    font-size: 0.92rem;
    line-height: 1.4;
    color: var(--text-color);
    font-weight: 500;
}

/* Avatar del Robot */
.alya-character {
    width: 228px;
    height: 315px;
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background-color: transparent;
}
.alya-character:hover {
    transform: scale(1.04) translateY(-3px);
}
.alya-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

/* Animaciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.fade-in {
    animation: fadeInUp 0.4s ease forwards;
}

/* Responsividad para móviles */
@media (max-width: 600px) {
    body.survey-body {
        padding: 12px 12px 120px;
        align-items: flex-start;
    }
    .survey-wrapper {
        margin: 8px auto 24px;
        max-width: 100%;
    }
    .survey-card {
        border-radius: 14px;
        border-top-width: 6px;
    }
    .survey-header {
        padding: 22px 18px 14px;
    }
    .survey-header h1 {
        font-size: 1.35rem;
    }
    .survey-header .subtitle {
        font-size: 0.98rem;
        line-height: 1.4;
    }
    .survey-meta-badge {
        display: block;
        max-width: 100%;
        padding: 10px 14px;
        font-size: 0.88rem;
        line-height: 1.35;
        word-break: break-word;
        border-radius: 12px;
    }
    .company-logo-img-wrapper {
        max-width: min(240px, 88vw);
        padding: 8px 10px;
    }
    .company-logo-img {
        max-height: 56px;
    }
    .survey-body-content {
        padding: 18px 16px 22px;
    }
    .question-title {
        font-size: 1.08rem;
        line-height: 1.45;
    }
    .question-desc {
        font-size: 0.92rem;
        margin-bottom: 18px;
    }
    .form-question-card {
        padding: 18px 0;
    }
    .star-rating {
        gap: 10px;
        justify-content: center;
        flex-wrap: wrap;
    }
    .star-rating label {
        font-size: 2.35rem;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .nps-labels {
        font-size: 0.78rem;
        gap: 8px;
        line-height: 1.3;
    }
    .nps-options {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 6px;
        justify-content: initial;
    }
    .nps-option {
        flex: initial;
    }
    .nps-option label {
        min-height: 44px;
        padding: 10px 0;
        font-size: 0.95rem;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
    }
    .form-control {
        min-height: 48px;
        font-size: 1rem;
        padding: 14px 16px;
    }
    textarea.form-control {
        min-height: 120px;
    }
    .btn {
        min-height: 48px;
        padding: 14px 20px;
        font-size: 1rem;
    }
    .btn-lg {
        padding: 16px 22px;
        font-size: 1.05rem;
    }
    .survey-navigation {
        gap: 10px;
        flex-wrap: wrap;
    }
    .survey-navigation .btn {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }
    .survey-navigation #btnSubmitSurvey {
        flex: 1 1 100%;
    }
    .state-title {
        font-size: 1.35rem;
    }
    .state-text {
        font-size: 0.98rem;
        padding: 0 4px;
    }
    .alya-inline-bubble {
        flex-direction: row;
        max-width: 100%;
        padding: 12px 14px;
        margin-top: 18px;
    }
    .alya-inline-bubble .alya-avatar {
        width: 48px;
        height: 48px;
        margin-right: 12px;
    }
    .alya-inline-bubble .alya-speech {
        font-size: 0.92rem;
    }
    .survey-footer {
        padding: 16px;
        font-size: 0.8rem;
    }
    .dark-mode-toggle {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
    }

    /* Alya: no tapar el formulario en móvil */
    .alya-widget {
        bottom: 10px;
        right: 10px;
        align-items: flex-end;
        max-width: min(220px, calc(100vw - 24px));
        pointer-events: none;
    }
    .alya-widget .alya-speech-bubble,
    .alya-widget .alya-character {
        pointer-events: auto;
    }
    .alya-character {
        width: 78px;
        height: 108px;
    }
    .alya-speech-bubble {
        max-width: 200px;
        padding: 10px 12px;
        margin-bottom: 8px;
        font-size: 0.85rem;
    }
    .alya-text {
        font-size: 0.82rem;
        line-height: 1.35;
    }
    .alya-speech-bubble.alya-collapsed,
    .alya-widget.alya-minimized .alya-speech-bubble {
        display: none !important;
    }
}

@media (max-width: 380px) {
    .nps-options {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .star-rating label {
        font-size: 2.1rem;
    }
    .alya-character {
        width: 64px;
        height: 88px;
    }
}

/* Utilidades de Diseño y Botones */
.d-flex { display: flex !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.ml-2 { margin-left: 0.5rem !important; }
.text-center { text-align: center !important; }

.btn-secondary {
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--border-color);
}

/* Logotipo de Empresa */
.company-logo-img-wrapper {
    max-width: min(320px, 92%);
    width: 100%;
    margin: 0 auto 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #FFFFFF;
    padding: 10px 14px;
    border-radius: 8px;
}
.company-logo-img {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 78px;
    object-fit: contain;
}
.mb-3 {
    margin-bottom: 1rem !important;
}
