/* Global styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    max-width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* Evita scroll doble */
}

/* Header */
.app-header {
    padding: 1rem;
    background-color: #0066cc;
    color: white;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 1.2rem;
    margin: 0;
}

.privacy-link {
    margin-top: 0.5rem;
}

.privacy-link a {
    color: #fff;
    text-decoration: underline;
    font-size: 0.9rem;
}

/* Chat container */
.chat-container {
    flex: 1 1 auto;
    overflow-y: auto;
    background: #fafbfc;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Permite que flexbox calcule bien el espacio */
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100%;
    width: 100%;
    flex-grow: 1;
    padding: 1.2em 1.5em 1.2em 1.5em; /* padding superior, derecho, inferior, izquierdo */
    box-sizing: border-box;
}

/* Message styles */
.message {
    max-width: 85%;
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

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

.assistant {
    align-self: flex-start;
    background-color: #f0f0f0;
    border-bottom-left-radius: 0.25rem;
}

.user {
    align-self: flex-end;
    background-color: #0066cc;
    color: white;
    border-bottom-right-radius: 0.25rem;
    text-align: right;
}

.system {
    align-self: center;
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    color: #666;
    font-style: italic;
    padding: 0.5rem 1rem;
    text-align: center;
    max-width: 90%;
}

.urgent {
    background-color: #ff4b4b;
    color: white;
    font-weight: bold;
}

/* Input container */
.input-container {
    padding: 0 1rem 0 1rem; /* Solo padding horizontal */
    border-top: 1px solid #eee;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom, 0); /* Espacio dinámico para barras inferiores */
}

.action-container {
    height: 120px;
    min-height: 120px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.user-input {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 1.5rem;
    outline: none;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.user-input:focus {
    border-color: #0066cc;
}

.send-button {
    padding: 0.8rem 1.2rem;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 1.5rem;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

.send-button:hover {
    background-color: #0052a3;
}

.send-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Option buttons */
.options-container {
    width: 100%;
    display: flex;
    flex-direction: row; /* Siempre en fila, también en móvil */
    flex-wrap: wrap;     /* Permite que bajen si no caben */
    justify-content: center;
    align-items: center;
    gap: 1em;
    transition: opacity 0.2s;
    visibility: visible;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
}

.options-container[style*="display: none"] {
    display: flex !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0.1 !important;
}

.option-button {
    padding: 0.8rem;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.3s, transform 0.1s;
}

.option-button:hover {
    background-color: #e6e6e6;
    transform: translateY(-1px);
}

.option-button:active {
    transform: translateY(1px);
}

/* Restart button */
.restart-button {
    display: block;
    width: 60%; /* Más angosto para mejor centrado visual */
    margin: 0 auto;
    padding: 0.8rem;
    margin-top: 0.5rem;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: bold;
    text-align: center;
}

.restart-button:hover {
    background-color: #218838;
}

/* Start button - new styles */
.start-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 0;
    height: 100%;
    box-sizing: border-box;
}

.start-button.blue-centered {
    background-color: #1976d2; /* mismo azul que la barra de título */
    color: #fff;
    border: none;
    border-radius: 25px;
    padding: 0.9em 2.5em;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.15);
    transition: background 0.2s, transform 0.1s;
}

.start-button.blue-centered:hover,
.start-button.blue-centered:focus {
    background-color: #1565c0;
    transform: translateY(-2px) scale(1.04);
}

/* Spacer for mobile navigation */
#bottom-spacer {
    width: 100%;
    height: env(safe-area-inset-bottom, 0);
    /* height: 12dvh; Altura fija para navegadores móviles */

}

@media (max-width: 600px) {
    #bottom-spacer {
        min-height: 80px; /* Garantiza espacio mínimo en móviles */
    }
}

/* Responsive design for tablet and desktop */
@media (min-width: 768px) {
    .app-header h1 {
        font-size: 1.5rem;
    }
    /* Ya no es necesario cambiar flex-direction aquí */
    .option-button {
        flex: 1 0 45%;
    }
}

@media (min-width: 1024px) {
    .message {
        max-width: 70%;
    }
    
    .app-header h1 {
        font-size: 1.8rem;
    }
}