/**
 * SleepUp AI Assistant - Frontend Widget CSS
 * Isolated BEM naming: su-ai-*
 */

:root {
    --su-ai-primary: #1B365D;
    --su-ai-secondary: #3498DB;
    --su-ai-bg: #FFFFFF;
    --su-ai-text: #2C3E50;
    --su-ai-bubble-user-bg: #1B365D;
    --su-ai-bubble-user-text: #FFFFFF;
    --su-ai-bubble-ai-bg: #F4F7FA;
    --su-ai-bubble-ai-text: #2C3E50;
    --su-ai-border: #E2E8F0;
    --su-ai-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    --su-ai-radius: 16px;
    --su-ai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.su-ai-widget-container {
    position: fixed;
    bottom: 24px;
    z-index: 999990;
    font-family: var(--su-ai-font);
    box-sizing: border-box;
}

.su-ai-widget-container * {
    box-sizing: border-box;
}

.su-pos-right {
    right: 24px;
}

.su-pos-left {
    left: 24px;
}

/* Floating Launcher Button */
.su-ai-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--su-ai-primary);
    color: #FFFFFF;
    border: none;
    box-shadow: 0 4px 16px rgba(27, 54, 93, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
    outline: none;
}

.su-ai-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(27, 54, 93, 0.45);
}

.su-ai-launcher:focus-visible {
    outline: 3px solid var(--su-ai-secondary);
    outline-offset: 2px;
}

.su-ai-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #E74C3C;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FFFFFF;
}

/* Chatbox Window */
.su-ai-chatbox {
    position: absolute;
    bottom: 74px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: var(--su-ai-bg);
    border-radius: var(--su-ai-radius);
    box-shadow: var(--su-ai-shadow);
    border: 1px solid var(--su-ai-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: suAiSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.su-pos-right .su-ai-chatbox {
    right: 0;
}

.su-pos-left .su-ai-chatbox {
    left: 0;
}

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

/* Chat Header */
.su-ai-header {
    background: var(--su-ai-primary);
    color: #FFFFFF;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.su-ai-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.su-ai-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #2ECC71;
    border-radius: 50%;
    border: 2px solid var(--su-ai-primary);
}

.su-ai-header-name {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #FFFFFF !important;
    line-height: 1.2;
}

.su-ai-header-role {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    display: block;
}

.su-ai-header-actions {
    display: flex;
    gap: 8px;
}

.su-ai-header-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.su-ai-header-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #FFFFFF;
}

/* Messages Feed */
.su-ai-messages {
    flex: 1;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    background: #FAFCFE;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.su-ai-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 86%;
}

.su-ai-msg-row.su-ai-user {
    align-self: flex-end;
}

.su-ai-msg-row.su-ai-bot {
    align-self: flex-start;
}

.su-ai-msg-bubble {
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.5;
    border-radius: 16px;
    word-break: break-word;
}

.su-ai-msg-row.su-ai-user .su-ai-msg-bubble {
    background: var(--su-ai-bubble-user-bg);
    color: var(--su-ai-bubble-user-text);
    border-bottom-right-radius: 4px;
}

.su-ai-msg-row.su-ai-bot .su-ai-msg-bubble {
    background: var(--su-ai-bubble-ai-bg);
    color: var(--su-ai-bubble-ai-text);
    border: 1px solid var(--su-ai-border);
    border-bottom-left-radius: 4px;
}

.su-ai-msg-time {
    font-size: 10px;
    color: #94A3B8;
    margin-top: 4px;
    padding: 0 4px;
}

.su-ai-msg-row.su-ai-user .su-ai-msg-time {
    text-align: right;
}

/* Typing Indicator */
.su-ai-typing {
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #FAFCFE;
}

.su-ai-typing-dots {
    display: flex;
    gap: 4px;
}

.su-ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: #94A3B8;
    border-radius: 50%;
    animation: suAiPulse 1.2s infinite ease-in-out;
}

.su-ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.su-ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

.su-ai-typing-text {
    font-size: 11px;
    color: #94A3B8;
    font-style: italic;
}

/* Quick Suggestion Chips */
.su-ai-chips {
    padding: 8px 12px;
    background: #FAFCFE;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    max-height: 120px;
    overflow-y: auto;
    flex-shrink: 0;
    border-top: 1px solid var(--su-ai-border);
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.su-ai-chips::-webkit-scrollbar {
    width: 4px;
}

.su-ai-chips::-webkit-scrollbar-track {
    background: transparent;
}

.su-ai-chips::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

.su-ai-chips-title {
    width: 100%;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94A3B8;
    margin-bottom: 2px;
    user-select: none;
    display: block;
}

.su-ai-chip {
    background: #FFFFFF;
    color: var(--su-ai-primary);
    border: 1px solid #CBD5E1;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    line-height: 1.3;
}

.su-ai-chip:hover {
    background: var(--su-ai-primary);
    color: #FFFFFF;
    border-color: var(--su-ai-primary);
}

/* Input Form */
.su-ai-form {
    padding: 12px 14px;
    background: #FFFFFF;
    border-top: 1px solid var(--su-ai-border);
}

.su-ai-input-wrap {
    display: flex;
    align-items: center;
    background: #F1F5F9;
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    border: 1px solid transparent;
    transition: border 0.2s ease, background 0.2s ease;
}

.su-ai-input-wrap:focus-within {
    border-color: var(--su-ai-secondary);
    background: #FFFFFF;
}

.su-ai-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13.5px;
    color: #1E293B;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 80px;
}

.su-ai-btn-send {
    background: var(--su-ai-primary);
    color: #FFFFFF;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

.su-ai-btn-send:hover {
    background: var(--su-ai-secondary);
    transform: scale(1.05);
}

.su-ai-disclaimer {
    margin-top: 6px;
    text-align: center;
    font-size: 10px;
    color: #94A3B8;
}

/* Interactive Cards inside Chat */
/* Order Card */
.su-ai-order-card {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    padding: 14px;
    margin-top: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.su-ai-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #E2E8F0;
}

.su-ai-order-num {
    font-weight: 700;
    font-size: 14px;
    color: var(--su-ai-primary);
}

.su-ai-order-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info { background: #DBEAFE; color: #1E40AF; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-secondary { background: #F1F5F9; color: #475569; }

.su-ai-order-desc {
    font-size: 12px;
    color: #475569;
    margin-bottom: 8px;
}

.su-ai-order-items {
    font-size: 11.5px;
    color: #64748B;
    margin-bottom: 8px;
    list-style: none;
    padding: 0;
}

.su-ai-order-items li {
    padding: 2px 0;
}

.su-ai-order-total {
    font-size: 13px;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 10px;
}

.su-ai-order-tracking {
    background: #F8FAFC;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11px;
    margin-bottom: 10px;
    border-left: 3px solid var(--su-ai-secondary);
}

.su-ai-card-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: var(--su-ai-primary);
    color: #FFFFFF !important;
    text-decoration: none !important;
    padding: 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s ease;
}

.su-ai-card-btn:hover {
    background: var(--su-ai-secondary);
}

/* Product Recommendation Card */
.su-ai-product-card {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.su-ai-product-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.su-ai-product-info {
    flex: 1;
}

.su-ai-product-title {
    font-size: 13px;
    font-weight: 600;
    color: #1E293B;
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.su-ai-product-price {
    font-size: 13px;
    font-weight: 700;
    color: #10B981;
    margin-bottom: 6px;
}

.su-ai-product-btn {
    display: inline-block;
    padding: 4px 10px;
    background: var(--su-ai-primary);
    color: #FFFFFF !important;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none !important;
}

/* WhatsApp Card */
.su-ai-wa-card {
    background: #F0FDF4;
    border: 1px solid #86EFAC;
    border-radius: 12px;
    padding: 14px;
    margin-top: 8px;
    text-align: center;
}

.su-ai-wa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: #FFFFFF !important;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 24px;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
    margin-top: 8px;
    transition: transform 0.15s ease, background 0.15s ease;
}

.su-ai-wa-btn:hover {
    background: #20BD5A;
    transform: translateY(-2px);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .su-ai-widget-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
    }

    .su-ai-chatbox {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}

/* Accessibility Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .su-ai-launcher,
    .su-ai-chatbox,
    .su-ai-typing-dots span {
        animation: none !important;
        transition: none !important;
    }
}
