@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

.main-container {
    font-family: 'Poppins', sans-serif;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-dark: #000000;
    --secondary-dark: #031227;
    --accent-blue: #2449742f;
    --bright-blue: #3e8feb;
    --light-blue: #ccd6f6;
    --white: #e6f1ff;
    --gray: #8892b0;
}

.main-container {
    display: none;
    width: 850px;
    max-width: 95vw;
    height: 550px;
    max-height: 90vh;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
    border: 1px solid rgba(62, 143, 235, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: fadeInCentered 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-container.active {
    display: flex;
}

@keyframes fadeInCentered {
    from {
        opacity: 0;
        transform: translate(-50%, -48%) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.widget-bubble {
    font-family: 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', sans-serif;
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--bright-blue);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(62, 143, 235, 0.4);
    transition: all 0.3s ease;
}

.main-container .widget-bubble:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 20px rgba(62, 143, 235, 0.6);
}

.main-container .close-widget {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--white);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10001;
    transition: background 0.2s ease;
}

.main-container .close-widget:hover {
    background: rgba(255, 255, 255, 0.2);
}

.main-container .close-widget .material-symbols-outlined {
    font-size: 24px;
}

.main-container .material-symbols-outlined {
    font-size: 24px;
    color: var(--white);
}

.main-container .content-info {
    background-color: transparent;
    width: 45%;
    height: 100%;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 1rem;
    gap: 1.5rem;
    overflow-y: auto;
}

#n8n-chat {
    width: 55%;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(62, 143, 235, 0.2);
    min-height: 0; /* FIX: permite que el body haga scroll correctamente en flex */
}

.main-container .content-info-title {
    text-align: center;
    max-width: 800px;
    padding: 0 1rem;
    margin: 0;
}

.main-container .content-info-title h2 {
    font-size: 1.5rem;
    color: #ccd6f6;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(62, 143, 235, 0.3);
}

.main-container .content-info-title p {
    color: var(--gray);
    line-height: 1.4;
    font-size: 0.85rem;
}

.main-container .content-info-cards {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
    max-width: 1200px;
    padding: 0 1rem;
    margin: 0 auto;
}

.main-container .card {
    background: rgba(3, 18, 39, 0.6);
    border: 1px solid rgba(62, 143, 235, 0.2);
    border-radius: 0.8rem;
    padding: 0.6rem 1.2rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-align: left;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-height: 50px;
    cursor: pointer;
    gap: 1rem;
}

.main-container .card:hover {
    transform: translateX(5px);
    border-color: var(--bright-blue);
    box-shadow: 0 5px 15px rgba(62, 143, 235, 0.15);
    background: rgba(3, 18, 39, 0.8);
}

.main-container .card .material-symbols-outlined {
    font-size: 1.4rem;
    color: var(--bright-blue);
    margin-bottom: 0;
    display: block;
}

.main-container .card h2 {
    color: #e6f1ff;
    font-size: 0.9rem;
    margin: 0;
    font-weight: 400;
    line-height: 1.3;
}

.main-container .card p {
    color: var(--gray);
    line-height: 1.4;
    font-size: 0.95rem;
    margin: 0;
}

.main-container .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(62, 143, 235, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.main-container .card:hover::before {
    opacity: 1;
}

.main-container .chat-powered-by {
    display: none;
}

.main-container span {
    color: #3e8feb;
}

.main-container .gmail-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 0.6rem;
    object-fit: contain;
}

.main-container .whatsapp-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 0.6rem;
    object-fit: contain;
}

@media (max-width: 1200px) {
    .main-container .content-info {
        justify-content: center;
        padding: 1rem;
    }

    .main-container .content-info-cards {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.8rem;
        max-width: 1000px;
    }
}

@media (max-width: 992px) {
    .main-container .content-info {
        justify-content: center;
        padding: 1rem;
    }

    .main-container .content-info-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        max-width: 800px;
    }
}

@media (max-width: 768px) {

    /* FIX: antes estaba como .main-container .main-container (no aplicaba) */
    .main-container {
        flex-direction: column;
        height: 100dvh;       /* FIX: alto real en móviles */
        max-height: 100dvh;
        width: 100%;
        max-width: 100%;
        top: 0;
        left: 0;
        transform: none;      /* FIX: en móvil no lo centres con translate */
        border-radius: 0;
        display: none;        /* se mantiene tu lógica: solo muestra con .active */
        min-height: 0;        /* FIX: clave en flex */
    }

    .main-container.active {
        display: flex;
    }

    .main-container .content-info {
        display: none;
    }

    #n8n-chat {
        width: 100%;
        height: 100%;
        border-left: none;
        min-height: 0;        /* FIX: clave en flex */
    }

    /* FIX: el main del chat debe ser un flex column con alto 100% */
    .main-container .chat-layout {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;        /* FIX: clave para que .chat-body no se desborde */
        border-radius: 0 !important;
    }

    /* Header y footer no crecen */
    .main-container .chat-header,
    .main-container .chat-footer {
        flex: 0 0 auto;
    }

    /* Body ocupa el resto y hace scroll */
    .main-container .chat-body {
        flex: 1 1 auto;
        min-height: 0;        /* FIX: el más importante */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {

    /* FIX: antes estaba como .main-container .main-container (no aplicaba) */
    .main-container {
        flex-direction: column;
        height: 100dvh;
        max-height: 100dvh;
        width: 100%;
        max-width: 100%;
        top: 0;
        left: 0;
        transform: none;
        border-radius: 0;
        display: none;
        min-height: 0;
    }

    .main-container.active {
        display: flex;
    }

    .main-container .content-info {
        display: none;
    }

    #n8n-chat {
        width: 100%;
        height: 100%;
        border-left: none;
        min-height: 0;
    }

    .main-container .card {
        padding: 0.8rem;
        min-height: 90px;
    }

    .main-container .card .material-symbols-outlined {
        font-size: 1.5rem;
    }

    .main-container .card h2 {
        font-size: 0.85rem;
    }

    .main-container .gmail-icon {
        width: 32px;
        height: 32px;
    }

    /* Reitero el layout del chat en 480 por si este breakpoint pisa cosas */
    .main-container .chat-layout {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        border-radius: 0 !important;
    }

    .main-container .chat-header,
    .main-container .chat-footer {
        flex: 0 0 auto;
    }

    .main-container .chat-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

#n8n-chat {
    border-radius: 10px !important;
}

.main-container .chat-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 10px !important;
    min-height: 0; /* FIX: importante */
}

.main-container .chat-header {
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(10px);
}

.main-container .chat-heading h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(100, 255, 218, 0.3);
}

.main-container .chat-header p {
    margin: 0.5rem 0 0;
    color: var(--gray);
    font-size: 0.9rem;
}

.main-container .chat-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) var(--secondary-dark);
    min-height: 0; /* FIX: importante */
}

.main-container .chat-body::-webkit-scrollbar {
    width: 8px;
}

.main-container .chat-body::-webkit-scrollbar-track {
    background: var(--secondary-dark);
    border-radius: 10px;
}

.chat-body::-webkit-scrollbar-thumb {
    background-color: var(--accent-blue);
    border-radius: 10px;
}

.chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    max-width: 80%;
    padding: 1rem 1.2rem;
    border-radius: 1rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.chat-message a {
    color: var(--bright-blue);
    text-decoration: underline;
    word-break: break-all;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-from-bot {
    align-self: flex-start;
    background: rgb(3 8 16 / 80%);
    border: 2px solid rgba(1, 170, 248, 0.1);
    border-left: 4px solid var(--bright-blue);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chat-message-from-user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(10, 26, 45, 0.199) 0%, rgba(100, 198, 255, 0.274) 100%);
    border: 1px solid rgba(0, 185, 247, 0.938);
    color: var(--light-blue);
}

.chat-message-markdown p {
    margin: 0;
    font-size: 1rem;
}

.chat-footer {
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.chat-input {
    position: relative;
}

.chat-inputs {
    display: flex;
    align-items: center;
    background: rgb(6 10 23 / 58%);
    border-radius: 1rem;
    border: 1px solid rgb(4, 92, 255);
    transition: all 0.3s ease;
}

.chat-inputs:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(102, 159, 245, 0.548);
}

.chat-inputs textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--white);
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    resize: none;
    outline: none;
    min-height: 20px;
    max-height: 120px;
    line-height: 1.5;
}

.chat-inputs textarea::placeholder {
    color: var(--gray);
    opacity: 0.7;
}

.chat-inputs-controls {
    padding-right: 0.5rem;
}

.chat-input-send-button {
    background: transparent;
    border: none;
    color: var(--gray);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-send-button:not([disabled]) {
    color: var(--accent-blue);
}

.chat-input-send-button:not([disabled]):hover {
    background: rgba(100, 255, 218, 0.1);
    transform: scale(1.1);
}

.chat-input-send-button svg {
    width: 24px;
    height: 24px;
}

/* Efectos de hover para los mensajes */
.chat-message-from-bot:hover {
    transform: translateX(5px);
    transition: transform 0.2s ease;
}

.chat-message-from-user:hover {
    transform: translateX(-5px);
    transition: transform 0.2s ease;
}

/* Efecto de brillo para los bordes */
.chat-message-from-bot::after {
    content: '';
    position: absolute;
    top: 0;
    left: -4px;
    height: 100%;
    width: 4px;
    background: var(--bright-blue);
    border-radius: 4px 0 0 4px;
    box-shadow: 0 0 10px var(--bright-blue);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.chat-message-from-bot:hover::after {
    opacity: 0.7;
}

.chat-message-from-user:hover::after {
    opacity: 0.7;
}

.chat-message-markdown p {
    color: white !important;
}

button#widget-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    color: white;
    background: #1382df;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}