/* { box-sizing: border-box; } */

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #080810 100%); 
    padding: 0; 
    margin: 0;
    color: #f0f4f9; 
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh; /* Soporte moderno para pantallas móviles */
    width: 100vw;
    overflow: hidden;
}

/* Contenedor adaptado a Pantalla Completa Nativa */
.container { 
    background: rgba(26, 27, 30, 0.95); 
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px) 16px;
    border-radius: 0; /* Sin bordes redondeados extremos para ocupar toda la pantalla */
    text-align: center; 
    width: 100%;
    max-width: 600px; /* Límite estético para tablets o desktop */
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    border: none;
    box-shadow: none;
    position: relative; 
    box-sizing: border-box;
}

/* Header */
#status { 
    font-weight: 700; 
    font-size: 1.25em; 
    background: linear-gradient(90deg, #a8c7fa, #d3e3fd, #b06ab3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 10px;
    margin-bottom: 12px; 
    padding-right: 40px; 
    padding-left: 40px;
    text-align: center; 
    letter-spacing: -0.5px;
}

/* Botón Configuración */
.config-trigger { 
    position: absolute; 
    top: 15px; 
    right: 15px; 
    background: rgba(255, 255, 255, 0.05); 
    border: 1px solid rgba(255, 255, 255, 0.05); 
    color: #a8c7fa; 
    font-size: 16px; 
    cursor: pointer; 
    padding: 8px; 
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    z-index: 10;
}
.config-trigger:hover { 
    transform: rotate(60deg); 
    background: rgba(255, 255, 255, 0.15); 
    color: #fff;
    box-shadow: 0 0 12px rgba(168, 199, 250, 0.5);
}

/* Panel Configuración */
.config-panel { 
    display: none; 
    position: absolute; 
    top: 60px; 
    right: 15px; 
    background: #1e1f22; 
    border: 1px solid rgba(176, 106, 179, 0.2); 
    border-radius: 16px; 
    padding: 12px; 
    width: 260px; 
    text-align: left; 
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 15px rgba(176, 106, 179, 0.15); 
    animation: fadeIn 0.2s ease-out;
    z-index: 100;
}
.config-panel.show { display: block; }

/* Botón interno */
.btn-toggle { 
    width: 100%; 
    padding: 12px; 
    font-weight: 600; 
    cursor: pointer; 
    background: rgba(255, 255, 255, 0.05); 
    color: #c4c7c5; 
    border: 1px solid rgba(255, 255, 255, 0.05); 
    border-radius: 12px; 
    font-size: 12px; 
    text-transform: uppercase; 
    transition: all 0.2s ease; 
}
.btn-toggle.active { 
    background: linear-gradient(135deg, #b06ab3, #4a3b5c); 
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(176, 106, 179, 0.3); 
}

/* Historial */
#messages { 
    flex: 1; 
    overflow-y: auto; 
    margin: 4px 0 16px 0; 
    padding: 12px; 
    background: rgba(0, 0, 0, 0.25); 
    border-radius: 20px; 
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Scroll */
#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); }

/* Input */
.text-input-container {
    display: none;
    gap: 10px;
    margin-bottom: 12px;
    width: 100%;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.text-input-container.show { display: flex; }

#text-message-input {
    flex: 1;
    padding: 14px 18px;
    background: #1e1f22;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    color: #f0f4f9;
    font-size: 15px;
    outline: none;
}
#send-text-btn {
    padding: 0 20px;
    background: #a8c7fa;
    color: #042f62;
    border-radius: 24px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

/* Botón principal */
#main-btn { 
    padding: 18px; 
    font-size: 1em; 
    cursor: pointer; 
    background: linear-gradient(135deg, #004a77 0%, #002244 100%); 
    color: #c2e7ff; 
    border: 1px solid rgba(168, 199, 250, 0.2); 
    border-radius: 24px; 
    width: 100%; 
    font-weight: 600; 
    box-shadow: 0 8px 24px rgba(0,0,0,0.3); 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    margin-bottom: env(safe-area-inset-bottom, 0px);
}
#main-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #005c99 0%, #003366 100%);
    box-shadow: 0 12px 28px rgba(0, 74, 119, 0.4), 0 0 15px rgba(168, 199, 250, 0.2);
    transform: translateY(-2px);
}

/* Burbujas */
.msg { 
    text-align: left; 
    padding: 12px 16px; 
    border-radius: 16px; 
    background: rgba(255, 255, 255, 0.04); 
    font-size: 0.95em; 
    max-width: 85%; 
    align-self: flex-start; 
    line-height: 1.5; 
    border: 1px solid rgba(255, 255, 255, 0.03);
    animation: fadeIn 0.3s ease-out;
}

.msg.interprete { 
    background: linear-gradient(135deg, rgba(74, 59, 92, 0.5), rgba(41, 30, 54, 0.6)); 
    border: 1px solid rgba(176, 106, 179, 0.4); 
    align-self: center; 
    width: 100%; 
    cursor: pointer; 
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-listen {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #a8c7fa;
    cursor: pointer;
    border-radius: 50%;
    width: 28px;
    height: 28px;
}

.translation { 
    font-weight: 600; 
    color: #a8c7fa; 
    margin-top: 6px; 
    display: block; 
    font-size: 1.05em;
}

.translation.copied { 
    color: #34a853 !important; 
    transform: scale(1.02); 
}

/* Modal de Idioma */
#modal-idioma {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#modal-idioma .modal-content {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    width: 90%;
    max-width: 350px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#modal-idioma h2 {
    color: #ffffff;
    margin-bottom: 20px;
    font-size: 22px;
    letter-spacing: 0.5px;
}

#modal-idioma select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #2c2c2c;
    color: #ffffff;
    margin-bottom: 20px;
    outline: none;
}

#modal-idioma button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    background: linear-gradient(135deg, #34a853 0%, #137333 100%);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.2s;
}

#modal-idioma button:hover {
    opacity: 0.9;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Estilos para el Código QR en Panel de Configuración --- */
.qr-container {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.qr-image {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid rgba(168, 199, 250, 0.2);
    background: #ffffff;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease;
}

.qr-image:hover {
    transform: scale(1.03);
}

.qr-label {
    font-size: 0.68em;
    color: #a8c7fa;
    margin-top: 6px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-weight: 600;
}