/*=============================================
=            CONFIGURACIÓN GLOBAL             =
=============================================*/
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 60px;
}


/*=============================================
=            ELEMENTOS ENFOCADOS              =
=============================================*/
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}


/*=============================================
=         PLACEHOLDERS EN FORM FLOATING       =
=============================================*/
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}


/*=============================================
=            CONTENEDOR DEL CHAT              =
=============================================*/
.chat-container {
    font-family: 'Poppins', sans-serif;
    background-color: #f6f9fc;
    max-width: 1000px;
    margin: 2rem auto;
}

.chat-body {
    background-color: #f8f9fa;
    padding: 1rem;
    height: 60vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@supports (overflow-anchor: auto) {
    .chat-messages {
        overflow-anchor: auto;
    }
}


/*=============================================
=              INPUTS Y BOTONES               =
=============================================*/
.chat-input {
    border-radius: 12px;
    border: 1px solid #ced4da;
    padding: 0.75rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

    .chat-input:focus {
        border-color: var(--color-principal, #007bff);
        box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    }

.chat-form textarea:focus {
    box-shadow: none;
    border-color: #007bff;
}

.chat-form .btn {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

    .chat-form .btn:hover {
        transform: translateY(-2px);
    }

#btnCloseChat {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 9999;
}


/*=============================================
=             MENSAJES DEL CHAT               =
=============================================*/
.message {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInSlideUp 0.3s ease-out forwards;
}

@keyframes fadeInSlideUp {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-bubble {
    max-width: 75%;
    padding: 0.8rem 1.2rem;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

user-message .message-bubble {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message {
    align-self: flex-start;
}

    .ai-message .message-bubble {
        background-color: #e9ecef;
        color: #212529;
        border-bottom-left-radius: 0.25rem;
        border: 1px solid #e0e6f1;
    }

        .ai-message .message-bubble:empty {
            min-height: 2.5rem;
        }

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.message-content {
    white-space: pre-wrap;
    line-height: 1.4;
}

    .message-content a {
        color: #007bff;
        text-decoration: underline;
    }

        .message-content a:hover {
            color: #0056b3;
        }


/*=============================================
=         COMPONENTES COMPLEMENTARIOS         =
=============================================*/
.card-header {
    background-color: #003366;
    color: white;
}

#connectionStatus {
    font-size: 0.8rem;
    opacity: 0.8;
}


/*=============================================
=             SPINNERS Y EFECTOS              =
=============================================*/
.spinner-border {
    width: 1rem;
    height: 1rem;
}

.message-content .spinner-border {
    vertical-align: middle;
}

.btn-primary .spinner-border {
    color: white;
    border-color: white transparent white transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.blink-red {
    animation: blinkRed 1s infinite;
}

@keyframes blinkRed {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}


/*=============================================
=              SUGERENCIAS CHAT               =
=============================================*/
.sugerencias-chat .suggestion,
.suggestion {
    background-color: #e0e6f1;
    border-radius: 20px;
    padding: 6px 14px;
    display: inline-block;
    transition: background-color 0.2s;
    cursor: pointer;
}

    .sugerencias-chat .suggestion:hover,
    .suggestion:hover {
        background-color: #cbd7ec;
    }


/*=============================================
=                  DARK MODE                  =
=============================================*/
@media (prefers-color-scheme: dark) {
    .chat-container .card {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .chat-body {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 1rem;
        background-color: #f9f9f9;
    }

    .card-footer {
        flex-shrink: 0;
        padding: 1rem;
        background-color: #fff;
        border-top: 1px solid #ddd;
    }
}

/*=============================================
= Animación para que los metadatos aparezcan suavemente  =
=============================================*/
@media (prefers-color-scheme: dark) {

    .fade-in {
        animation: fadeIn 0.8s ease-in;
        opacity: 1;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* Ajuste para que el icono de CPU se vea alineado */
    .message-header small i {
        vertical-align: text-bottom;
    }
}