/* ============================================
   SmartSide Chat - Widget Styles
   ============================================ */

:root {
    --ssc-primary: #2563eb;
    --ssc-primary-dark: #1d4ed8;
    --ssc-success: #16a34a;
    --ssc-warning: #f59e0b;
    --ssc-danger: #dc2626;
    --ssc-gray: #9ca3af;
    --ssc-bg: #f8fafc;
    --ssc-white: #ffffff;
    --ssc-text: #1a1a1a;
    --ssc-radius: 12px;
    --ssc-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}

/* ============================================
   دکمه باز کردن چت (سمت چپ)
   ============================================ */

#ssc-chat-toggle {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ssc-primary);
    color: var(--ssc-white);
    border: none;
    cursor: pointer;
    box-shadow: var(--ssc-shadow);
    z-index: 999999;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#ssc-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.4);
}

#ssc-chat-toggle:active {
    transform: scale(0.95);
}

#ssc-chat-toggle .ssc-toggle-icon,
#ssc-chat-toggle .ssc-toggle-close {
    display: flex;
    align-items: center;
    justify-content: center;
}

#ssc-chat-toggle .ssc-toggle-icon svg,
#ssc-chat-toggle .ssc-toggle-close svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
}

#ssc-chat-toggle .ssc-toggle-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ssc-success);
    border: 2px solid var(--ssc-white);
    animation: ssc-pulse 2s infinite;
}

@keyframes ssc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================
   باکس چت (سمت چپ)
   ============================================ */

#ssc-chat-widget {
    position: fixed;
    bottom: 100px;
    left: 24px;
    width: 380px;
    max-width: 92vw;
    height: 560px;
    max-height: 75vh;
    background: var(--ssc-white);
    border-radius: 16px;
    box-shadow: var(--ssc-shadow);
    display: none !important;
    flex-direction: column;
    z-index: 999998;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    direction: rtl;
    overflow: hidden;
}

#ssc-chat-widget.active {
    display: flex !important;
    animation: ssc-slide-up 0.3s ease;
}

@keyframes ssc-slide-up {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ============================================
   Header
   ============================================ */

.ssc-header {
    background: var(--ssc-primary);
    color: var(--ssc-white);
    padding: 14px 18px;
    flex-shrink: 0;
}

.ssc-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ssc-header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ssc-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ssc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.ssc-close-btn {
    background: none;
    border: none;
    color: var(--ssc-white);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.ssc-close-btn:hover {
    opacity: 1;
}

.ssc-close-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.ssc-header-status {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    margin-top: 4px;
    opacity: 0.9;
    flex-wrap: wrap;
}

.ssc-mode-indicator {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ssc-mode {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    font-size: 11px;
}

.ssc-mode.active {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   Messages
   ============================================ */

#ssc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--ssc-bg);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ssc-message {
    display: flex;
    margin-bottom: 2px;
    animation: ssc-msg-in 0.3s ease;
}

@keyframes ssc-msg-in {
    from {
        transform: translateY(8px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ssc-message.ssc-user {
    justify-content: flex-end;
}

.ssc-message.ssc-ai,
.ssc-message.ssc-operator {
    justify-content: flex-start;
}

.ssc-message.ssc-system {
    justify-content: center;
}

.ssc-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--ssc-radius);
    word-wrap: break-word;
    line-height: 1.7;
    font-size: 14px;
}

.ssc-user .ssc-bubble {
    background: var(--ssc-primary);
    color: var(--ssc-white);
    border-bottom-right-radius: 4px;
}

.ssc-ai .ssc-bubble {
    background: var(--ssc-white);
    color: var(--ssc-text);
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.ssc-operator .ssc-bubble {
    background: #dcfce7;
    color: var(--ssc-text);
    border-bottom-left-radius: 4px;
}

.ssc-system .ssc-bubble {
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    border-radius: 20px;
    padding: 4px 14px;
}

/* ============================================
   Typing Indicator
   ============================================ */

.ssc-typing {
    padding: 8px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ssc-gray);
    font-size: 13px;
}

.ssc-typing-dots {
    display: flex;
    gap: 4px;
}

.ssc-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--ssc-gray);
    border-radius: 50%;
    animation: ssc-typing-bounce 1.4s infinite;
}

.ssc-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ssc-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes ssc-typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

/* ============================================
   Footer
   ============================================ */

.ssc-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid #e5e7eb;
    background: var(--ssc-white);
    flex-shrink: 0;
}

.ssc-chat-form {
    display: flex;
    gap: 8px;
}

.ssc-input-wrapper {
    flex: 1;
    display: flex;
    background: #f3f4f6;
    border-radius: var(--ssc-radius);
    padding: 4px;
    border: 1px solid #e5e7eb;
    transition: border-color 0.2s;
}

.ssc-input-wrapper:focus-within {
    border-color: var(--ssc-primary);
}

.ssc-message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    min-height: 40px;
    max-height: 100px;
    line-height: 1.5;
}

.ssc-send-btn {
    background: var(--ssc-primary);
    color: var(--ssc-white);
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ssc-send-btn:hover {
    background: var(--ssc-primary-dark);
}

.ssc-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ssc-request-operator {
    width: 100%;
    margin-top: 8px;
    padding: 8px 16px;
    background: var(--ssc-success);
    color: var(--ssc-white);
    border: none;
    border-radius: var(--ssc-radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.ssc-request-operator:hover {
    background: #15803d;
}

.ssc-request-operator:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Scrollbar
   ============================================ */

#ssc-messages::-webkit-scrollbar {
    width: 4px;
}

#ssc-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ============================================
   RTL Support
   ============================================ */

[dir="rtl"] #ssc-chat-toggle {
    left: 24px;
    right: auto;
}

[dir="rtl"] #ssc-chat-widget {
    left: 24px;
    right: auto;
}

[dir="rtl"] .ssc-user .ssc-bubble {
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: var(--ssc-radius);
}

[dir="rtl"] .ssc-ai .ssc-bubble,
[dir="rtl"] .ssc-operator .ssc-bubble {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: var(--ssc-radius);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    #ssc-chat-toggle {
        bottom: 16px;
        left: 16px;
        width: 56px;
        height: 56px;
    }
    
    #ssc-chat-toggle .ssc-toggle-icon svg,
    #ssc-chat-toggle .ssc-toggle-close svg {
        width: 24px;
        height: 24px;
    }
    
    #ssc-chat-widget {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    [dir="rtl"] #ssc-chat-toggle {
        left: 16px;
        right: auto;
    }
    
    [dir="rtl"] #ssc-chat-widget {
        left: 0;
        right: 0;
    }
}