/**
 * AI Super Bot — Floating Chat Widget Styles (Light Mode)
 *
 * @package AI Super Bot
 * @since 1.0.0
 */

/* === Utility: reliable hide/show === */
.asb-hidden {
    display: none !important;
}

/* Show popup/bubble as flex/block only when .asb-hidden is absent */
.asb-floating-popup:not(.asb-hidden) {
    display: flex;
}
.asb-welcome-bubble:not(.asb-hidden) {
    display: block;
}

/* === Floating Widget Container === */
.asb-floating-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Left position variant */
.asb-floating-widget.asb-position-left {
    right: auto;
    left: 20px;
    align-items: flex-start;
}

.asb-floating-widget.asb-position-left .asb-floating-button {
    right: auto;
    left: 0;
}

.asb-floating-widget.asb-position-left .asb-floating-popup {
    right: auto;
    left: 0;
}

.asb-floating-widget.asb-position-left .asb-welcome-bubble-arrow {
    right: auto;
    left: 20px;
}

/* === Floating Button (60×60 circle) === */
.asb-floating-button {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    border-radius: 100px !important;
    background: #222 !important;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 2;
    padding: 0;
    outline: none;
}

.asb-floating-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.asb-floating-button:active {
    transform: scale(0.95);
}

/* Custom icon image */
.asb-floating-custom-icon {
    max-width: 32px;
    max-height: 32px;
    width: auto;
    height: auto;
    border-radius: 100px;
    object-fit: contain;
}

/* Icon toggle */
.asb-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Chat Popup === */
.asb-floating-popup {
    flex-direction: column;
    width: 390px;
    height: 600px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    position: relative;
    animation: asbPopupIn 0.25s ease-out;
}

@keyframes asbPopupIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Chat Header ────────────────────────────────── */
.asb-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--asb-primary, #0073ee);
    color: #fff;
    flex-shrink: 0;
}

.asb-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.asb-chat-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.asb-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.asb-chat-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid var(--asb-primary, #0073ee);
    border-radius: 50%;
}

.asb-chat-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asb-chat-header-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.asb-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ── Messages Area ───────────────────────────────── */
.asb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

/* Scrollbar */
.asb-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.asb-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ── Chat Form ───────────────────────────────────── */
.asb-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.asb-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 100px;
    transition: border-color 0.15s;
}

.asb-chat-input:focus {
    border-color: var(--asb-primary, #0073ee);
    box-shadow: 0 0 0 3px var(--asb-primary-light, rgba(0, 115, 238, 0.15));
}

.asb-chat-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--asb-primary, #0073ee);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.asb-chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
    flex-shrink: 0;
}

.asb-chat-send:hover {
    background: color-mix(in srgb, var(--asb-primary, #0073ee) 85%, #000);
    transform: scale(1.05);
}

.asb-chat-send:active {
    transform: scale(0.95);
}

/* ── Message Bubbles ─────────────────────────────── */
.asb-msg {
    display: flex;
    max-width: 85%;
}

.asb-msg--bot {
    align-self: flex-start;
}

.asb-msg--user {
    align-self: flex-end;
}

.asb-msg__bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

/* ── Markdown content styles (inside bot messages) ── */
.asb-msg--bot .asb-msg__bubble h3 {
    margin: 12px 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.asb-msg--bot .asb-msg__bubble h4 {
    margin: 10px 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.asb-msg--bot .asb-msg__bubble ul,
.asb-msg--bot .asb-msg__bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.asb-msg--bot .asb-msg__bubble li {
    margin-bottom: 3px;
}

.asb-msg--bot .asb-msg__bubble code {
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    color: #dc2626;
}

.asb-msg--bot .asb-msg__bubble hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 10px 0;
}

.asb-msg--bot .asb-msg__bubble a {
    color: var(--asb-primary, #0073ee);
    text-decoration: underline;
}

.asb-msg--user .asb-msg__bubble a {
    color: #fff;
}

.asb-msg--bot .asb-msg__bubble {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.asb-msg--user .asb-msg__bubble {
    background: var(--asb-primary, #0073ee);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.asb-msg--error .asb-msg__bubble {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ── Typing indicator ────────────────────────────── */
.asb-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.asb-typing span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: asbTypingBounce 1.2s infinite ease-in-out;
}

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

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

@keyframes asbTypingBounce {
    0%,
    80%,
    100% {
        transform: scale(0.7);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ── Chat Form ───────────────────────────────────── */
.asb-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.asb-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 100px;
    transition: border-color 0.15s;
}

.asb-chat-input:focus {
    border-color: var(--asb-primary, #0073ee);
    box-shadow: 0 0 0 3px var(--asb-primary-light, rgba(0, 115, 238, 0.15));
}

.asb-chat-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border: none;
    border-radius: 10px;
    background: var(--asb-primary, #0073ee);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.asb-chat-send:hover {
    background: color-mix(in srgb, var(--asb-primary, #0073ee) 85%, #000);
    transform: scale(1.05);
}

.asb-chat-send:active {
    transform: scale(0.95);
}

/* ── Welcome Bubble ──────────────────────────────── */
.asb-welcome-bubble {
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 36px 12px 14px;
    max-width: 260px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    line-height: 1.4;
    color: #1f2937;
    animation: asbBubbleIn 0.3s ease-out;
    flex-shrink: 0;
}

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

.asb-welcome-bubble-content {
    padding-right: 4px;
}

.asb-welcome-bubble-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.asb-welcome-bubble-close:hover {
    color: #374151;
    background: #f3f4f6;
}

/* Arrow pointing down to the button */
.asb-welcome-bubble-arrow {
    position: absolute;
    bottom: -7px;
    right: 16px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    transform: rotate(45deg);
    margin-bottom: -1px;
}

/* ── Product Cards ───────────────────────────────── */
.asb-product-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 0 4px;
    width: 100%;
    max-width: 85%;
    align-self: flex-start;
}

.asb-product-card {
    display: flex;
    gap: 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, border-color 0.15s;
    overflow: hidden;
}

.asb-product-card:hover {
    border-color: var(--asb-primary, #0073ee);
    box-shadow: 0 2px 8px rgba(0, 115, 238, 0.12);
}

.asb-product-thumb {
    position: relative;
    width: 80px;
    min-width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    flex-shrink: 0;
}

.asb-product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.asb-product-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1.2;
    text-transform: uppercase;
}

.asb-product-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.asb-product-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asb-product-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--asb-primary, #0073ee);
    line-height: 1.3;
}

.asb-product-price del {
    color: #9ca3af;
    font-weight: 400;
    font-size: 12px;
}

.asb-product-price ins {
    text-decoration: none;
    color: #ef4444;
    font-weight: 700;
}

.asb-product-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asb-product-stock {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    margin-top: auto;
}

.asb-product-stock--in {
    color: #16a34a;
}

.asb-product-stock--out {
    color: #dc2626;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 480px) {
    .asb-floating-popup {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 80px) !important;
        border-radius: 12px;
        max-width: none;
        max-height: none;
    }

    .asb-floating-widget {
        bottom: 12px;
        right: 12px;
    }

    .asb-floating-widget.asb-position-left {
        left: 12px;
    }
}
