/**
 * WickerFlow Chat Widget — Frontend styles.
 * @package WickerFlow_AI_Commerce
 */

/* ========= Container ========= */
.wflow-widget {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
.wflow-widget--right { right: 20px; }
.wflow-widget--left  { left: 20px; }

/* ========= Floating Bubble ========= */
.wflow-bubble-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-direction: row-reverse;
}
.wflow-widget--left .wflow-bubble-wrap { flex-direction: row; }

.wflow-bubble-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25), 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
    position: relative;
    z-index: 2;
}
.wflow-bubble-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0,0,0,0.3), 0 3px 12px rgba(0,0,0,0.2);
}
.wflow-bubble-btn:active { transform: scale(0.95); }

/* Pulse ring */
.wflow-bubble-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0;
    animation: wflowPulse 2s ease-out infinite;
}

@keyframes wflowPulse {
    0% { transform: scale(0.8); opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

.wflow-bubble-tooltip {
    background: #fff;
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    white-space: nowrap;
    animation: wflowSlideIn 0.4s ease-out;
    cursor: pointer;
}

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

/* WhatsApp mini button */
.wflow-wa-mini {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(37, 211, 102, 0.4);
    text-decoration: none;
    transition: transform 0.3s;
    position: relative;
    z-index: 2;
}
.wflow-wa-mini:hover { transform: scale(1.1); color: #fff; }

/* ========= Chat Panel ========= */
.wflow-chat-panel {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-height: 580px;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15), 0 2px 12px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    animation: wflowPanelIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.wflow-widget--right .wflow-chat-panel { right: 0; }
.wflow-widget--left  .wflow-chat-panel { left: 0; }

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

@media (max-width: 420px) {
    .wflow-chat-panel {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 120px);
        bottom: 72px;
    }
    .wflow-widget { bottom: 12px; right: 12px !important; left: auto !important; }
}

/* ========= Header ========= */
.wflow-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    color: #fff;
    flex-shrink: 0;
}
.wflow-chat-header__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.wflow-chat-header__info { flex: 1; min-width: 0; }
.wflow-chat-header__name {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wflow-chat-header__status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wflow-online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: wflowOnline 2s ease-in-out infinite;
}
@keyframes wflowOnline {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.wflow-chat-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.wflow-chat-close:hover { background: rgba(255,255,255,0.3); }

/* ========= Messages ========= */
.wflow-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f4ee;
    min-height: 280px;
    max-height: 360px;
}
.wflow-chat-messages::-webkit-scrollbar { width: 5px; }
.wflow-chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }

.wflow-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    animation: wflowMsgIn 0.3s ease-out;
}
.wflow-msg--user { flex-direction: row-reverse; }

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

.wflow-msg__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e8e0d4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.wflow-msg--user .wflow-msg__avatar {
    background: #dbeafe;
}

.wflow-msg__bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.wflow-msg--bot .wflow-msg__bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.wflow-msg--user .wflow-msg__bubble {
    background: #1e3f2a;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.wflow-msg__time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
}
.wflow-msg--user .wflow-msg__time { text-align: right; }

/* Typing indicator */
.wflow-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    width: fit-content;
}
.wflow-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: wflowDotPulse 1.4s ease-in-out infinite;
}
.wflow-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.wflow-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes wflowDotPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* ========= Quick Chips ========= */
.wflow-quick-chips {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    overflow-x: auto;
    background: #f7f4ee;
    border-top: 1px solid #ebe5d9;
    flex-shrink: 0;
}
.wflow-quick-chips::-webkit-scrollbar { display: none; }

.wflow-chip {
    background: #fff;
    border: 1px solid #d4c5a9;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #5e3c26;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}
.wflow-chip:hover {
    background: #1e3f2a;
    color: #fff;
    border-color: #1e3f2a;
}

/* ========= Input ========= */
.wflow-chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #ebe5d9;
    background: #fff;
    flex-shrink: 0;
}
.wflow-chat-input input {
    flex: 1;
    border: 1px solid #e0d6c8;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
.wflow-chat-input input:focus {
    border-color: #1e3f2a;
}

.wflow-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}
.wflow-send-btn:hover { transform: scale(1.08); }
.wflow-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========= Footer ========= */
.wflow-chat-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #faf6f0;
    border-top: 1px solid #ebe5d9;
    flex-shrink: 0;
}
.wflow-footer-wa {
    display: flex;
    align-items: center;
    color: #25D366;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}
.wflow-footer-wa:hover { opacity: 0.8; color: #25D366; }

.wflow-powered {
    font-size: 11px;
    color: #aaa;
}

/* ========= Animations for open/close ========= */
/* ========= Open/close icon swap ========= */
.wflow-widget.wflow-open .wflow-bubble-tooltip { display: none; }
.wflow-widget.wflow-open .wflow-icon-chat { display: none; }
.wflow-widget.wflow-open .wflow-icon-close { display: block !important; }

/* ========= Product card in chat ========= */
.wflow-product-card {
    margin: 8px 0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.wflow-chat-img {
    width: 100%;
    max-width: 280px;
    height: auto;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    display: block;
}
.wflow-chat-img:hover { transform: scale(1.02); }

/* ========= Chat links ========= */
.wflow-chat-link {
    color: #1e3f2a;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(30, 63, 42, 0.3);
    transition: all 0.2s;
    word-break: break-word;
}
.wflow-chat-link:hover {
    color: #c4613a;
    text-decoration-color: #c4613a;
}

/* ========= Chat bullets ========= */
.wflow-bullet {
    display: block;
    padding: 1px 0 1px 4px;
}

/* ========= Action buttons in chat ========= */
.wflow-btn {
    display: inline-block;
    padding: 7px 16px;
    margin: 4px 4px 4px 0;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none !important;
    transition: all 0.2s;
    cursor: pointer;
    line-height: 1.3;
}
.wflow-btn:hover { opacity: 0.9; transform: translateY(-1px); }

.wflow-btn--order {
    background: #1e3f2a;
    color: #fff !important;
    border: none;
}
.wflow-btn--order:hover { background: #2d5a3d; }

.wflow-btn--checkout {
    background: #c4613a;
    color: #fff !important;
}
.wflow-btn--checkout:hover { background: #a84d29; }

.wflow-btn--wa {
    background: #25D366;
    color: #fff !important;
}
.wflow-btn--wa:hover { background: #1fad54; }
