/* 
   LifeSport Assistant - Grandmaster UI 
   Design System: Glassmorphism, Neumorphism, Apple Human Interface Guidelines 
*/

:root {
    --sa-primary: #FF2D2D;
    /* Vibrant Red */
    --sa-primary-dark: #D91B1B;
    --sa-bg-glass: rgba(255, 255, 255, 0.85);
    /* Glass effect */
    --sa-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
    --sa-shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
    --sa-text-main: #1F2937;
    --sa-text-light: #6B7280;
    --sa-radius-xl: 20px;
    --sa-radius-lg: 16px;
    --sa-font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Container */
.sa-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: var(--sa-font-family);
}

/* Launcher Button (Neumorphic Pulse) */
.sa-launcher {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--sa-primary);
    box-shadow: 0 10px 25px rgba(255, 45, 45, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.sa-launcher:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 15px 35px rgba(255, 45, 45, 0.5);
}

.sa-launcher::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.5s ease;
}

.sa-launcher:active::after {
    opacity: 1;
    transform: scale(1);
}

.sa-launcher-icon {
    width: 32px;
    height: 32px;
    fill: white;
    z-index: 2;
}

/* Main Chat Window (Glassmorphism) */
.sa-chat-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 380px;
    height: 650px;
    max-height: 80vh;
    background: var(--sa-bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--sa-radius-xl);
    box-shadow: var(--sa-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    transform-origin: bottom right;
}

.sa-chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.sa-header {
    padding: 18px 20px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sa-header-title {
    font-weight: 700;
    font-size: 17px;
    color: var(--sa-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sa-header-title svg {
    color: var(--sa-primary);
    filter: drop-shadow(0 2px 4px rgba(255, 45, 45, 0.2));
}

.sa-header-close {
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--sa-text-light);
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
}

.sa-header-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--sa-text-main);
}

.sa-header-clear {
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--sa-text-light);
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.sa-header-clear:hover {
    background: rgba(255, 45, 45, 0.1);
    color: var(--sa-primary);
    opacity: 1;
}

/* Chat Area */
.sa-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Messages */
.sa-message {
    max-width: 85%;
    padding: 12px 18px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    animation: sa-slide-up 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    letter-spacing: 0.01em;
}

/* Assistant Bubble */
.sa-message-assistant {
    align-self: flex-start;
    background: white;
    color: var(--sa-text-main);
    border-radius: var(--sa-radius-lg) var(--sa-radius-lg) var(--sa-radius-lg) 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* User Bubble */
.sa-message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--sa-primary) 0%, var(--sa-primary-dark) 100%);
    color: white;
    border-radius: var(--sa-radius-lg) var(--sa-radius-lg) 4px var(--sa-radius-lg);
    box-shadow: 0 4px 12px rgba(255, 45, 45, 0.25);
}

.sa-message-user a {
    color: white;
    text-decoration: underline;
}

/* Typing Indicator */
.sa-typing-indicator {
    padding: 14px 20px;
    background: white;
    border-radius: var(--sa-radius-lg);
    align-self: flex-start;
    display: flex;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 8px;
}

.sa-dot {
    width: 8px;
    height: 8px;
    background: #D1D5DB;
    border-radius: 50%;
    animation: sa-bounce 1.4s infinite ease-in-out both;
}

.sa-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.sa-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Suggestion Chips (Horizontal Scroll) */
.sa-suggestions {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 20px 20px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sa-suggestions::-webkit-scrollbar {
    display: none;
}

.sa-suggestion-chip {
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sa-text-main);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    animation: sa-fade-in 0.3s ease-out forwards;
}

.sa-suggestion-chip:hover {
    transform: translateY(-2px);
    background: #FFF5F5;
    border-color: #FECACA;
    color: var(--sa-primary);
    box-shadow: 0 4px 8px rgba(255, 45, 45, 0.15);
}

/* Input Area */
.sa-input-area {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 12px;
    align-items: center;
}

.sa-input {
    flex: 1;
    border: 2px solid #F3F4F6;
    background: #F9FAFB;
    border-radius: 24px;
    padding: 10px 20px;
    outline: none;
    font-size: 15px;
    color: var(--sa-text-main);
    transition: all 0.2s ease;
}

.sa-input::placeholder {
    color: #9CA3AF;
}

.sa-input:focus {
    border-color: var(--sa-primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(255, 45, 45, 0.1);
}

.sa-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--sa-primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(255, 45, 45, 0.2);
}

.sa-send-btn:hover {
    transform: scale(1.05);
    background: var(--sa-primary-dark);
}

.sa-send-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5px;
}

/* Product List (Vertical - Grandmaster Polish) */
.sa-products-grid {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    gap: 10px;
    width: 100%;
    max-width: 100%;
}

.sa-product-card {
    width: 100%;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 14px;
    padding: 8px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    /* Smooth interactions */
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    /* Minimal shadow */
    position: relative;
    overflow: hidden;
}

.sa-product-card:hover {
    transform: translateY(-1px);
    background: #FFFAFA;
    /* Very subtle tint */
    border-color: rgba(255, 45, 45, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    /* Soft elevation */
}

/* Image on the left */
.sa-product-image {
    width: 64px;
    height: 64px;
    min-width: 64px;
    object-fit: contain;
    border-radius: 10px;
    background: white;
    padding: 2px;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.sa-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    text-align: left;
    min-width: 0;
}

.sa-product-brand {
    font-size: 11px;
    color: #9CA3AF;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.sa-product-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--sa-text-main);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.sa-product-price {
    font-weight: 700;
    color: var(--sa-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.sa-product-price .old-price {
    text-decoration: line-through;
    color: #D1D5DB;
    font-size: 11px;
    font-weight: 400;
}

.sa-product-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.sa-product-actions button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #F9FAFB;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    line-height: 1;
}

.sa-btn-view:hover {
    background: #EFF6FF;
    border-color: #93C5FD;
    transform: scale(1.08);
}

.sa-btn-cart:hover {
    background: #FEF2F2;
    border-color: var(--sa-primary);
    transform: scale(1.08);
}

.sa-chip-cart {
    background: var(--sa-primary) !important;
    color: white !important;
    border-color: var(--sa-primary) !important;
}

.sa-chip-cart:hover {
    background: var(--sa-primary-dark) !important;
    color: white !important;
}

.sa-currency {
    font-size: 0.8em;
    font-weight: 500;
}

.sa-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1F2937;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--sa-font-family);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
}

.sa-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Animations */
@keyframes sa-slide-up {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sa-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes sa-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .sa-chat-window {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    .sa-widget-container {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
    }

    .sa-launcher {
        pointer-events: all;
        position: absolute;
        bottom: 20px;
        right: 20px;
    }

    .sa-chat-window.active {
        pointer-events: all;
    }
}

/* ─── Store Cards ─── */
.sa-stores-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 12px;
    width: 100%;
}

.sa-store-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.sa-store-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.sa-store-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.sa-store-info {
    padding: 10px 12px 6px;
}

.sa-store-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--sa-text-main);
    margin-bottom: 4px;
    line-height: 1.3;
}

.sa-store-address {
    font-size: 11px;
    color: var(--sa-text-light);
    margin-bottom: 6px;
    line-height: 1.4;
}

.sa-store-distance {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.sa-distance-badge {
    background: #059669;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.sa-distance-time {
    font-size: 10px;
    color: var(--sa-text-light);
}

.sa-store-meta {
    display: flex;
    gap: 12px;
    font-size: 10px;
    color: var(--sa-text-light);
    margin-bottom: 2px;
}

.sa-store-actions {
    display: flex;
    border-top: 1px solid #f3f4f6;
}

.sa-store-actions a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease;
}

.sa-btn-call {
    color: #059669;
    border-right: 1px solid #f3f4f6;
}

.sa-btn-call:hover {
    background: #ecfdf5;
}

.sa-btn-route {
    color: var(--sa-primary);
}

.sa-btn-route:hover {
    background: #fef2f2;
}

/* ─── Multi-Modal UI (Voice & Vision) ─── */
.sa-attach-btn, .sa-mic-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--sa-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sa-attach-btn:hover, .sa-mic-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--sa-primary);
}

.sa-mic-btn.recording {
    color: #ef4444;
    background: #fee2e2;
    animation: sa-pulse-record 1.5s infinite running;
}

.sa-media-preview-area {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

#sa-image-preview {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.sa-remove-image {
    position: absolute;
    top: 5px;
    left: 60px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sa-recording-indicator {
    padding: 10px 20px;
    background: #fee2e2;
    color: #ef4444;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sa-pulse {
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    animation: sa-pulse-record 1.5s infinite;
}

@keyframes sa-pulse-record {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}