/* Estilos para el Chat - Línea Gráfica Magistral 2025 */

/* Importar fuentes */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Montserrat:wght@700;800;900&display=swap');

/* Variables de colores de marca */
:root {
    --brand-burgundy: #8b0e2b;
    --brand-red: #c42f3d; /* Rojo menos brillante */
    --brand-red-dark: #a02632;
    --brand-dark: #0f0f14;
    --brand-dark-2: #17171d;
    --brand-dark-3: #1e1e26;
    --chat-bg: #211d1d; /* Fondo del área de mensajes */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-muted: rgba(255, 255, 255, 0.6);
    --border-color: rgba(196, 47, 61, 0.2); /* Borde rojo sutil */
    --input-bg: rgba(255, 255, 255, 0.05);
    --card-bg: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand-dark-2) 100%);
}

/* Configuración general */
* {
    box-sizing: border-box;
}

body {
    background: var(--brand-dark);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
}

/* Scroll personalizado */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--brand-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--brand-red);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #c41e3a;
}

/* Contenedor principal */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    max-width: 800px;
    height: auto;
    padding: 20px 16px;
}

/* Tarjetas (Registro, Login, Bienvenida) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

/* Secciones de formularios */
#register-section,
#login-section {
    width: 100%;
    max-width: 500px;
    padding: 28px;
}

#register-section h5,
#login-section h5 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

/* Labels */
.form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

/* Inputs */
.form-control {
    background: var(--input-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--brand-red);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(224, 30, 55, 0.1);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Botones principales */
.btn {
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 10px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.btn-primary {
    background: var(--brand-red);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(224, 30, 55, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-red-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(196, 47, 61, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: rgba(196, 47, 61, 0.3);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Botones outline */
.btn-outline-primary {
    background: transparent;
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}

.btn-outline-primary:hover {
    background: var(--input-bg);
    border-color: var(--brand-red);
    color: var(--text-primary);
}

/* Texto muted */
.text-muted {
    color: var(--text-muted) !important;
    font-size: 0.9rem;
}

/* Sección de bienvenida */
#welcome-section {
    width: 100%;
    max-width: 100%;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px;
    margin-bottom: 16px;
}

#welcome-section h5 {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    word-wrap: break-word;
    line-height: 1.5;
    margin: 0;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--brand-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
}

/* Sección de chat */
#chat-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* Botón de asistencia */
#assistance-container {
    margin-bottom: 16px;
}

#assistButton {
    background: var(--brand-red);
    color: white;
    font-weight: 600;
    padding: 12px;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(224, 30, 55, 0.3);
}

#assistButton:hover {
    background: var(--brand-red-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(196, 47, 61, 0.4);
}

#assist-timer {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 8px;
}

/* Área de mensajes - CON FONDO #211d1d */
#messages {
    width: 100%;
    height: 70vh;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--chat-bg); /* #211d1d */
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Contenedor del input */
#input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

/* Input de mensaje */
#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.95rem;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

/* Botón de enviar */
#sendMessage {
    padding: 12px;
    font-size: 0.95rem;
    min-width: 100px;
    font-weight: 600;
}

/* Contador de caracteres */
#charCounter {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 4px;
}

/* Countdown */
#countdown {
    color: var(--text-secondary) !important;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    margin-top: 8px;
}

/* Estilos para los mensajes propios */
.my-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px 12px 4px 12px;
    max-width: 75%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(196, 47, 61, 0.3);
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Estilos para los mensajes de otros usuarios */
.other-message {
    align-self: flex-start;
    background: var(--brand-dark-3);
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: 12px 12px 12px 4px;
    max-width: 75%;
    word-wrap: break-word;
    border: 1px solid var(--border-color);
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Mensaje de advertencia */
.warning-message {
    align-self: center;
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    text-align: center;
    font-weight: 600;
    padding: 12px 16px;
    border-radius: 10px;
    width: 100%;
    max-width: 90%;
    border: 1px solid rgba(255, 193, 7, 0.3);
    font-size: 0.9rem;
}

/* Ajuste del área de mensajes */
#messages div {
    margin-bottom: 4px;
}

/* Animación de entrada para mensajes */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.my-message,
.other-message {
    animation: messageSlideIn 0.3s ease;
}

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

/* Tablets */
@media (max-width: 768px) {
    .container {
        padding: 16px 12px;
    }

    #register-section,
    #login-section {
        max-width: 100%;
        padding: 24px;
    }

    #register-section h5,
    #login-section h5 {
        font-size: 1.2rem;
    }

    .form-label {
        font-size: 0.85rem;
    }

    .form-control {
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    .btn {
        font-size: 0.9rem;
        padding: 10px 16px;
    }

    #messages {
        height: 60vh;
        max-height: 60vh;
        padding: 12px;
        font-size: 0.9rem;
    }

    .my-message,
    .other-message {
        font-size: 0.9rem;
        padding: 10px 14px;
        max-width: 80%;
    }

    #welcome-section h5 {
        font-size: 0.95rem;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .container {
        padding: 12px 8px;
    }

    #register-section,
    #login-section {
        padding: 20px;
    }

    #register-section h5,
    #login-section h5 {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    .form-label {
        font-size: 0.8rem;
    }

    .form-control {
        font-size: 0.85rem;
        padding: 10px 12px;
    }

    .btn {
        font-size: 0.85rem;
        padding: 10px 14px;
    }

    #messages {
        height: 55vh;
        max-height: 55vh;
        padding: 12px;
    }

    .my-message,
    .other-message {
        font-size: 0.85rem;
        padding: 10px 12px;
        max-width: 85%;
    }

    #welcome-section {
        padding: 16px;
    }

    #welcome-section h5 {
        font-size: 0.9rem;
    }

    #sendMessage {
        font-size: 0.85rem;
        padding: 10px;
    }

    #charCounter {
        font-size: 0.8rem;
    }
}

/* Modo horizontal en dispositivos móviles */
@media (min-width: 360px) and (max-width: 896px) and (orientation: landscape) {
    #chat-section {
        width: 100%;
        height: 100%;
    }

    #messages {
        height: 60vh;
        max-height: 60vh;
    }

    /* iPhone SE (667x375) */
    @media (max-height: 375px) {
        #messages {
            height: 50vh;
            max-height: 50vh;
        }
    }

    /* Samsung Galaxy S8 (360x740) */
    @media (max-width: 360px) {
        #messages {
            height: 50vh;
            max-height: 50vh;
        }
    }

    /* Surface Duo (720x540) */
    @media (max-height: 540px) {
        #messages {
            height: 55vh;
            max-height: 55vh;
        }
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 360px) {
    .container {
        padding: 10px 6px;
    }

    #register-section,
    #login-section {
        padding: 16px;
    }

    .my-message,
    .other-message {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}
