/* ========================================
   Chatbot Widget Styles
   ======================================== */

/* Widget Container */
.chatbot-widget {
    position: fixed;
    bottom: 20px;
    z-index: 1001;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.chatbot-widget[data-position="right"] {
    right: 20px;
}

.chatbot-widget[data-position="left"] {
    left: 20px;
}

/* Welcome Popup */
.chatbot-welcome-popup {
    position: absolute;
    bottom: 0;
    background: linear-gradient(135deg, #f8f0e5 0%, #eaddcc 100%);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 20px;
    max-width: 380px;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.chatbot-welcome-content {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
}

/* RTL text alignment */
[dir="rtl"] .chatbot-welcome-content {
    text-align: right;
}

/* Position and animation for RTL (Arabic) - popup appears to the LEFT of button */
.chatbot-widget[data-position="right"] .chatbot-welcome-popup {
    right: 90px; /* Position to the left of the button */
    transform: translateX(30px) scale(0.9);
}

.chatbot-widget[data-position="right"] .chatbot-welcome-popup.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.chatbot-widget[data-position="right"] .chatbot-welcome-popup.hide {
    opacity: 0;
    transform: translateX(30px) scale(0.9);
}

/* Position and animation for LTR (English) - popup appears to the RIGHT of button */
.chatbot-widget[data-position="left"] .chatbot-welcome-popup {
    left: 90px; /* Position to the right of the button */
    transform: translateX(-30px) scale(0.9);
}

.chatbot-widget[data-position="left"] .chatbot-welcome-popup.show {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.chatbot-widget[data-position="left"] .chatbot-welcome-popup.hide {
    opacity: 0;
    transform: translateX(-30px) scale(0.9);
}

.chatbot-welcome-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    transition: all 0.3s;
}

.chatbot-welcome-close:hover {
    background: #f0f0f0;
    color: #333;
}

.chatbot-welcome-avatar {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
   background: linear-gradient(135deg, #f8f0e5 0%, #e8d8c3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.chatbot-welcome-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-welcome-avatar i {
    font-size: 28px;
    color: white;
}

.chatbot-welcome-text {
    flex: 1;
    min-width: 0;
}

.chatbot-welcome-popup h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.chatbot-welcome-popup p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.chatbot-welcome-button {
    background: linear-gradient(135deg, #f8f0e5 0%, #eaddcc 100%);
    color: black;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chatbot-welcome-button:hover {
    transform: translateY(-2px);
}

.chatbot-welcome-button i {
    font-size: 12px;
}

/* Chat Bubble */
.chatbot-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
   background: linear-gradient(135deg, #f8f0e5 0%, #e8d8c3 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
}

.chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.chatbot-bubble:active {
    transform: scale(0.95);
}

.chatbot-bubble.has-notification::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse-notification 2s infinite;
}

@keyframes pulse-notification {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.chatbot-bubble-avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.chatbot-bubble-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-bubble-avatar i {
    font-size: 28px;
    color: white;
}

.chatbot-bubble-close {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    background: #f8f0e5; 
    border-radius: 4px; 
}

.chatbot-bubble-close i {
    font-size: 24px;
    color: #e74c3c; 
    transition: color 0.3s;
}

.chatbot-bubble-close:hover i {
    color: #d35400; 
}

.chatbot-bubble.active .chatbot-bubble-avatar {
    opacity: 0;
}

.chatbot-bubble.active .chatbot-bubble-close {
    opacity: 1;
}


/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* RTL (Arabic): Window positioned on right, slides from right */
html[dir="rtl"] .chatbot-window {
    right: 0;
    left: auto;
    animation: chatWindowSlideFromRight 0.3s ease-in-out;
}

/* LTR (English): Window positioned on left, slides from left */
html[dir="ltr"] .chatbot-window {
    left: 0;
    right: auto;
    animation: chatWindowSlideFromLeft 0.3s ease-in-out;
}

/* Animation: Slides IN from right (for RTL/Arabic) */
@keyframes chatWindowSlideFromRight {
    from {
        right: -100%;
        opacity: 0;
    }
    to {
        right: 0;
        opacity: 1;
    }
}

/* Animation: Slides IN from left (for LTR/English) */
@keyframes chatWindowSlideFromLeft {
    from {
        left: -100%;
        opacity: 0;
    }
    to {
        left: 0;
        opacity: 1;
    }
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #f8f0e5 0%, #eaddcc 100%);
    color: #3e2f22;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}


.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-header-avatar i {
    font-size: 22px;
    color: white;
}

.chatbot-header-text h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chatbot-header-close {
    background: rgba(248, 240, 229, 0.5);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    color: #3e2f22; 
    font-size: 18px;
}

.chatbot-header-close:hover {
    background: rgba(224, 201, 166, 0.6); 


    transform: rotate(90deg);
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
background: #f8f0e5;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.chatbot-message {
    display: flex;
    gap: 10px;
	background:#f8f0e5;
    margin-bottom: 15px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.chatbot-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
   background: linear-gradient(135deg, #f8f0e5 0%, #e8d8c3 100%);
    overflow: hidden;
}

.chatbot-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbot-message-avatar i {
    font-size: 16px;
    color: white;
}

.chatbot-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 75%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.chatbot-message.user {
    flex-direction: row-reverse;
}

.chatbot-message.user .chatbot-message-avatar {
    background: linear-gradient(135deg, var(--accent-color, #e74c3c) 0%, #c0392b 100%);
}

.chatbot-message.user .chatbot-message-bubble {
    background: linear-gradient(135deg, #eeb69a 0%, #e5a876 100%);
    color: black;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot .chatbot-message-bubble {
    background: #F8F0E5; 
    color: #3e2f22; 
    border: 1px solid rgba(224, 201, 166, 0.4); 
    border-bottom-left-radius: 4px;
}


/* System Message */
.chatbot-system-message {
    text-align: center;
    padding: 15px 20px;
    margin: 10px 0;
}

.chatbot-system-message span {
    display: inline-block;
    padding: 8px 16px;
background: #f8f0e5;
    border: 1px solid #b3d9e6;
    border-radius: 20px;
    font-size: 12px;
    color: #4a90e2;
    font-weight: 500;
}

/* Typing Indicator */
.chatbot-typing {
    padding: 0 20px 10px 20px;
background: #f8f0e5;
}

.chatbot-typing-indicator {
    padding: 16px 20px !important;
    display: flex;
    gap: 4px;
    align-items: center;
}

.chatbot-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chatbot-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.chatbot-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.chatbot-input-container {
    padding: 15px 20px;
background: #f8f0e5;
    border-top: 1px solid #e5e7eb;
}

.chatbot-input-container form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    font-size: 14px;
    background: #f8f0e5;
    font-family: inherit;
    transition: all 0.3s;
    outline: none;
    resize: none; /* Prevent manual resize */
    overflow-y: auto; /* Show scrollbar if needed */
    min-height: 44px; /* Minimum height for mobile */
    max-height: 150px; /* Maximum height before scrolling */
    line-height: 1.5;
}

.chatbot-input:focus {
    border-color: #eaddcc;
    box-shadow: 0 0 0 3px rgba(248, 240, 229, 0.3);
    outline: none;
}

/* زر الإرسال */
.chatbot-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e74c3c 0%, #d35400 100%); /* تدرج دافئ يشبه accent */
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chatbot-send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}


.chatbot-send-button:active {
    transform: scale(0.95);
}

.chatbot-send-button i {
    font-size: 16px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chatbot-widget {
        bottom: 10px;
    }
	
	  .chatbot-input {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px; /* Better touch target */
        max-height: 120px; /* Smaller max on mobile */
    }
    
    .chatbot-send-button {
        width: 44px; /* Better touch target */
        height: 44px;
    }
    
    .chatbot-widget[data-position="right"] {
        right: 10px;
    }
    
    .chatbot-widget[data-position="left"] {
        left: 10px;
    }
    
    .chatbot-welcome-popup {
        max-width: 280px;
        padding: 16px;
    }
    
    .chatbot-welcome-content {
        gap: 12px;
    }
    
    .chatbot-welcome-avatar {
        width: 50px;
        height: 50px;
    }
    
    .chatbot-welcome-avatar i {
        font-size: 24px;
    }
    
    .chatbot-welcome-popup h3 {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .chatbot-welcome-popup p {
        font-size: 12px;
        margin-bottom: 10px;
    }
    
    .chatbot-welcome-button {
        padding: 6px 16px;
        font-size: 12px;
    }
    
    /* On mobile, keep popup next to button horizontally */
    .chatbot-widget[data-position="right"] .chatbot-welcome-popup {
        right: 70px;
        bottom: 0;
        left: auto;
        transform: translateX(20px) scale(0.9);
    }
    
    .chatbot-widget[data-position="right"] .chatbot-welcome-popup.show {
        transform: translateX(0) scale(1);
    }
    
    .chatbot-widget[data-position="right"] .chatbot-welcome-popup.hide {
        transform: translateX(20px) scale(0.9);
    }
    
    .chatbot-widget[data-position="left"] .chatbot-welcome-popup {
        left: 70px;
        bottom: 0;
        right: auto;
        transform: translateX(-20px) scale(0.9);
    }
    
    .chatbot-widget[data-position="left"] .chatbot-welcome-popup.show {
        transform: translateX(0) scale(1);
    }
    
    .chatbot-widget[data-position="left"] .chatbot-welcome-popup.hide {
        transform: translateX(-20px) scale(0.9);
    }
    
    /* Chatbot window on mobile - professional compact size */
    .chatbot-window {
        width: calc(100vw - 20px);
        height: 70svh;
        bottom: 10px;
        max-width: 380px;
        border-radius: 16px;
    }
	    .chatbot-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .chatbot-input-container {
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
    }
    
    /* Position based on direction */
    html[dir="rtl"] .chatbot-window {
        right: 10px;
        left: auto;
    }
    
    html[dir="ltr"] .chatbot-window {
        left: 10px;
        right: auto;
    }
    
    .chatbot-header {
        padding: 15px;
    }
    
    .chatbot-header h3 {
        font-size: 16px;
    }
    
    .chatbot-close {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .chatbot-messages {
        padding: 15px;
    }
    
    .chatbot-input {
        padding: 15px;
    }
    
    .chatbot-input textarea {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .chatbot-send-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .chatbot-bubble {
        width: 55px;
        height: 55px;
    }
    
    .chatbot-bubble-avatar i {
        font-size: 24px;
    }
    
    .chatbot-message {
        font-size: 13px;
        gap: 8px;
    }
    
    .chatbot-message-avatar {
        width: 28px;
        height: 28px;
    }
    
    .chatbot-message-avatar i {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    /* Extra small phones - even more compact */
    .chatbot-window {
        width: calc(100vw - 16px);
        height: 65vh; /* Slightly smaller */
        max-width: none;
        border-radius: 20px 20px 0 0; /* Rounded only at top */
    }
    
    html[dir="rtl"] .chatbot-window {
        right: 8px;
    }
    
    html[dir="ltr"] .chatbot-window {
        left: 8px;
    }
    
    .chatbot-bubble {
        bottom: 10px;
        width: 50px;
        height: 50px;
    }
    
    .chatbot-header {
        padding: 12px 15px;
    }
    
    .chatbot-header h3 {
        font-size: 15px;
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .chatbot-input {
        padding: 12px;
    }
    
    .chatbot-message-bubble {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* RTL Support */
[dir="rtl"] .chatbot-message.user {
    flex-direction: row;
}

[dir="rtl"] .chatbot-message.user .chatbot-message-bubble {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .chatbot-message.bot .chatbot-message-bubble {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

