/* ==========================================================================
   Almotawa Smart Assistant - Premium Stylesheet (v3.0)
   Developed by O2 Nations | 100% Scoped & Zero External Dependencies
   ========================================================================== */

#almotawa-smart-assistant-root {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    direction: rtl !important;
    text-align: right !important;
    box-sizing: border-box !important;
    position: fixed !important;
    bottom: 24px !important;
    z-index: 999999 !important;
    --primary: #008744;
    --primary-dark: #006834;
    --primary-light: #e6f7ee;
    --primary-glow: rgba(0, 135, 68, 0.25);
    --accent: #f59e0b;
    --accent-warm: #ff6b35;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --bg-light: #f8fafc;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --gold: #d4a017;
}

#almotawa-smart-assistant-root.almotawa-sa-pos-left {
    left: 24px !important;
    right: auto !important;
}

#almotawa-smart-assistant-root.almotawa-sa-pos-right {
    right: 24px !important;
    left: auto !important;
}

#almotawa-smart-assistant-root * {
    box-sizing: border-box !important;
    font-family: inherit !important;
}

/* ==========================================================================
   Launcher / Trigger Button - Premium Floating CTA
   ========================================================================== */

.almotawa-sa-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #00b35a 0%, #008744 40%, #006834 100%);
    color: #ffffff;
    padding: 12px 20px 12px 16px;
    border-radius: 60px;
    box-shadow: 
        0 14px 34px rgba(0, 135, 68, 0.42),
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255,255,255,0.2);
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.25);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    position: relative;
    backdrop-filter: blur(4px);
}

.almotawa-sa-trigger:hover {
    transform: translateY(-5px) scale(1.04);
    box-shadow: 
        0 20px 40px rgba(0, 135, 68, 0.5),
        0 8px 18px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.almotawa-sa-trigger-icon {
    width: 48px;
    height: 48px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #008744;
    font-size: 26px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    position: relative;
}

.almotawa-sa-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(0, 180, 90, 0.45);
    animation: almotawa-pulse 2s infinite;
    z-index: -1;
}

@keyframes almotawa-pulse {
    0% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.45); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

.almotawa-sa-trigger-text {
    display: flex;
    flex-direction: column;
}

.almotawa-sa-trigger-title {
    font-weight: 800;
    font-size: 15.5px;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.almotawa-sa-trigger-sub {
    font-size: 11.5px;
    opacity: 0.92;
    font-weight: 500;
    margin-top: 2px;
}

/* Tooltip on Launcher */
.almotawa-sa-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    background: #ffffff;
    color: #0f172a;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
    border: 1px solid #e2e8f0;
    animation: almotawa-float 3s ease-in-out infinite;
    display: flex;
    align-items: center;
    gap: 8px;
}

.almotawa-sa-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    transform: rotate(45deg);
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

@keyframes almotawa-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ==========================================================================
   Chat Modal Window - Premium Glass
   ========================================================================== */

.almotawa-sa-window {
    width: 420px;
    height: 650px;
    max-height: calc(100vh - 90px);
    background: #ffffff;
    border-radius: 26px;
    box-shadow: 
        0 30px 70px -15px rgba(0, 0, 0, 0.25),
        0 0 1px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(226, 232, 240, 0.85);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom left;
    animation: almotawa-pop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#almotawa-smart-assistant-root.almotawa-sa-pos-right .almotawa-sa-window {
    transform-origin: bottom right;
}

@keyframes almotawa-pop {
    0% { opacity: 0; transform: scale(0.82) translateY(24px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.almotawa-sa-hidden {
    display: none !important;
}

/* Header - Rich Gradient */
.almotawa-sa-header {
    background: linear-gradient(135deg, #00a651 0%, #008744 45%, #005a2d 100%);
    color: #ffffff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 6px 20px rgba(0, 90, 45, 0.2);
    position: relative;
    z-index: 10;
}

/* subtle pattern overlay on header */
.almotawa-sa-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.almotawa-sa-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 2;
}

.almotawa-sa-header-avatar {
    width: 46px;
    height: 46px;
    background: #ffffff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    color: #008744;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
    position: relative;
}

.almotawa-sa-online-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 13px;
    height: 13px;
    background: #22c55e;
    border-radius: 50%;
    border: 2.5px solid #ffffff;
    animation: almotawa-online-blink 2.5s infinite;
}

@keyframes almotawa-online-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.almotawa-sa-header-title {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.almotawa-sa-header-sub {
    font-size: 11.5px;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
}

.almotawa-sa-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 2;
}

.almotawa-sa-btn-icon {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #ffffff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.25s;
    backdrop-filter: blur(4px);
}

.almotawa-sa-btn-icon:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
}

/* ==========================================================================
   Chat Messages Body
   ========================================================================== */

.almotawa-sa-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 10px 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.almotawa-sa-body::-webkit-scrollbar {
    width: 5px;
}
.almotawa-sa-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Welcome Card - Premium */
.almotawa-sa-welcome-card {
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    padding: 18px 16px;
    border-radius: 20px;
    border: 1px solid #d1fae5;
    box-shadow: 0 6px 20px rgba(0, 135, 68, 0.06);
    text-align: center;
    margin-bottom: 6px;
    position: relative;
    overflow: hidden;
}

.almotawa-sa-welcome-card::before {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(0,135,68,0.07) 0%, transparent 70%);
    border-radius: 50%;
}

.almotawa-sa-welcome-badge {
    display: inline-block;
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #008744;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 10px;
    border: 1px solid rgba(0, 135, 68, 0.12);
}

.almotawa-sa-welcome-text {
    font-size: 13.5px;
    color: #334155;
    line-height: 1.6;
    font-weight: 500;
}

/* Quick Suggestion Chips - Enhanced */
.almotawa-sa-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    justify-content: center;
}

.almotawa-sa-chip {
    background: #ffffff;
    color: #0f172a;
    border: 1.5px solid #e2e8f0;
    padding: 8px 14px;
    border-radius: 22px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.almotawa-sa-chip:hover {
    background: linear-gradient(135deg, #00b35a 0%, #008744 100%);
    color: #ffffff;
    border-color: #008744;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 16px rgba(0, 135, 68, 0.28);
}

/* Message Rows */
.almotawa-sa-msg-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: almotawa-msg-fade 0.35s ease-out;
}

@keyframes almotawa-msg-fade {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.almotawa-sa-msg-user {
    justify-content: flex-start;
    flex-direction: row-reverse;
}

.almotawa-sa-msg-bubble {
    max-width: 82%;
    padding: 13px 16px;
    border-radius: 20px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
}

.almotawa-sa-msg-user .almotawa-sa-msg-bubble {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    border-bottom-left-radius: 6px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.almotawa-sa-msg-bot .almotawa-sa-msg-bubble {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.almotawa-sa-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 5px;
    text-align: left;
}

/* ==========================================================================
   Product Cards - Premium E-Commerce Design
   ========================================================================== */

.almotawa-sa-products-container {
    margin-top: 12px;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 6px 4px 16px 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.almotawa-sa-products-container::-webkit-scrollbar {
    height: 5px;
}
.almotawa-sa-products-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.almotawa-sa-products-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.almotawa-sa-product-card {
    min-width: 230px;
    max-width: 230px;
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.almotawa-sa-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 35px rgba(0, 135, 68, 0.14);
    border-color: #00a651;
}

.almotawa-sa-product-img-wrap {
    position: relative;
    width: 100%;
    height: 150px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.almotawa-sa-product-img {
    max-width: 88%;
    max-height: 88%;
    object-fit: contain;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.06));
}

.almotawa-sa-product-card:hover .almotawa-sa-product-img {
    transform: scale(1.1);
}

.almotawa-sa-badge-discount {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #ff4444 0%, #dc2626 100%);
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(220, 38, 38, 0.4);
    letter-spacing: -0.2px;
    z-index: 2;
}

/* Premium "Best Seller" badge */
.almotawa-sa-badge-hot {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    font-size: 9.5px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    z-index: 2;
}

.almotawa-sa-product-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.almotawa-sa-product-cat {
    font-size: 10.5px;
    color: #008744;
    font-weight: 800;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.almotawa-sa-product-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
    height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
}

.almotawa-sa-product-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}

.almotawa-sa-spec-tag {
    background: #f1f5f9;
    color: #475569;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.almotawa-sa-product-price-box {
    margin-top: auto;
    margin-bottom: 12px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.almotawa-sa-product-price {
    font-size: 17px;
    font-weight: 900;
    color: #008744;
    letter-spacing: -0.3px;
}

.almotawa-sa-product-regular-price {
    font-size: 12px;
    color: #94a3b8;
    text-decoration: line-through;
}

.almotawa-sa-product-actions {
    display: flex;
    gap: 8px;
}

.almotawa-sa-btn-cart {
    flex: 1;
    background: linear-gradient(135deg, #00b35a 0%, #008744 50%, #006834 100%);
    color: #ffffff;
    border: none;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 12.5px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(0, 135, 68, 0.2);
    position: relative;
    overflow: hidden;
}

.almotawa-sa-btn-cart::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.almotawa-sa-btn-cart:hover::before {
    left: 100%;
}

.almotawa-sa-btn-cart:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 135, 68, 0.35);
}

.almotawa-sa-btn-cart.almotawa-sa-added {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

.almotawa-sa-btn-details {
    background: #f1f5f9;
    color: #334155;
    border: 1.5px solid #e2e8f0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 15px;
    transition: all 0.25s;
}

.almotawa-sa-btn-details:hover {
    background: #e2e8f0;
    color: #008744;
    border-color: #008744;
    transform: scale(1.08);
}

/* Typing Indicator - Smoother */
.almotawa-sa-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    width: fit-content;
    box-shadow: 0 3px 10px rgba(0,0,0,0.04);
}

.almotawa-sa-typing-dot {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #00b35a, #008744);
    border-radius: 50%;
    animation: almotawa-wave 1.4s infinite ease-in-out both;
}

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

@keyframes almotawa-wave {
    0%, 80%, 100% { transform: scale(0.55); opacity: 0.35; }
    40% { transform: scale(1.15); opacity: 1; }
}

/* ==========================================================================
   Input & Footer Area - Premium
   ========================================================================== */

.almotawa-sa-footer {
    padding: 14px 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.almotawa-sa-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 50px;
    padding: 4px 6px 4px 16px;
    transition: all 0.3s;
}

.almotawa-sa-input-row:focus-within {
    border-color: #008744;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 135, 68, 0.1);
}

.almotawa-sa-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13.5px;
    padding: 10px 0;
    color: #0f172a;
    outline: none;
}

.almotawa-sa-btn-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #00b35a 0%, #008744 50%, #006834 100%);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 17px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 135, 68, 0.25);
}

.almotawa-sa-btn-send:hover:not(:disabled) {
    transform: scale(1.12);
    box-shadow: 0 6px 18px rgba(0, 135, 68, 0.4);
}

.almotawa-sa-btn-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
}

.almotawa-sa-brand-tag {
    text-align: center;
    font-size: 10.5px;
    color: #94a3b8;
    margin-top: 8px;
    font-weight: 500;
}

.almotawa-sa-brand-tag a {
    color: #008744;
    text-decoration: none;
    font-weight: 700;
}

.almotawa-sa-brand-tag a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */

@media (max-width: 480px) {
    #almotawa-smart-assistant-root {
        bottom: 14px !important;
        left: 10px !important;
        right: 10px !important;
    }

    .almotawa-sa-trigger {
        padding: 10px 16px 10px 12px;
    }

    .almotawa-sa-trigger-icon {
        width: 42px;
        height: 42px;
    }

    .almotawa-sa-window {
        width: 100% !important;
        height: calc(100vh - 30px) !important;
        max-height: 680px !important;
        border-radius: 22px !important;
    }

    .almotawa-sa-product-card {
        min-width: 200px;
        max-width: 200px;
    }

    .almotawa-sa-product-img-wrap {
        height: 130px;
    }
}

/* ==========================================================================
   Stars Rating (for future use)
   ========================================================================== */
.almotawa-sa-stars {
    display: flex;
    gap: 1px;
    margin-bottom: 4px;
}

.almotawa-sa-star {
    color: #f59e0b;
    font-size: 11px;
}
