/* PMI HomeV2 — chatbot.css */
/* Floating bubble bottom-right, 3-step flow: API key, user info, chat interface */

.v2-chatbot, .v2-chatbot *, .v2-chatbot *::before, .v2-chatbot *::after { box-sizing: border-box; margin: 0; padding: 0; }

.elementor-widget-pmiv2_chatbot .elementor-widget-container { padding: 0 !important; margin: 0 !important; }

/* Floating bubble */
.v2-chatbot {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99990;
    font-family: 'DM Sans', sans-serif;
}

.v2-chatbot__bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #f97316;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 24px rgba(249,115,22,0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
}

.v2-chatbot__bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 32px rgba(249,115,22,0.55);
    background: #ea6c0a;
}

.v2-chatbot__bubble:active { transform: scale(0.96); }
.v2-chatbot__bubble:focus-visible { outline: 3px solid #0f2d58; outline-offset: 3px; }

.v2-chatbot__bubble-icon { display: flex; align-items: center; justify-content: center; }
.v2-chatbot__bubble-icon[hidden] { display: none; }

/* Pulse animation */
.v2-chatbot__bubble::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(249,115,22,0.4);
    animation: chatPulse 2.5s ease-in-out infinite;
}

@keyframes chatPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.18); opacity: 0; }
}

.v2-chatbot__bubble-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1a8fe8;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.v2-chatbot__bubble-badge[hidden] { display: none; }

/* Chat window */
.v2-chatbot__window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: chatWindowIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
    border: 1px solid #e5e7eb;
}

.v2-chatbot__window[hidden] { display: none; }

@keyframes chatWindowIn {
    from { opacity: 0; transform: scale(0.92) translateY(12px); transform-origin: bottom right; }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Header */
.v2-chatbot__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #0f2d58;
    color: #fff;
}

.v2-chatbot__header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(249,115,22,0.25);
    border: 1.5px solid rgba(249,115,22,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f97316;
    flex-shrink: 0;
}

.v2-chatbot__header-info { flex: 1; display: flex; flex-direction: column; gap: 1px; }

.v2-chatbot__header-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.v2-chatbot__header-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: rgba(255,255,255,0.65);
}

.v2-chatbot__status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    animation: statusPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.v2-chatbot__header-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.2s ease, background 0.2s ease;
}

.v2-chatbot__header-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.v2-chatbot__header-close:focus-visible { outline: 2px solid #f97316; }

/* Steps */
.v2-chatbot__step { flex: 1; overflow-y: auto; }
.v2-chatbot__step[hidden] { display: none; }

.v2-chatbot__step-inner {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
    text-align: center;
}

.v2-chatbot__step-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(249,115,22,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.v2-chatbot__step-title {
    font-size: 15px;
    font-weight: 800;
    color: #111827;
}

.v2-chatbot__step-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.6;
    max-width: 280px;
}

.v2-chatbot__field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
}

.v2-chatbot__field-label {
    font-size: 11px;
    font-weight: 600;
    color: #374151;
}

.v2-chatbot__field-label span { color: #f97316; }

.v2-chatbot__input,
.v2-chatbot__select {
    width: 100%;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
    color: #111827;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

.v2-chatbot__input:focus,
.v2-chatbot__select:focus {
    border-color: #f97316;
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

.v2-chatbot__select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

.v2-chatbot__field-hint {
    font-size: 10px;
    color: #9ca3af;
}

.v2-chatbot__field-hint a { color: #1a8fe8; }

.v2-chatbot__step-btn {
    background: #f97316;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 11px 24px;
    font-size: 13px;
    font-weight: 700;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s ease, transform 0.15s ease;
    margin-top: 4px;
}

.v2-chatbot__step-btn:hover { background: #ea6c0a; transform: translateY(-1px); }
.v2-chatbot__step-btn:active { transform: translateY(0); }
.v2-chatbot__step-btn:focus-visible { outline: 2px solid #0f2d58; outline-offset: 2px; }

.v2-chatbot__step-btn.is-loading {
    opacity: 0.75;
    pointer-events: none;
}

/* Chat messages */
.v2-chatbot__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 280px;
    min-height: 200px;
    scroll-behavior: smooth;
}

.v2-chatbot__messages::-webkit-scrollbar { width: 3px; }
.v2-chatbot__messages::-webkit-scrollbar-track { background: transparent; }
.v2-chatbot__messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 3px; }

.v2-chatbot__msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: msgIn 0.25s ease both;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.v2-chatbot__msg--bot { align-self: flex-start; }
.v2-chatbot__msg--user { align-self: flex-end; flex-direction: row-reverse; }

.v2-chatbot__msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(15,45,88,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #0f2d58;
    font-size: 10px;
    font-weight: 700;
}

.v2-chatbot__msg--user .v2-chatbot__msg-avatar { background: #f97316; color: #fff; }

.v2-chatbot__msg-bubble {
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.65;
    max-width: 100%;
    word-wrap: break-word;
}

.v2-chatbot__msg--bot .v2-chatbot__msg-bubble {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 3px;
}

.v2-chatbot__msg--user .v2-chatbot__msg-bubble {
    background: #f97316;
    color: #fff;
    border-bottom-right-radius: 3px;
}

/* Typing indicator */
.v2-chatbot__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    align-self: flex-start;
}

.v2-chatbot__typing[hidden] { display: none; }

.v2-chatbot__typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #d1d5db;
    animation: typingDot 1.2s ease-in-out infinite;
}

.v2-chatbot__typing span:nth-child(2) { animation-delay: 0.2s; }
.v2-chatbot__typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Composer */
.v2-chatbot__composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f3f4f6;
    background: #fff;
}

.v2-chatbot__composer-input {
    flex: 1;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12px;
    color: #111827;
    font-family: 'DM Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s ease;
}

.v2-chatbot__composer-input:focus { border-color: #f97316; }
.v2-chatbot__composer-input::placeholder { color: #9ca3af; font-size: 11px; }

.v2-chatbot__composer-send {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f97316;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.v2-chatbot__composer-send:hover { background: #ea6c0a; transform: scale(1.08); }
.v2-chatbot__composer-send:disabled { background: #d1d5db; cursor: not-allowed; transform: none; }
.v2-chatbot__composer-send:focus-visible { outline: 2px solid #0f2d58; outline-offset: 2px; }

/* Footer bar */
.v2-chatbot__footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 10px;
    border-top: 1px solid #f9fafb;
}

.v2-chatbot__reset {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    padding: 3px 6px;
    border-radius: 4px;
    transition: color 0.2s ease, background 0.2s ease;
}

.v2-chatbot__reset:hover { color: #f97316; background: rgba(249,115,22,0.07); }

.v2-chatbot__powered {
    font-size: 9px;
    color: #d1d5db;
    letter-spacing: 0.03em;
}

/* Error bubble */
.v2-chatbot__msg-bubble.is-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

@media (max-width: 420px) {
    .v2-chatbot { bottom: 16px; right: 16px; }
    .v2-chatbot__window { width: calc(100vw - 32px); right: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    .v2-chatbot__bubble::before { display: none; }
}
