#sanad-floating-icon-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    cursor: pointer;
}

.sanad-floating-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sanad-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 14px rgba(0,0,0,0.4);
}

/* Chat Widget */
#sanad-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 360px;
    height: 500px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

#sanad-chat-widget.sanad-chat-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
}

.sanad-chat-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.sanad-chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sanad-chat-close {
    cursor: pointer;
    font-size: 20px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.sanad-chat-close:hover {
    opacity: 1;
}

.sanad-chat-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.sanad-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

.sanad-message.user {
    align-self: flex-end;
    background: #10b981;
    color: white;
    border-bottom-right-radius: 4px;
}

.sanad-message.ai {
    align-self: flex-start;
    background: #ffffff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sanad-chat-input-container {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.sanad-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}

.sanad-chat-input:focus {
    border-color: #10b981;
}

.sanad-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #10b981;
    color: white;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sanad-chat-send:hover {
    background: #059669;
}

.sanad-msg-source {
    font-size: 10px;
    color: #999;
    text-align: left;
    margin-top: 6px;
    opacity: 0.7;
    border-top: 1px solid #eee;
    padding-top: 4px;
}

[dir="rtl"] .sanad-msg-source {
    text-align: right;
}

/* Typing Indicator */
.sanad-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sanad-typing-dot {
    width: 6px;
    height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.sanad-typing-dot:nth-child(1) { animation-delay: 0s; }
.sanad-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sanad-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

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

/* RTL Support */
[dir="rtl"] #sanad-floating-icon-container {
    right: auto;
    left: 30px;
}
[dir="rtl"] #sanad-chat-widget {
    right: auto;
    left: 30px;
}
[dir="rtl"] .sanad-message.user {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}
[dir="rtl"] .sanad-message.ai {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}
[dir="rtl"] .sanad-typing-indicator {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}
[dir="rtl"] .sanad-msg-copy-btn {
    right: auto;
    left: -10px;
}

/* NEW UX ENHANCEMENTS */

.sanad-history-icon {
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
}
.sanad-history-icon:hover {
    opacity: 1;
}

.sanad-message {
    position: relative;
}

.sanad-msg-copy-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #64748b;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 10;
}

.sanad-message.ai:hover .sanad-msg-copy-btn {
    opacity: 1;
}

.sanad-msg-copy-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.sanad-chat-attach {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: #64748b;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.sanad-chat-attach:hover {
    background: #f1f5f9;
    color: #10b981;
}

.sanad-attachment-sheet {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 10px;
    display: flex;
    gap: 10px;
    justify-content: space-around;
    animation: fadeIn 0.2s ease;
}

.sanad-attachment-option {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}
.sanad-attachment-option:hover {
    border-color: #10b981;
}

.sanad-chat-send.mic-mode {
    background: transparent;
    color: #10b981;
}
.sanad-chat-send.mic-mode:hover {
    background: #ecfdf5;
}
