#portfolio-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1200;
    font-family: var(--fuente-secundaria), sans-serif;
}

.chat-widget__toggle {
    width: 70px;
    height: 70px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #073d8a 0%, #d21828 100%);
    color: #fff;
    box-shadow: 0 18px 40px rgba(6, 18, 44, 0.34);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-widget__toggle:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 24px 48px rgba(6, 18, 44, 0.42);
}

.chat-widget__toggle-badge {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.14);
    font-size: 1.3rem;
    font-weight: 700;
}

.chat-widget__panel {
    position: absolute;
    right: 0;
    bottom: 88px;
    width: min(390px, calc(100vw - 28px));
    height: min(620px, calc(100vh - 120px));
    border-radius: 26px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.15), transparent 30%),
        linear-gradient(180deg, rgba(8, 23, 51, 0.98) 0%, rgba(15, 20, 35, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.38);
    color: #eef3fb;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.97);
    transition: opacity 0.24s ease, transform 0.24s ease;
}

#portfolio-chat-widget.is-open .chat-widget__panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.chat-widget__header {
    padding: 18px 18px 16px;
    background: linear-gradient(135deg, rgba(7, 61, 138, 0.96), rgba(210, 24, 40, 0.92));
}

.chat-widget__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-widget__identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.22);
    font-family: var(--fuente-principal), sans-serif;
    font-weight: 700;
}

.chat-widget__headline {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.chat-widget__subhead {
    margin: 2px 0 0;
    font-size: 0.85rem;
    opacity: 0.9;
}

.chat-widget__close {
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
}

.chat-widget__body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.chat-widget__quick-actions {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 14px 16px 4px;
    scrollbar-width: thin;
}

.chat-widget__chip {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.07);
    color: #f4f8ff;
    border-radius: 999px;
    padding: 10px 14px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.88rem;
}

.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget__message {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 18px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.chat-widget__message--assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.09);
    border-top-left-radius: 8px;
}

.chat-widget__message--user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(7, 61, 138, 0.95), rgba(210, 24, 40, 0.92));
    color: #fff;
    border-top-right-radius: 8px;
}

.chat-widget__message-meta {
    display: block;
    margin-top: 7px;
    font-size: 0.72rem;
    opacity: 0.72;
}

.chat-widget__typing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chat-widget__typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    opacity: 0.75;
    animation: chatPulse 1s infinite ease-in-out;
}

.chat-widget__typing-dot:nth-child(2) {
    animation-delay: 0.12s;
}

.chat-widget__typing-dot:nth-child(3) {
    animation-delay: 0.24s;
}

@keyframes chatPulse {
    0%, 80%, 100% {
        transform: scale(0.82);
        opacity: 0.35;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-widget__footer {
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(3, 8, 20, 0.42);
    backdrop-filter: blur(10px);
}

.chat-widget__privacy {
    margin: 0 0 10px;
    color: rgba(230, 238, 250, 0.76);
    font-size: 0.76rem;
}

.chat-widget__form {
    display: flex;
    gap: 10px;
}

.chat-widget__input {
    flex: 1;
    min-width: 0;
    resize: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    border-radius: 16px;
    padding: 12px 14px;
    min-height: 48px;
    max-height: 130px;
    box-sizing: border-box;
    font-family: inherit;
}

.chat-widget__input::placeholder {
    color: rgba(234, 241, 251, 0.62);
}

.chat-widget__submit {
    border: none;
    min-width: 54px;
    border-radius: 16px;
    background: linear-gradient(135deg, #f39c12 0%, #d21828 100%);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    padding: 0 16px;
}

.chat-widget__submit[disabled],
.chat-widget__chip[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-widget__helper-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    color: #ffd7da;
    font-size: 0.82rem;
    text-decoration: none;
}

@media (max-width: 768px) {
    #portfolio-chat-widget {
        right: 12px;
        left: 12px;
        bottom: 12px;
    }

    .chat-widget__toggle {
        margin-left: auto;
        width: 64px;
        height: 64px;
    }

    .chat-widget__panel {
        width: 100%;
        right: 0;
        left: 0;
        bottom: 78px;
        height: min(72vh, 620px);
    }
}
