/* corps - WooCommerce AI Chatbot Widget */

.corps-ai-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    height: 56px;
    padding: 0 20px 0 16px;
    border-radius: 28px;
    background: var(--corps-ai-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, background 0.2s;
}

.corps-ai-chat-btn-label {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.corps-ai-chat-btn:hover {
    transform: scale(1.08);
    background: var(--corps-ai-primary-hover);
}

.corps-ai-chat-btn svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

/* Chat window */
.corps-ai-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 400px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.corps-ai-chat-window.open {
    display: flex;
}

/* Header */
.corps-ai-chat-header {
    background: var(--corps-ai-primary);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.corps-ai-chat-header-title {
    font-size: 15px;
    font-weight: 600;
}

.corps-ai-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.corps-ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.corps-ai-chat-reset {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.corps-ai-chat-reset:hover {
    opacity: 1;
}

.corps-ai-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.corps-ai-chat-close:hover {
    opacity: 1;
}

/* Messages area */
.corps-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 380px;
    background: #f7f8fa;
}

/* Message bubbles */
.corps-ai-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.corps-ai-msg-user {
    align-self: flex-end;
    background: var(--corps-ai-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.corps-ai-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e2e5e9;
    border-bottom-left-radius: 4px;
}

/* Formatted bot message content */
.corps-ai-msg-bot p {
    margin: 0 0 10px 0;
    line-height: 1.6;
}

.corps-ai-msg-bot p:last-child {
    margin-bottom: 0;
}

/* Product links */
.corps-ai-msg-bot .corps-ai-link {
    color: var(--corps-ai-primary);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s;
}

.corps-ai-msg-bot .corps-ai-link:hover {
    color: var(--corps-ai-primary-hover);
}

.corps-ai-msg-bot ul,
.corps-ai-msg-bot ol {
    margin: 8px 0 10px 0;
    padding-left: 20px;
}

.corps-ai-msg-bot ul:last-child,
.corps-ai-msg-bot ol:last-child {
    margin-bottom: 0;
}

.corps-ai-msg-bot li {
    margin-bottom: 4px;
    line-height: 1.5;
}

.corps-ai-msg-bot li:last-child {
    margin-bottom: 0;
}

/* Section block (header + list) */
.corps-ai-msg-bot .corps-ai-section {
    background: var(--corps-ai-primary-light-bg);
    border-left: 3px solid var(--corps-ai-primary);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 10px 0;
}

.corps-ai-msg-bot .corps-ai-section:last-child {
    margin-bottom: 0;
}

.corps-ai-msg-bot .corps-ai-section-title {
    font-weight: 600;
    color: var(--corps-ai-primary);
    margin-bottom: 6px;
    font-size: 13px;
}

.corps-ai-msg-bot .corps-ai-section ul {
    margin: 0;
    padding-left: 16px;
}

/* Collapsible quote / calculation */
.corps-ai-msg-bot .corps-ai-quote {
    background: var(--corps-ai-primary-light-bg);
    border: 1px solid var(--corps-ai-primary-border);
    border-radius: 8px;
    margin: 10px 0;
    overflow: hidden;
}

.corps-ai-msg-bot .corps-ai-quote:last-child {
    margin-bottom: 0;
}

.corps-ai-msg-bot .corps-ai-quote-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--corps-ai-primary);
    background: var(--corps-ai-primary-toggle-bg);
    list-style: none;
    user-select: none;
}

.corps-ai-msg-bot .corps-ai-quote-toggle::-webkit-details-marker {
    display: none;
}

.corps-ai-msg-bot .corps-ai-quote-toggle::after {
    content: "\25BC";
    font-size: 10px;
    color: var(--corps-ai-primary);
    transition: transform 0.2s;
}

.corps-ai-msg-bot .corps-ai-quote[open] .corps-ai-quote-toggle::after {
    transform: rotate(180deg);
}

.corps-ai-msg-bot .corps-ai-quote-content {
    padding: 10px 14px;
    border-top: 1px solid var(--corps-ai-primary-border);
}

.corps-ai-msg-bot .corps-ai-quote-content p {
    margin: 0 0 8px 0;
}

.corps-ai-msg-bot .corps-ai-quote-content p:last-child {
    margin-bottom: 0;
}

.corps-ai-msg-bot .corps-ai-quote-content ul {
    margin: 4px 0;
    padding-left: 16px;
}

.corps-ai-msg-bot .corps-ai-quote-content li {
    margin-bottom: 3px;
    font-size: 13px;
}

/* Cart button */
.corps-ai-cart-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    color: #fff;
    background: var(--corps-ai-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    vertical-align: middle;
    margin: 2px 0;
    line-height: 1.4;
}

.corps-ai-cart-btn:hover {
    background: var(--corps-ai-primary-hover);
}

.corps-ai-cart-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.corps-ai-cart-btn.corps-ai-cart-loading {
    background: var(--corps-ai-primary-loading);
}

.corps-ai-cart-btn.corps-ai-cart-success {
    background: #1a8917;
}

.corps-ai-cart-btn.corps-ai-cart-error {
    background: #c0392b;
}

.corps-ai-cart-btn svg {
    flex-shrink: 0;
}

/* Branding */
.corps-ai-branding {
    padding: 4px 16px 6px;
    text-align: center;
    font-size: 10px;
    background: #fafafa;
    flex-shrink: 0;
}

.corps-ai-branding a {
    color: #999;
    text-decoration: none;
}

.corps-ai-branding a:hover {
    color: #666;
    text-decoration: underline;
}

/* Disclaimer */
.corps-ai-chat-disclaimer {
    padding: 6px 16px;
    font-size: 11px;
    color: #888;
    text-align: center;
    background: #fafafa;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

/* Typing indicator */
.corps-ai-typing {
    align-self: flex-start;
    padding: 12px 18px;
    background: #fff;
    border: 1px solid #e2e5e9;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    display: none;
}

.corps-ai-typing.visible {
    display: flex;
    gap: 4px;
    align-items: center;
}

.corps-ai-typing-dot {
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
    animation: corps-ai-bounce 1.2s infinite;
}

.corps-ai-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.corps-ai-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes corps-ai-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.corps-ai-chat-input {
    display: flex;
    padding: 12px;
    border-top: 1px solid #e2e5e9;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

.corps-ai-chat-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.corps-ai-chat-input textarea:focus {
    border-color: var(--corps-ai-primary);
}

.corps-ai-chat-input textarea::placeholder {
    color: #999;
}

.corps-ai-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--corps-ai-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    align-self: flex-end;
}

.corps-ai-chat-send:hover {
    background: var(--corps-ai-primary-hover);
}

.corps-ai-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.corps-ai-send-icon {
    font-size: 22px;
    line-height: 1;
    color: #fff;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .corps-ai-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }

    .corps-ai-chat-messages {
        max-height: none;
        flex: 1;
        min-height: 0;
    }

    .corps-ai-chat-btn {
        bottom: 16px;
        right: 16px;
    }
}
