/**
 * WP Agent Sidekick - Modern UI Stylesheet
 */

:root {
    --wp-ai-primary: #0073aa;
    --wp-ai-primary-hover: #005a87;
    --wp-ai-text-on-primary: #ffffff;
    --wp-ai-bg: #ffffff;
    --wp-ai-bubble-bot: #ffffff;
    --wp-ai-text-bot: #1e293b;
    --wp-ai-text-muted: #64748b;
    --wp-ai-border: #e2e8f0;
    --wp-ai-border-light: #f1f5f9;
    --wp-ai-radius: 20px;
    --wp-ai-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.16), 0 0 1px 1px rgba(0, 0, 0, 0.05);
    --wp-ai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", -apple-system, sans-serif;
}

/* Floating Launcher Button */
.wp-ai-chat-launcher {
    position: fixed;
    bottom: 24px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wp-ai-primary) 0%, var(--wp-ai-primary-hover) 100%);
    color: var(--wp-ai-text-on-primary);
    border: none;
    box-shadow: 0 8px 24px -4px rgba(0, 115, 170, 0.45), 0 4px 12px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999990;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
    outline: none;
}

.wp-ai-chat-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 28px -4px rgba(0, 115, 170, 0.55), 0 6px 16px rgba(0, 0, 0, 0.15);
}

.wp-ai-chat-launcher:active {
    transform: scale(0.96);
}

.wp-ai-chat-launcher.wp-ai-pos-right {
    right: 24px;
}

.wp-ai-chat-launcher.wp-ai-pos-left {
    left: 24px;
}

/* Launcher Pulse Halo */
.wp-ai-launcher-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--wp-ai-primary);
    opacity: 0.6;
    animation: wpAiPulseRing 2.5s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
    pointer-events: none;
}

@keyframes wpAiPulseRing {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    70% {
        transform: scale(1.35);
        opacity: 0;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.wp-ai-chat-launcher svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.wp-ai-chat-launcher .wp-ai-icon-close {
    display: none;
}

.wp-ai-chat-launcher.wp-ai-open .wp-ai-icon-chat {
    display: none;
}

.wp-ai-chat-launcher.wp-ai-open .wp-ai-icon-close {
    display: block;
    transform: rotate(90deg);
}

.wp-ai-chat-launcher.wp-ai-open .wp-ai-launcher-pulse {
    display: none;
}

/* Chat Window Container */
.wp-ai-chat-window {
    position: fixed;
    bottom: 100px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 590px;
    max-height: calc(100vh - 130px);
    background: var(--wp-ai-bg);
    border-radius: var(--wp-ai-radius);
    box-shadow: var(--wp-ai-shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999991;
    font-family: var(--wp-ai-font);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.96);
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
}

.wp-ai-chat-window.wp-ai-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.wp-ai-chat-window.wp-ai-pos-right {
    right: 24px;
}

.wp-ai-chat-window.wp-ai-pos-left {
    left: 24px;
}

/* Modern Header */
.wp-ai-chat-header {
    background: linear-gradient(135deg, var(--wp-ai-primary) 0%, var(--wp-ai-primary-hover) 100%);
    color: var(--wp-ai-text-on-primary);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 2;
}

.wp-ai-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wp-ai-header-avatar {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(4px);
}

.wp-ai-header-avatar svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
}

.wp-ai-status-pulse {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background-color: #22c55e;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.wp-ai-header-info {
    display: flex;
    flex-direction: column;
}

.wp-ai-header-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: #ffffff;
}

.wp-ai-header-subtitle {
    font-size: 11px;
    margin: 2px 0 0 0;
    color: rgba(255, 255, 255, 0.88);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

.wp-ai-online-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.wp-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wp-ai-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    outline: none;
}

.wp-ai-header-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.05);
}

.wp-ai-header-btn svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

/* Message List */
.wp-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background-color: #f8fafc;
    scroll-behavior: smooth;
}

.wp-ai-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.wp-ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.14);
    border-radius: 10px;
}

/* Message Rows */
.wp-ai-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 92%;
    animation: wpAiSlideUp 0.22s ease-out;
}

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

.wp-ai-row-user {
    align-self: flex-end;
    justify-content: flex-end;
    margin-left: auto;
}

.wp-ai-row-assistant {
    align-self: flex-start;
    justify-content: flex-start;
    margin-right: auto;
}

/* Assistant Avatar Beside Bubble */
.wp-ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wp-ai-primary) 0%, var(--wp-ai-primary-hover) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.wp-ai-msg-avatar svg {
    width: 16px;
    height: 16px;
    fill: #ffffff;
}

/* Message Bubbles */
.wp-ai-message {
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}

.wp-ai-message-user {
    background: linear-gradient(135deg, var(--wp-ai-primary) 0%, var(--wp-ai-primary-hover) 100%);
    color: var(--wp-ai-text-on-primary);
    padding: 10px 15px;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.wp-ai-message-bot {
    background: #ffffff;
    color: var(--wp-ai-text-bot);
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid var(--wp-ai-border);
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.05);
}

.wp-ai-message-bot p {
    margin: 0 0 8px 0;
}

.wp-ai-message-bot p:last-child {
    margin-bottom: 0;
}

.wp-ai-message-bot ul,
.wp-ai-message-bot ol {
    margin: 4px 0 8px 18px;
    padding: 0;
}

.wp-ai-message-bot li {
    margin-bottom: 3px;
}

.wp-ai-message-bot a {
    color: var(--wp-ai-primary);
    font-weight: 500;
    text-decoration: underline;
    word-break: break-all;
}

.wp-ai-message-bot code {
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.wp-ai-message-bot pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 10px 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 12px;
    margin: 6px 0;
}

/* Typing Indicator */
.wp-ai-typing-indicator {
    background: #ffffff;
    border: 1px solid var(--wp-ai-border);
    padding: 10px 14px;
    border-radius: 18px 18px 18px 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.05);
}

.wp-ai-typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--wp-ai-primary);
    border-radius: 50%;
    animation: wpAiWave 1.3s infinite ease-in-out both;
}

.wp-ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.wp-ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes wpAiWave {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.35;
    }
    40% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Quick Suggestion Pills */
.wp-ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 6px;
    margin-bottom: 2px;
}

.wp-ai-suggestion-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: var(--wp-ai-primary);
    font-size: 12px;
    font-weight: 500;
    padding: 7px 13px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: left;
    font-family: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.wp-ai-suggestion-btn:hover {
    background: var(--wp-ai-primary);
    color: var(--wp-ai-text-on-primary);
    border-color: var(--wp-ai-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 115, 170, 0.2);
}

/* Modern Input Area */
.wp-ai-chat-input-wrapper {
    background: #ffffff;
    border-top: 1px solid var(--wp-ai-border-light);
    padding: 10px 14px 8px 14px;
}

.wp-ai-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid var(--wp-ai-border);
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.wp-ai-chat-input-area:focus-within {
    border-color: var(--wp-ai-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.12);
}

.wp-ai-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 7px 0;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    color: #1e293b;
}

.wp-ai-input::placeholder {
    color: #94a3b8;
}

.wp-ai-btn-send {
    background: linear-gradient(135deg, var(--wp-ai-primary) 0%, var(--wp-ai-primary-hover) 100%);
    color: var(--wp-ai-text-on-primary);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    box-shadow: 0 2px 6px rgba(0, 115, 170, 0.25);
}

.wp-ai-btn-send:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 10px rgba(0, 115, 170, 0.35);
}

.wp-ai-btn-send:active {
    transform: scale(0.95);
}

.wp-ai-btn-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.wp-ai-btn-send svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
    transform: translateX(1px);
}

/* Subtle Footer */
.wp-ai-chat-footer {
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    margin-top: 6px;
    letter-spacing: 0.02em;
}

.wp-ai-chat-footer strong {
    color: #64748b;
    font-weight: 600;
}

/* Error Banner */
.wp-ai-error-banner {
    background: #fee2e2;
    color: #991b1b;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Human Handoff Card */
.wp-ai-handoff-card {
    background: #ffffff;
    border: 1px solid var(--wp-ai-border);
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 4px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.wp-ai-handoff-caption {
    font-size: 12px;
    color: var(--wp-ai-text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wp-ai-handoff-badge {
    display: inline-block;
    background: #ecfdf5;
    color: #059669;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 6px;
    align-self: flex-start;
}

.wp-ai-handoff-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--wp-ai-primary) 0%, var(--wp-ai-primary-hover) 100%);
    color: var(--wp-ai-text-on-primary) !important;
    text-decoration: none !important;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease;
    box-shadow: 0 3px 8px rgba(0, 115, 170, 0.25);
}

.wp-ai-handoff-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 115, 170, 0.35);
}

.wp-ai-handoff-arrow {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    transition: transform 0.15s ease;
}

.wp-ai-handoff-btn:hover .wp-ai-handoff-arrow {
    transform: translateX(3px);
}

/* Mobile Screen Adaptation */
@media (max-width: 480px) {
    .wp-ai-chat-window {
        width: 100vw;
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
        border: none;
    }
    .wp-ai-chat-launcher {
        bottom: 16px;
    }
    .wp-ai-chat-launcher.wp-ai-pos-right {
        right: 16px;
    }
    .wp-ai-chat-launcher.wp-ai-pos-left {
        left: 16px;
    }
}
