/* ═══════════════════════════════════════════════════════════
   💬 CHAT WINDOWS & RATING PANELS
   ═══════════════════════════════════════════════════════════ */

/* نافذة التقييم - منبثقة من اليسار */
.rating-widget {
    position: absolute;
    bottom: 60px;
    left: 0;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(0, 0, 0, 0.1);
    min-width: 320px;
    max-width: 350px;
    transform: translateX(-20px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rating-widget.active {
    transform: translateX(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.rating-header h3 {
    margin: 0;
    color: var(--text);
    font-size: 1.1rem;
}

.close-rating {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
    transition: color 0.2s ease;
}

.close-rating:hover {
    color: var(--error);
}

.rating-stars {
    display: flex;
    gap: 5px;
    margin-bottom: 1rem;
    justify-content: center;
}

.star {
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    filter: grayscale(100%);
}

.star:hover,
.star.active {
    filter: grayscale(0%);
    transform: scale(1.2);
}

.rating-labels {
    text-align: center;
    margin-bottom: 1rem;
}

.rating-label {
    font-weight: 600;
    color: var(--text);
}

#ratingComment {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    resize: vertical;
    min-height: 80px;
    margin-bottom: 1rem;
    font-family: var(--body-font);
}

.rating-actions {
    display: flex;
    gap: 0.5rem;
}

.rating-actions .btn {
    flex: 1;
    text-align: center;
    padding: 0.8rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* لوحة إدارة التقييمات - من اليسار */
.ratings-panel {
    position: fixed;
    top: 0;
    left: -400px;
    width: 400px;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.1);
    z-index: 1002;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.ratings-panel.active {
    left: 0;
}

.ratings-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary);
    color: white;
}

.ratings-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.close-panel:hover {
    opacity: 0.7;
}

.ratings-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-alt);
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.ratings-list {
    padding: 1.5rem;
}

.no-ratings {
    text-align: center;
    color: var(--muted);
    padding: 2rem;
}

/* نافذة الدردشة */
.chat-window {
    position: fixed;
    bottom: 210px;
    left: 20px;
    width: 350px;
    height: 450px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 8px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1004;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* رأس نافذة الدردشة */
.chat-header {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #34e79a 0%, #25d366 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.chat-agent-info h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34e79a;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.25rem;
    border-radius: 50%;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* منطقة الرسائل */
.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* الرسائل */
.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.message.user {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 0.25rem;
    text-align: right;
}

/* منطقة الكتابة */
.chat-input-area {
    padding: 1rem;
    background: white;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 20px 20px;
}

.chat-input-container {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    transition: all 0.2s ease;
    font-family: var(--body-font);
}

.chat-input:focus {
    outline: none;
    border-color: #25d366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.chat-send {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.chat-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* الردود السريعة */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.quick-reply {
    background: white;
    border: 2px solid #25d366;
    color: #25d366;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-reply:hover {
    background: #25d366;
    color: white;
    transform: translateY(-1px);
}

/* مؤشر الكتابة */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 80px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #25d366;
    animation: typingDot 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* التصميم المتجاوب للنوافذ */
@media (max-width: 768px) {
    .chat-window {
        bottom: 195px;
        left: 15px;
        right: 15px;
        width: auto;
        max-width: calc(100vw - 30px);
        height: 400px;
    }
    
    .chat-header {
        padding: 0.75rem 1rem;
    }
    
    .chat-avatar {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .chat-agent-info h4 {
        font-size: 0.9rem;
    }
    
    .chat-status {
        font-size: 0.75rem;
    }
    
    .rating-widget {
        min-width: 280px;
        max-width: calc(100vw - 40px);
        left: -140px;
    }
    
    .ratings-panel {
        width: 100vw;
        left: -100vw;
    }
    
    .ratings-panel.active {
        left: 0;
    }
}