/* Viaweb Assistant — Frontend Chat Styles */

:root {
    --vwa-primary: #1B3A5C;
    --vwa-secondary: #3D8B7A;
    --vwa-accent: #E8892F;
    --vwa-bot-bubble: #F0EDE8;
    --vwa-user-bubble: #1B3A5C;
    --vwa-bot-text: #2D3748;
    --vwa-user-text: #FFFFFF;
    --vwa-background: #FAF8F5;
    --vwa-header-bg: #1B3A5C;
    --vwa-header-text: #FFFFFF;
    --vwa-font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --vwa-chat-height: 600px;
    --vwa-bubble-size: 60px;
    --vwa-bubble-color: #1B3A5C;
    --vwa-send-color: #E8892F;
    --vwa-window-width: 380px;
    --vwa-window-height: 550px;
    --vwa-bottom-distance: 0px;
}

.vwa-app,
.vwa-app *,
.vwa-app *::before,
.vwa-app *::after {
    box-sizing: border-box;
}

.vwa-app {
    font-family: var(--vwa-font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────
   SHARED: messages, bubbles, typing, sources, chips, input
   ───────────────────────────────────────────── */

.vwa-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.vwa-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(144, 152, 170, 0.6) rgba(144, 152, 170, 0.12);
}

.vwa-messages::-webkit-scrollbar {
    width: 8px;
}

.vwa-messages::-webkit-scrollbar-track {
    background: rgba(144, 152, 170, 0.12);
    border-radius: 4px;
}

.vwa-messages::-webkit-scrollbar-thumb {
    background: rgba(144, 152, 170, 0.6);
    border-radius: 4px;
}

.vwa-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(144, 152, 170, 0.85);
}

.vwa-message {
    display: flex;
    gap: 10px;
    max-width: 82%;
    animation: vwaSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.vwa-message-bot {
    align-self: flex-start;
}

.vwa-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.vwa-message-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-top: 2px;
}

.vwa-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: white;
    box-shadow: 0 1px 4px rgba(28, 34, 69, 0.10);
}

.vwa-message-user .vwa-message-avatar {
    display: none;
}

.vwa-message-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.vwa-message-user .vwa-message-content {
    align-items: flex-end;
}

.vwa-message-bubble {
    padding: 11px 16px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.vwa-message-bot .vwa-message-bubble {
    background: linear-gradient(90deg, transparent 60%, rgba(0, 0, 0, 0.25) 100%), var(--vwa-bot-bubble);
    color: var(--vwa-bot-text);
    border-top-left-radius: 4px;
    box-shadow: 0px 0px 5px color-mix(in srgb, var(--vwa-bot-bubble) 40%, transparent);
}

.vwa-message-user .vwa-message-bubble {
    background: linear-gradient(90deg, transparent 60%, rgba(0, 0, 0, 0.25) 100%), var(--vwa-user-bubble);
    color: var(--vwa-user-text);
    border-top-right-radius: 4px;
    box-shadow: 0px 0px 5px color-mix(in srgb, var(--vwa-user-bubble) 40%, transparent);
}

.vwa-message-bubble strong {
    font-weight: 700;
}

.vwa-message-bubble em {
    font-style: italic;
}

.vwa-message-bubble a {
    color: var(--vwa-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.vwa-error .vwa-message-bubble {
    background: #FEF2F2 !important;
    color: #991B1B !important;
    border: 1px solid #FECACA;
    box-shadow: none !important;
}

/* Typing */
.vwa-typing {
    display: flex;
    gap: 10px;
    align-self: flex-start;
    max-width: 82%;
    animation: vwaSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.vwa-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: var(--vwa-bot-bubble);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.vwa-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9098aa;
    animation: vwaTyping 1.4s ease-in-out infinite;
}

.vwa-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.vwa-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

/* Sources */
.vwa-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-self: flex-start;
    padding-left: 38px;
    margin-top: -6px;
}

.vwa-source-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: rgba(28, 34, 69, 0.04);
    border: 1px solid rgba(28, 34, 69, 0.10);
    border-radius: 8px;
    font-size: 10px;
    color: #6f7689;
    font-weight: 500;
}

.vwa-source-pill i {
    font-size: 9px;
    color: var(--vwa-accent);
}

/* Smart action */
.vwa-smart-action {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: -4px;
    padding: 10px 18px;
    background: var(--vwa-accent);
    color: #fff;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(232, 137, 47, 0.28);
    transition: transform 0.2s, box-shadow 0.2s;
}

.vwa-smart-action:hover {
    transform: translateY(-2px);
    color: #fff;
}

/* Suggestions / chips */
.vwa-suggestions {
    text-align: center;
}

.vwa-suggestions-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 10px 0;
}

.vwa-suggestions-label::before,
.vwa-suggestions-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #9098aa;
}

.vwa-suggestions-label span {
    font-size: 11px;
    font-weight: 600;
    color: #c7c7c7;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.vwa-suggestions-list {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.vwa-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--vwa-background);
    border: 1.5px solid rgba(28, 34, 69, 0.10);
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--vwa-bot-text);
    font-family: inherit;
    line-height: 1.3;
    text-align: left;
    transition: all 0.2s ease;
}

.vwa-chip:hover {
    box-shadow: 0 1px 3px var(--vwa-bot-text);
    transform: translateY(-1.5px);
}

.vwa-chip-icon {
    color: var(--vwa-accent);
    flex-shrink: 0;
}

/* Input area */
.vwa-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e9e9e9;
    border-radius: 30px;
    padding: 3px 3px 3px 15px;
    border: 1px solid rgba(28, 34, 69, 0.12);
    transition: border-color 0.25s, box-shadow 0.25s;
    box-shadow: 0 2px 10px rgba(28, 34, 69, 0.04);
}

.vwa-input-wrapper:focus-within {
    border-color: rgba(232, 137, 47, 0.5);
    box-shadow: 0 1px 5px var(--vwa-send-color);
}

.vwa-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    resize: none;
    outline: none;
    padding: 0px 0;
    max-height: 40px;
    font-family: inherit;
    color: #1c2245;
	min-height: 20px;
}

.vwa-input::placeholder {
    color: #9098aa;
}

.vwa-send-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    background: var(--vwa-send-color);
    color: #fff;
    border-radius: 999px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(232, 137, 47, 0.3);
}

.vwa-send-btn:hover:not(:disabled) {
    filter: brightness(0.94);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(232, 137, 47, 0.4);
}

.vwa-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.vwa-disclaimer {
    font-size: 11px;
    color: #a9afbc;
    text-align: center;
    margin: 10px 0 0 0;
    line-height: 1.4;
}

/* ─────────────────────────────────────────────
   FULLSCREEN MODE
   ───────────────────────────────────────────── */

.vwa-mode-fullscreen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    background: var(--vwa-background);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    isolation: isolate;
}

.admin-bar .vwa-mode-fullscreen {
    top: 32px;
    height: calc(100vh - 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar .vwa-mode-fullscreen {
        top: 46px;
        height: calc(100vh - 46px);
    }
}

.vwa-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 40px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(28, 34, 69, 0.08);
    background: var(--vwa-background);
}

.vwa-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.vwa-logo {
    height: 34px;
    width: auto;
    object-fit: contain;
}

.vwa-site-name {
    font-size: 15px;
    font-weight: 800;
    color: var(--vwa-primary);
    letter-spacing: -0.3px;
}

.vwa-brand-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 7px;
    background: rgba(34, 197, 94, 0.08);
    border-radius: 20px;
    font-size: 11px;
    color: #16a34a;
    font-weight: 500;
}

.vwa-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
    animation: vwaPulse 2s ease-in-out infinite;
}

.vwa-newchat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: transparent;
    border: 1.5px solid rgba(28, 34, 69, 0.12);
    border-radius: 999px;
    color: #6f7689;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

.vwa-mode-fullscreen.vwa-has-messages .vwa-newchat {
    opacity: 1;
    pointer-events: auto;
}

.vwa-newchat:hover {
    background: var(--vwa-primary);
    border-color: var(--vwa-primary);
    color: #fff;
}

.vwa-mode-fullscreen .vwa-messages {
    padding: 24px 40px;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
}

.vwa-mode-fullscreen .vwa-bottom {
    flex-shrink: 0;
    padding: 0 40px 24px;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
}

.vwa-mode-fullscreen .vwa-suggestions {
    margin-bottom: 14px;
}

/* Welcome */
.vwa-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 20px;
    gap: 8px;
    position: relative;
    animation: vwaWelcome 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.vwa-mode-fullscreen.vwa-has-messages .vwa-welcome {
    display: none;
}

.vwa-welcome-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(232, 137, 47, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.vwa-welcome-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    position: relative;
    z-index: 1;
}

.vwa-welcome-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 8px 24px rgba(28, 34, 69, 0.08);
}

.vwa-avatar-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--vwa-accent);
    opacity: 0.4;
}

.vwa-welcome-title {
    font-size: 28px;
    font-weight: 500;
    color: #1c2245;
    margin: 10px 0 0 0;
    line-height: 1.25;
    letter-spacing: -0.5px;
    z-index: 1;
}

.vwa-welcome-title strong {
    font-weight: 800;
    color: var(--vwa-primary);
}

.vwa-welcome-subtitle {
    font-size: 14px;
    color: #373a43;
    margin: 4px 0 0 0;
    max-width: 420px;
    line-height: 1.6;
    z-index: 1;
}

/* ─────────────────────────────────────────────
   WIDGET MODE
   ───────────────────────────────────────────── */

.vwa-mode-widget {
    position: fixed;
    bottom: calc(20px + var(--vwa-bottom-distance));
    z-index: 999999;
}

.vwa-mode-widget.vwa-pos-right {
    right: 20px;
}

.vwa-mode-widget.vwa-pos-left {
    left: 20px;
}

.vwa-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    animation: vwaBounce 4s ease-in-out infinite;
}

.vwa-pos-left .vwa-toggle-wrap {
    flex-direction: row-reverse;
}

.vwa-help-bubble {
    background: #f7f7f7;
    border: 2px solid var(--vwa-primary);
    border-radius: 25px 25px 5px 25px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}

.vwa-help-bubble:hover {
    opacity: 0.85;
}

.vwa-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: var(--vwa-bubble-size);
    height: var(--vwa-bubble-size);
    background: var(--vwa-bubble-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--vwa-primary);
}

.vwa-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 26px rgba(0, 0, 0, 0.32);
    animation-play-state: paused;
}

.vwa-toggle-icon {
    width: 62%;
    height: 62%;
    object-fit: contain;
}

.vwa-window {
    position: absolute;
    bottom: calc(var(--vwa-bubble-size) + 15px);
    width: var(--vwa-window-width);
    max-width: calc(100vw - 40px);
    height: var(--vwa-window-height);
    max-height: calc(100vh - 120px);
    background: var(--vwa-background);
    border-radius: 14px;
    box-shadow: 0 1px 8px var(--vwa-header-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: vwaSlideUp 0.3s ease-out;
}

.vwa-pos-right .vwa-window {
    right: 0;
}

.vwa-pos-left .vwa-window {
    left: 0;
}

.vwa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(90deg, transparent 60%, rgba(0, 0, 0, 0.25) 100%), var(--vwa-header-bg);
    color: var(--vwa-header-text);
    flex-shrink: 0;
}

.vwa-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vwa-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: white;
}

.vwa-header-name {
    font-weight: 600;
    font-size: 15px;
}

.vwa-header-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 8px;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
}

.vwa-header-btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.vwa-mode-widget .vwa-messages {
    padding: 18px;
}

.vwa-mode-widget .vwa-bottom {
    padding: 6px 16px 9px 16px;
    border-top: 1px solid rgba(28, 34, 69, 0.08);
    flex-shrink: 0;
    background: var(--vwa-bot-bubble);
}

.vwa-mode-widget .vwa-suggestions {
    margin-bottom: 12px;
}

.vwa-mode-widget .vwa-message {
    max-width: 88%;
}

.vwa-header-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ── Historial (widget, solo admin) ── */
.vwa-subpanel {
    z-index: 5;
}

.vwa-history-search {
    position: relative;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(28, 34, 69, 0.08);
    flex-shrink: 0;
}

.vwa-history-search input {
    width: 100%;
    padding: 8px 34px 8px 14px;
    border: 1px solid rgba(28, 34, 69, 0.14);
    border-radius: 999px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.vwa-history-search input:focus {
    border-color: rgba(232, 137, 47, 0.5);
    box-shadow: 0 0 0 3px rgba(232, 137, 47, 0.12);
}

.vwa-history-search i {
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%);
    color: #9098aa;
    font-size: 13px;
}

.vwa-history-list {
    flex: 1;
    overflow-y: auto;
}

.vwa-history-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    border: none;
    border-bottom: 1px solid rgba(28, 34, 69, 0.06);
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.vwa-history-item:hover {
    background: rgb(255 255 255 / 13%);
}

.vwa-history-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.vwa-history-item-id {
    font-weight: 700;
    font-size: 13px;
    color: var(--vwa-primary);
}

.vwa-history-item-date {
    font-size: 11px;
    color: #9098aa;
}

.vwa-history-item-preview {
    font-size: 13px;
    color: #dddddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vwa-history-item-meta {
    font-size: 11px;
    color: #9098aa;
    margin-top: 4px;
}

.vwa-history-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    border-top: 1px solid rgba(28, 34, 69, 0.08);
    flex-shrink: 0;
}

.vwa-page-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--vwa-header-bg);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.vwa-page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.vwa-page-info {
    font-size: 13px;
    color: var(--vwa-primary);
}

.vwa-loading-msg,
.vwa-empty-msg {
    text-align: center;
    padding: 30px 20px;
    color: #9098aa;
    font-size: 13px;
}

#vwa-conversation-messages {
    padding: 18px;
}

/* ── Animations ── */
@keyframes vwaWelcome {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }

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

@keyframes vwaSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes vwaSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes vwaTyping {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    30% {
        transform: translateY(-4px);
        opacity: 0.9;
    }
}

@keyframes vwaPulse {

    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
    }
}

@keyframes vwaBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .vwa-mode-fullscreen .vwa-topbar {
        padding: 12px 16px;
    }

    .vwa-mode-fullscreen .vwa-messages {
        padding: 16px;
    }

    .vwa-mode-fullscreen .vwa-bottom {
        padding: 0 16px 16px;
    }

    .vwa-welcome-title {
        font-size: 22px;
    }

    .vwa-newchat span {
        display: none;
    }

    .vwa-brand-badge {
        display: none;
    }

    .vwa-message {
        max-width: 88%;
    }
}

@media (max-width: 480px) {
    .vwa-mode-widget.vwa-pos-right {
        right: 15px;
    }

    .vwa-mode-widget.vwa-pos-left {
        left: 15px;
    }

    .vwa-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 180px);
        max-height: none;
    }

    .vwa-send-label {
        display: none;
    }

    .vwa-send-btn {
        padding: 10px;
        width: 40px;
        height: 40px;
        justify-content: center;
    }
	
	.vwa-suggestions-list{
		flex-flow: wrap;
	}
		
}

@media print {
    .vwa-mode-widget {
        display: none !important;
    }
}