.lp-ai-root {
    --lp-ai-bg-1: #0B1739;
    --lp-ai-bg-2: #162447;
    --lp-ai-bg-3: #1F4068;
    --lp-ai-gold: #FCD34D;
    --lp-ai-gold-bright: #FDE68A;
    --lp-ai-gold-glow: rgba(252, 211, 77, 0.42);
    --lp-ai-cyan: #22D3EE;
    --lp-ai-cyan-glow: rgba(34, 211, 238, 0.4);
    --lp-ai-green: #4ade80;
    --lp-ai-red: #f87171;
    --lp-ai-text: rgba(255, 255, 255, 0.92);
    --lp-ai-text-dim: rgba(255, 255, 255, 0.65);
    --lp-ai-border: rgba(255, 255, 255, 0.12);
    --lp-ai-panel-bg: linear-gradient(135deg, #162447 0%, #1F4068 100%);
    --lp-ai-msg-bot-bg: rgba(0, 0, 0, 0.32);
    --lp-ai-msg-user-bg: linear-gradient(135deg, rgba(252, 211, 77, 0.18) 0%, rgba(34, 211, 238, 0.12) 100%);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.lp-ai-root *,
.lp-ai-root *::before,
.lp-ai-root *::after {
    box-sizing: border-box;
}

/* ═══════════════════════════════════════════════
   FAB (Floating Action Button)
   ═══════════════════════════════════════════════ */
.lp-ai-fab {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22D3EE 0%, #FCD34D 100%);
    border: 2px solid #FDE68A;
    color: #0B1739;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999996;
    box-shadow:
        0 4px 20px rgba(34, 211, 238, 0.45),
        0 4px 20px rgba(252, 211, 77, 0.35),
        0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
    outline: none;
    font-family: inherit;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
}

.lp-ai-fab:hover,
.lp-ai-fab:focus {
    transform: scale(1.08);
    box-shadow:
        0 6px 28px rgba(34, 211, 238, 0.55),
        0 6px 28px rgba(252, 211, 77, 0.45),
        0 2px 10px rgba(0, 0, 0, 0.35);
}

.lp-ai-fab:active {
    transform: scale(0.98);
}

.lp-ai-fab.is-open {
    transform: rotate(90deg) scale(0.9);
}

.lp-ai-fab.is-open:hover {
    transform: rotate(90deg) scale(1);
}

.lp-ai-fab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    line-height: 1;
}

.lp-ai-fab-icon i {
    display: inline-block;
    pointer-events: none;
}

.lp-ai-fab-pulse {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid rgba(34, 211, 238, 0.55);
    animation: lpAiFabPulse 2s ease-out infinite;
    pointer-events: none;
}

@keyframes lpAiFabPulse {
    0% {
        transform: scale(1);
        opacity: 0.9;
    }
    70% {
        transform: scale(1.35);
        opacity: 0;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.lp-ai-fab.is-open .lp-ai-fab-pulse {
    display: none;
}

body.lp-ai-open .lp-ai-fab {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════
   OVERLAY
   ═══════════════════════════════════════════════ */
.lp-ai-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.lp-ai-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ═══════════════════════════════════════════════
   PANEL
   ═══════════════════════════════════════════════ */
.lp-ai-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 92%;
    max-width: 440px;
    background: var(--lp-ai-panel-bg);
    border-left: 1px solid var(--lp-ai-gold);
    z-index: 999998;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6);
    color: var(--lp-ai-text);
}

.lp-ai-panel.is-open {
    transform: translateX(0);
}

.lp-ai-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at top right, rgba(34, 211, 238, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.lp-ai-panel > * {
    position: relative;
    z-index: 1;
}

/* ═══════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════ */
.lp-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(252, 211, 77, 0.22);
    background: rgba(0, 0, 0, 0.24);
    flex-shrink: 0;
}

.lp-ai-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.lp-ai-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22D3EE 0%, #FCD34D 100%);
    color: #0B1739;
    font-size: 17px;
    flex-shrink: 0;
    box-shadow: 0 0 12px var(--lp-ai-cyan-glow);
}

.lp-ai-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lp-ai-title {
    margin: 0;
    padding: 0;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -0.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lp-ai-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--lp-ai-text-dim);
    line-height: 1.2;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lp-ai-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.75);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.18s ease;
    flex-shrink: 0;
    padding: 0;
    font-family: inherit;
}

.lp-ai-close:hover,
.lp-ai-close:focus {
    background: rgba(248, 113, 113, 0.16);
    border-color: rgba(248, 113, 113, 0.5);
    color: #f87171;
    outline: none;
}

/* ═══════════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════════ */
.lp-ai-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(252, 211, 77, 0.4) transparent;
}

.lp-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.lp-ai-messages::-webkit-scrollbar-thumb {
    background: rgba(252, 211, 77, 0.4);
    border-radius: 3px;
}

.lp-ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(252, 211, 77, 0.6);
}

.lp-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.lp-ai-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    animation: lpAiMsgIn 0.28s ease-out;
}

@keyframes lpAiMsgIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lp-ai-msg-bot {
    flex-direction: row;
}

.lp-ai-msg-user {
    flex-direction: row-reverse;
}

.lp-ai-msg-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22D3EE 0%, #FCD34D 100%);
    color: #0B1739;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 0 8px var(--lp-ai-cyan-glow);
}

.lp-ai-msg-user .lp-ai-msg-avatar {
    background: linear-gradient(135deg, #FCD34D 0%, #FDE68A 100%);
    box-shadow: 0 0 8px var(--lp-ai-gold-glow);
}

.lp-ai-msg-bubble {
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--lp-ai-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: calc(100% - 40px);
    border: 1px solid var(--lp-ai-border);
}

.lp-ai-msg-bot .lp-ai-msg-bubble {
    background: var(--lp-ai-msg-bot-bg);
    border-top-left-radius: 4px;
}

.lp-ai-msg-user .lp-ai-msg-bubble {
    background: var(--lp-ai-msg-user-bg);
    border-top-right-radius: 4px;
    border-color: rgba(252, 211, 77, 0.28);
}

.lp-ai-msg-bubble p {
    margin: 0 0 6px;
}

.lp-ai-msg-bubble p:last-child {
    margin-bottom: 0;
}

.lp-ai-msg-bubble strong {
    color: var(--lp-ai-gold-bright);
    font-weight: 800;
}

.lp-ai-msg-bubble em {
    color: var(--lp-ai-cyan);
    font-style: italic;
}

.lp-ai-msg-bubble a {
    color: var(--lp-ai-gold);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 700;
    transition: color 0.15s ease;
}

.lp-ai-msg-bubble a:hover,
.lp-ai-msg-bubble a:focus {
    color: var(--lp-ai-gold-bright);
    outline: none;
}

.lp-ai-msg-bubble ul,
.lp-ai-msg-bubble ol {
    margin: 4px 0 6px;
    padding-left: 20px;
}

.lp-ai-msg-bubble li {
    margin: 2px 0;
}

.lp-ai-msg-bubble code {
    background: rgba(0, 0, 0, 0.4);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--lp-ai-cyan);
    font-family: 'SF Mono', Menlo, Consolas, monospace;
}

.lp-ai-upsell {
    margin: 6px 0 0;
    padding: 8px 10px;
    background: rgba(252, 211, 77, 0.08);
    border: 1px solid rgba(252, 211, 77, 0.28);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
}

.lp-ai-upsell strong {
    color: var(--lp-ai-gold);
}

/* ═══════════════════════════════════════════════
   SUGGESTIONS
   ═══════════════════════════════════════════════ */
.lp-ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px 4px 38px;
    animation: lpAiMsgIn 0.3s ease-out 0.1s both;
}

.lp-ai-suggestion {
    display: inline-flex;
    align-items: center;
    padding: 6px 11px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    color: var(--lp-ai-text-dim);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    outline: none;
    text-align: left;
    line-height: 1.3;
}

.lp-ai-suggestion:hover,
.lp-ai-suggestion:focus {
    background: rgba(252, 211, 77, 0.14);
    border-color: var(--lp-ai-gold);
    color: var(--lp-ai-gold-bright);
    box-shadow: 0 0 8px rgba(252, 211, 77, 0.22);
}

/* ═══════════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════════ */
.lp-ai-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 18px 8px 46px;
    flex-shrink: 0;
}

.lp-ai-typing[hidden] {
    display: none;
}

.lp-ai-typing-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--lp-ai-cyan);
    animation: lpAiTyping 1.2s ease-in-out infinite;
    box-shadow: 0 0 6px var(--lp-ai-cyan-glow);
}

.lp-ai-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.lp-ai-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes lpAiTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════
   FORM
   ═══════════════════════════════════════════════ */
.lp-ai-form {
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.32);
    padding: 10px 12px;
}

.lp-ai-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    padding: 6px 6px 6px 12px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.lp-ai-input-wrap:focus-within {
    border-color: var(--lp-ai-gold);
    box-shadow: 0 0 0 3px rgba(252, 211, 77, 0.14);
}

.lp-ai-input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--lp-ai-text);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.5;
    padding: 6px 0;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    -webkit-appearance: none;
    appearance: none;
}

.lp-ai-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.lp-ai-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #22D3EE 0%, #FCD34D 100%);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: #0B1739;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.18s ease;
    flex-shrink: 0;
    padding: 0;
    font-family: inherit;
    outline: none;
}

.lp-ai-send:hover:not(:disabled),
.lp-ai-send:focus:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(252, 211, 77, 0.5);
}

.lp-ai-send:active:not(:disabled) {
    transform: scale(0.98);
}

.lp-ai-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.lp-ai-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding: 0 2px;
}

.lp-ai-hint {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.3;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lp-ai-clear {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    outline: none;
    flex-shrink: 0;
}

.lp-ai-clear:hover,
.lp-ai-clear:focus {
    color: var(--lp-ai-red);
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.08);
}

.lp-ai-clear i {
    font-size: 10px;
}

/* ═══════════════════════════════════════════════
   SCROLLBAR IN PANEL (Firefox)
   ═══════════════════════════════════════════════ */
.lp-ai-panel {
    scrollbar-width: thin;
    scrollbar-color: rgba(252, 211, 77, 0.4) transparent;
}

/* ═══════════════════════════════════════════════
   BODY LOCK
   ═══════════════════════════════════════════════ */
body.lp-ai-open {
    overflow: hidden;
}

/* ═══════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════ */
@media (max-width: 640px) {
    .lp-ai-fab {
        width: 52px;
        height: 52px;
        font-size: 20px;
        bottom: 78px;
        right: 18px;
    }

    .lp-ai-panel {
        width: 100%;
        max-width: 100%;
        border-left: 0;
    }

    .lp-ai-header {
        padding: 12px 14px;
    }

    .lp-ai-header-icon {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .lp-ai-title {
        font-size: 14px;
    }

    .lp-ai-subtitle {
        font-size: 10.5px;
    }

    .lp-ai-messages {
        padding: 12px 10px;
        gap: 10px;
    }

    .lp-ai-msg-bubble {
        font-size: 13px;
        padding: 9px 12px;
    }

    .lp-ai-msg-avatar {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }

    .lp-ai-suggestions {
        padding-left: 34px;
    }

    .lp-ai-form {
        padding: 8px 10px;
    }

    .lp-ai-hint {
        display: none;
    }

    .lp-ai-footer {
        justify-content: flex-end;
    }
}

@media (max-width: 380px) {
    .lp-ai-msg-bubble {
        max-width: calc(100% - 34px);
    }
}

/* ═══════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .lp-ai-fab,
    .lp-ai-overlay,
    .lp-ai-panel,
    .lp-ai-msg,
    .lp-ai-suggestion,
    .lp-ai-send,
    .lp-ai-typing-dot,
    .lp-ai-fab-pulse {
        animation: none !important;
        transition: none !important;
    }
}

.lp-ai-fab:focus-visible,
.lp-ai-close:focus-visible,
.lp-ai-send:focus-visible,
.lp-ai-input:focus-visible,
.lp-ai-suggestion:focus-visible,
.lp-ai-clear:focus-visible {
    outline: 2px solid var(--lp-ai-gold);
    outline-offset: 2px;
}

.lp-ai-root [hidden] {
    display: none !important;
}

/* ═══════════════════════════════════════════════
   INLINE MODE (shortcode [lp_ai_agent])
   ═══════════════════════════════════════════════ */
.lp-ai-root.lp-ai-root-inline {
    display: block;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0;
}

.lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    max-width: 100%;
    transform: none;
    transition: none;
    border: 1px solid var(--lp-ai-gold);
    border-radius: 14px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 24px rgba(252, 211, 77, 0.12);
    overflow: hidden;
    height: 620px;
    max-height: 80vh;
    z-index: auto;
}

.lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline::before {
    border-radius: inherit;
}

.lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline .lp-ai-messages {
    min-height: 0;
}

.lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline .lp-ai-header {
    border-radius: 14px 14px 0 0;
}

.lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline .lp-ai-form {
    border-radius: 0 0 14px 14px;
}

@media (max-width: 768px) {
    .lp-ai-root.lp-ai-root-inline {
        max-width: 100%;
    }
    .lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline {
        height: 560px;
    }
}

@media (max-width: 640px) {
    .lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline {
        height: 520px;
        max-height: 75vh;
        border-radius: 10px;
    }
    .lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline .lp-ai-header {
        border-radius: 10px 10px 0 0;
    }
    .lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline .lp-ai-form {
        border-radius: 0 0 10px 10px;
    }
}

@media (max-width: 380px) {
    .lp-ai-root.lp-ai-root-inline .lp-ai-panel.lp-ai-panel-inline {
        height: 480px;
    }
}
