/* ============================================
   SAM - BBVA Mobile Interface
   Colors: #85C8FF (sky blue), #070E46 (dark navy),
           #001391 (electric blue), #FFFFFF (white)
   Font: system-ui, -apple-system, sans-serif
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #85C8FF;
    color: #070E46;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   1. PHONE CONTAINER (The Canvas)
   ============================================ */
.phone-container {
    max-width: 400px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: #85C8FF;
    padding: 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* ============================================
   2. HEADER
   ============================================ */
.header {
    flex-shrink: 0;
}

.header-img-wrapper {
    width: 100%;
    margin-bottom: 12px;
}

.header-img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* ============================================
   3. TITLE SECTION
   ============================================ */
.title-section {
    flex-shrink: 0;
    text-align: center;
    margin-bottom: 48px;
}

.main-title {
    font-size: 42px;
    font-weight: 700;
    color: #070E46;
    margin-bottom: 2px;
    line-height: 1;
}

.subtitle {
    font-size: 16px;
    color: #070E46;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* ============================================
   4. FORM SECTION
   ============================================ */
.form-section {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.instruction-text {
    text-align: left;
    color: #070E46;
    font-size: 16px;
    line-height: 1.4;
    margin-bottom: 16px;
    font-weight: 400;
}

/* Contenedor único: textarea + consejo */
.respuesta-contenedor {
    width: 100%;
    background: #FFFFFF;
    border: 3px solid #070E46;
    border-radius: 20px;
    padding: 16px;
}

.input-textarea {
    width: 100%;
    min-height: 130px;
    background: transparent;
    border: none;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    color: #070E46;
    resize: none;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
}

.input-textarea::placeholder {
    color: #070E46;
    opacity: 0.4;
}

/* Resultado (se muestra después de enviar) */
.resultado-categoria {
    font-size: 1.1rem;
    font-weight: 700;
    color: #001391;
    margin-bottom: 12px;
}

.resultado-mensaje {
    font-size: 0.95rem;
    color: #070E46;
    line-height: 1.5;
    margin-bottom: 24px;
}

/* Consejo dentro del mismo contenedor */
.consejo-section {
    width: 100%;
    margin-top: 0;
    padding-top: 0;
}

.consejo-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #001391;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.consejo-text {
    font-size: 0.95rem;
    color: #070E46;
    line-height: 1.5;
}

/* ============================================
   5. BUTTON
   ============================================ */
.btn-wrapper {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.btn-submit {
    background: #001391;
    color: #FFFFFF;
    padding: 10px 24px;
    border-radius: 20px;
    border: none;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    -webkit-appearance: none;
    touch-action: manipulation;
}

.btn-submit:hover {
    background: #0020c9;
}

.btn-submit:active {
    transform: scale(0.97);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   6. SIMPLE-KEYBOARD (Virtual Keyboard)
   ============================================ */
.simple-keyboard {
    /* Floating keyboard at the bottom of the screen */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none; /* hidden by default, shown on focus */
    background: #d4eaff;
    padding: 8px 4px 12px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    border-radius: 16px 16px 0 0;
    /* Ensure it spans full width but content is centered */
    max-width: 100%;
}

/* Overlay behind the keyboard to detect taps outside */
.simple-keyboard::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.2);
    z-index: -1;
    pointer-events: none;
}

.simple-keyboard .hg-button {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 16px;
    font-weight: 500;
    background: #FFFFFF;
    border: 1px solid #ccc;
    color: #070E46;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.simple-keyboard .hg-button:active {
    background: #e0e0e0;
    transform: scale(0.95);
}

.simple-keyboard .hg-row .hg-button-container {
    margin: 2px;
}

.simple-keyboard .hg-button.hg-functionBtn {
    background: #001391;
    color: #FFFFFF;
    border-color: #001391;
}

.simple-keyboard .hg-button.hg-functionBtn:active {
    background: #0020c9;
}

.simple-keyboard .hg-button.hg-button-space {
    font-size: 14px;
}

/* ============================================
   7. FOOTER
   ============================================ */
.footer {
    margin-top: auto;
    flex-shrink: 0;
}

.footer-logo {
    width: 120px;
    display: block;
    margin: 0 auto;
    padding-top: 40px;
    padding-bottom: 20px;
    height: auto;
}

/* Error Section */
.error-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: #FFFFFF;
    border-radius: 20px;
    border: 3px solid #070E46;
    animation: fadeInUp 0.3s ease;
    margin-top: 16px;
}

.error-text {
    font-size: 1.05rem;
    color: #d32f2f;
    text-align: center;
}

.btn-reset {
    min-height: 48px;
    padding: 12px 32px;
    background: transparent;
    color: #001391;
    border: 2px solid #001391;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-appearance: none;
    touch-action: manipulation;
}

.btn-reset:active {
    background: #001391;
    color: #fff;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Responsive adjustments
   ============================================ */
@media (max-height: 700px) {
    .phone-container {
        padding: 16px;
    }
    .title-section {
        margin-bottom: 24px;
    }
    .main-title {
        font-size: 34px;
    }
    .subtitle {
        font-size: 16px;
    }
    .input-textarea {
        min-height: 100px;
    }
    .footer-logo {
        padding-top: 24px;
        padding-bottom: 12px;
    }
}

@media (max-height: 500px) {
    .title-section {
        margin-bottom: 12px;
    }
    .main-title {
        font-size: 28px;
    }
    .subtitle {
        font-size: 14px;
    }
    .instruction-text {
        font-size: 14px;
    }
    .input-textarea {
        min-height: 80px;
    }
    .footer-logo {
        padding-top: 16px;
        padding-bottom: 8px;
        width: 80px;
    }
}
