/* ============================================
   SmartChat Widget Styles
   ============================================ */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --smartchat-primary:rgb(49, 49, 50);
    --smartchat-primary-dark:rgb(52, 52, 59);
    --smartchat-primary-light:rgb(255, 255, 255);
    --smartchat-secondary:rgb(53, 50, 50);
    --smartchat-success: #10b981;
    --smartchat-danger: #ef4444;
    --smartchat-warning: #f59e0b;
    --smartchat-text: #1f2937;
    --smartchat-text-light: #6b7280;
    --smartchat-bg: #ffffff;
    --smartchat-bg-light: #f3f4f6;
    --smartchat-border: #e5e7eb;
    --smartchat-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --smartchat-radius: 16px;
    --smartchat-radius-sm: 8px;
}

/* ============================================
   Widget Container
   ============================================ */
.smartchat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================
   Chat Bubble Button
   ============================================ */
.smartchat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--smartchat-primary) 0%, var(--smartchat-secondary) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    /*overflow: hidden;*/
}

.smartchat-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    border-radius: 50%;
}

.smartchat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(79, 70, 229, 0.5);
}

.smartchat-bubble-icon {
    width: 28px;
    height: 28px;
    color: white;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.smartchat-icon-chat {
    opacity: 1;
    transform: scale(1);
}

.smartchat-icon-close {
    position: absolute;
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

.smartchat-bubble-active .smartchat-icon-chat {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.smartchat-bubble-active .smartchat-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Unread Badge */
.smartchat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--smartchat-danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.smartchat-unread-badge:not(:empty):not([data-count="0"]) {
    display: flex;
}

/* ============================================
   Chat Window
   ============================================ */
.smartchat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 120px);
    /*background: var(--smartchat-bg);*/
    border-radius: var(--smartchat-radius);
    box-shadow: var(--smartchat-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.smartchat-open .smartchat-window {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ============================================
   Header
   ============================================ */
.smartchat-header {
    padding: 16px;
    background: linear-gradient(135deg, var(--smartchat-primary) 0%, var(--smartchat-secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.smartchat-back-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.smartchat-back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.smartchat-back-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

.smartchat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.smartchat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.smartchat-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.smartchat-header-text {
    flex: 1;
    min-width: 0;
}

.smartchat-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smartchat-subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.smartchat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
}

.smartchat-status-online {
    background: var(--smartchat-success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.smartchat-status-offline {
    background: #9ca3af;
}

.smartchat-status-reconnecting {
    background: var(--smartchat-warning);
    animation: pulse 1.5s ease-in-out infinite;
}

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

.smartchat-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.smartchat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.smartchat-close-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* ============================================
   Tabs
   ============================================ */
.smartchat-tabs {
    display: flex;
    border-bottom: 1px solid var(--smartchat-border);
    background: var(--smartchat-bg);
    flex-shrink: 0;
    position: relative;
}

.smartchat-tab {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--smartchat-text-light);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    position: relative;
}

.smartchat-tab:hover {
    color: var(--smartchat-text);
    background: var(--smartchat-bg-light);
}

.smartchat-tab.active {
    color: var(--smartchat-primary);
}

.smartchat-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--smartchat-primary);
}

/* Tab Add Button */
.smartchat-tab-add-btn {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--smartchat-primary);
    border-radius: 5px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    border: none;
}

.smartchat-tab-add-btn svg {
    width: 12px;
    height: 12px;
    color: white;
}

.smartchat-tab-add-btn:hover {
    background: var(--smartchat-primary-dark);
    transform: translateY(-50%) scale(1.1);
}

/* ============================================
   Views
   ============================================ */
.smartchat-view {
    flex: 1;
    overflow: hidden;
    display: none;
    flex-direction: column;
    background: var(--smartchat-bg-light);
}

.smartchat-view.active {
    display: flex;
}

.smartchat-view-list {
    overflow-y: auto;
}

.smartchat-view-chat {
    display: flex;
    flex-direction: column;
}

/* ============================================
   List Items (Conversations, Groups, AI)
   ============================================ */
.smartchat-conversations-list,
.smartchat-groups-list,
.smartchat-ai-list {
    flex: 1;
    overflow-y: auto;
}

.smartchat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--smartchat-border);
}

.smartchat-list-item:hover {
    background: var(--smartchat-bg-light);
}

.smartchat-list-item:last-child {
    border-bottom: none;
}

.smartchat-list-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--smartchat-bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.smartchat-list-avatar svg {
    width: 24px;
    height: 24px;
    color: var(--smartchat-text-light);
}

.smartchat-group-avatar {
    background: linear-gradient(135deg, var(--smartchat-primary-light) 0%, #dfdfdf 100%);
}

.smartchat-group-avatar svg {
    color: var(--smartchat-primary);
}

.smartchat-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--smartchat-success);
    border: 2px solid white;
    border-radius: 50%;
}

.smartchat-list-content {
    flex: 1;
    min-width: 0;
}

.smartchat-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.smartchat-list-name {
    font-weight: 600;
    color: var(--smartchat-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smartchat-list-time {
    font-size: 11px;
    color: var(--smartchat-text-light);
    flex-shrink: 0;
    margin-left: 8px;
}

.smartchat-list-preview {
    display: flex;
    align-items: center;
    gap: 8px;
}

.smartchat-list-message {
    font-size: 13px;
    color: var(--smartchat-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.smartchat-list-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--smartchat-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.smartchat-list-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--smartchat-text-light);
}

.smartchat-role-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.smartchat-role-badge[data-role="owner"] {
    background: #fef3c7;
    color: #92400e;
}

.smartchat-role-badge[data-role="admin"] {
    background: #dbeafe;
    color: #1e40af;
}

.smartchat-role-badge[data-role="member"] {
    background: var(--smartchat-bg-light);
    color: var(--smartchat-text-light);
}

/* Empty State */
.smartchat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--smartchat-text-light);
}

.smartchat-empty p {
    margin: 0;
    font-weight: 500;
}

/* ============================================
   Messages Area
   ============================================ */
.smartchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--smartchat-bg-light);
}

.smartchat-messages-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.15s ease-in-out;
}

/* Message Bubbles */
.smartchat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: messageIn 0.3s ease;
}

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

.smartchat-message-sent {
    align-self: flex-end;
}

.smartchat-message-received {
    align-self: flex-start;
}

.smartchat-message-system {
    align-self: center;
    max-width: 90%;
}

.smartchat-message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--smartchat-text-light);
    margin-bottom: 4px;
    padding-left: 12px;
}

.smartchat-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
}

.smartchat-message-sent .smartchat-message-bubble {
    background: linear-gradient(135deg, var(--smartchat-primary) 0%, var(--smartchat-secondary) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.smartchat-message-received .smartchat-message-bubble {
    background: white;
    color: var(--smartchat-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.smartchat-message-system .smartchat-message-bubble {
    background: rgba(0, 0, 0, 0.05);
    color: var(--smartchat-text-light);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 12px;
}

.smartchat-message-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--smartchat-text-light);
    margin-top: 4px;
}

.smartchat-message-sent .smartchat-message-meta {
    justify-content: flex-end;
    padding-right: 4px;
}

.smartchat-message-received .smartchat-message-meta {
    padding-left: 4px;
}

.smartchat-read-status {
    color: var(--smartchat-primary-light);
}

.smartchat-message-time {
    font-size: 10px;
    color: var(--smartchat-text-light);
    opacity: 0.7;
    font-weight: 400;
    white-space: nowrap;
}

.smartchat-message-sent .smartchat-message-time {
    color: rgba(255, 255, 255, 0.7);
}

.smartchat-message-received .smartchat-message-time {
    color: var(--smartchat-text-light);
}

.smartchat-message-system .smartchat-message-time {
    color: var(--smartchat-text-light);
    opacity: 0.6;
}

/* Typing Indicator */
.smartchat-typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border-top: 1px solid var(--smartchat-border);
}

.smartchat-typing-dots {
    display: flex;
    gap: 4px;
}

.smartchat-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--smartchat-text-light);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

.smartchat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.smartchat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.smartchat-typing-text {
    font-size: 12px;
    color: var(--smartchat-text-light);
}

/* ============================================
   Input Area
   ============================================ */
.smartchat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid var(--smartchat-border);
    flex-shrink: 0;
}

.smartchat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--smartchat-bg-light);
    border-radius: 24px;
    padding: 8px 12px;
    position: relative;
}

.smartchat-input {
    margin-bottom:6px;
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    outline: none;
    font-family: inherit;
}

.smartchat-input::placeholder {
    color: var(--smartchat-text-light);
}

.smartchat-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.smartchat-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.smartchat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.smartchat-send-btn svg {
    width: 18px;
    height: 18px;
    color: white;
    fill: white;
}

/* ============================================
   Attachment Preview
   ============================================ */
.smartchat-widget .smartchat-attachment-preview {
    display: none !important;
    margin: 0 12px 12px 12px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.smartchat-widget .smartchat-attachment-preview[style*="display: flex"] {
    display: flex !important;
}

.smartchat-widget .smartchat-attachment-preview-content {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    padding: 12px 16px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    gap: 0 !important;
    position: relative !important;
    overflow: hidden !important;
}

.smartchat-widget .smartchat-attachment-preview-content::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 3px !important;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899) !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

.smartchat-widget .smartchat-attachment-preview.uploading .smartchat-attachment-preview-content::before {
    opacity: 1 !important;
    animation: smartchat-shimmer 1.5s ease infinite !important;
}

@keyframes smartchat-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Image Preview */
.smartchat-widget .smartchat-attachment-preview-image {
    display: none !important;
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    border: 2px solid #ffffff !important;
    margin-right: 14px !important;
}

.smartchat-widget .smartchat-attachment-preview-image[style*="display: block"] {
    display: block !important;
}

.smartchat-widget .smartchat-attachment-preview-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: transform 0.3s ease !important;
}

.smartchat-widget .smartchat-attachment-preview:hover .smartchat-attachment-preview-image img {
    transform: scale(1.1) !important;
}

/* File Preview */
.smartchat-widget .smartchat-attachment-preview-file {
    display: none !important;
    align-items: center !important;
    gap: 14px !important;
    flex: 1 !important;
    min-width: 0 !important;
}

.smartchat-widget .smartchat-attachment-preview-file[style*="display: flex"] {
    display: flex !important;
}

.smartchat-widget .smartchat-attachment-preview-icon {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}

.smartchat-widget .smartchat-attachment-preview-icon svg {
    width: 24px !important;
    height: 24px !important;
    color: #ffffff !important;
    fill: #ffffff !important;
}

.smartchat-widget .smartchat-attachment-preview-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    min-width: 0 !important;
    flex: 1 !important;
}

.smartchat-widget .smartchat-attachment-preview-name {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.3 !important;
    display: block !important;
}

.smartchat-widget .smartchat-attachment-preview-size {
    font-size: 12px !important;
    color: #64748b !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    line-height: 1.3 !important;
}

.smartchat-widget .smartchat-attachment-preview-size::before {
    content: '' !important;
    width: 6px !important;
    height: 6px !important;
    min-width: 6px !important;
    background: #10b981 !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
}

.smartchat-widget .smartchat-attachment-preview.uploading .smartchat-attachment-preview-size::before {
    background: #f59e0b !important;
    animation: smartchat-pulse 1s ease-in-out infinite !important;
}

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

/* Remove Button */
.smartchat-widget .smartchat-attachment-preview-remove {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border: none !important;
    background: #f1f5f9 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    transition: all 0.2s ease !important;
    margin-left: 12px !important;
    padding: 0 !important;
}

.smartchat-widget .smartchat-attachment-preview-remove:hover {
    background: #fee2e2 !important;
    transform: scale(1.1) !important;
}

.smartchat-widget .smartchat-attachment-preview-remove svg {
    width: 16px !important;
    height: 16px !important;
    color: #64748b !important;
    transition: color 0.2s ease !important;
}

.smartchat-widget .smartchat-attachment-preview-remove:hover svg {
    color: #ef4444 !important;
}

/* ============================================
   Attachment Button & Menu
   ============================================ */
.smartchat-attach-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
    color: var(--smartchat-text-light);
}

.smartchat-attach-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--smartchat-primary);
    transform: scale(1.1);
}

.smartchat-attach-btn svg {
    width: 20px;
    height: 20px;
}

.smartchat-attach-menu {
    position: fixed !important;
    z-index: 999999 !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    padding: 8px !important;
    min-width: 220px !important;
    display: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    pointer-events: none !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.smartchat-attach-menu.active {
    display: block !important;
    pointer-events: auto !important;
}

.smartchat-attach-menu-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    padding: 8px 12px 4px;
}

.smartchat-attach-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.smartchat-attach-option:hover {
    background: #f3f4f6;
}

.smartchat-attach-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.smartchat-attach-icon svg {
    width: 22px;
    height: 22px;
}

.smartchat-attach-icon-image {
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
    color: white;
}

.smartchat-attach-icon-file {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.smartchat-attach-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.smartchat-attach-title {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

.smartchat-attach-desc {
    font-size: 12px;
    color: #6b7280;
}

/* Upload Progress */
.smartchat-message-uploading {
    opacity: 0.8;
}

.smartchat-file-upload-bubble {
    background: var(--smartchat-bg-light) !important;
    min-width: 200px;
}

.smartchat-upload-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px;
}

.smartchat-upload-progress svg {
    color: var(--smartchat-primary);
    flex-shrink: 0;
}

.smartchat-upload-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.smartchat-upload-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--smartchat-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smartchat-upload-status {
    font-size: 11px;
    color: var(--smartchat-text-light);
}

.smartchat-upload-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--smartchat-bg-light);
    border-top-color: var(--smartchat-primary);
    border-radius: 50%;
    animation: smartchat-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes smartchat-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Message Attachments
   ============================================ */
.smartchat-has-attachment {
    padding: 4px !important;
}

.smartchat-attachment {
    margin-bottom: 4px;
}

.smartchat-attachment-image {
    max-width: 250px;
    border-radius: 8px;
    overflow: hidden;
}

.smartchat-attachment-image img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 300px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}

.smartchat-attachment-image img:hover {
    transform: scale(1.02);
}

.smartchat-attachment-file {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden;
}

.smartchat-attachment-file a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.smartchat-attachment-file a:hover {
    background: rgba(0, 0, 0, 0.08);
}

.smartchat-file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.smartchat-file-icon svg {
    width: 32px;
    height: 32px;
}

.smartchat-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.smartchat-file-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--smartchat-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smartchat-file-size {
    font-size: 11px;
    color: var(--smartchat-text-light);
}

.smartchat-file-download {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--smartchat-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.smartchat-attachment-file a:hover .smartchat-file-download {
    transform: scale(1.1);
}

/* Sent message attachment styles */
.smartchat-message-sent .smartchat-attachment-file {
    background: rgba(255, 255, 255, 0.15);
}

.smartchat-message-sent .smartchat-attachment-file a:hover {
    background: rgba(255, 255, 255, 0.25);
}

.smartchat-message-sent .smartchat-file-name {
    color: white;
}

.smartchat-message-sent .smartchat-file-size {
    color: rgba(255, 255, 255, 0.7);
}

.smartchat-message-sent .smartchat-file-download {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   Modal
   ============================================ */
.smartchat-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.smartchat-modal-content {
    background: white;
    border-radius: var(--smartchat-radius);
    padding: 24px;
    width: 100%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: var(--smartchat-shadow);
    pointer-events: auto;
}

.smartchat-modal-content h3 {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--smartchat-text);
}

.smartchat-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.smartchat-modal-cancel {
    padding: 10px 20px;
    border: 1px solid var(--smartchat-border);
    background: white;
    border-radius: var(--smartchat-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.smartchat-modal-cancel:hover {
    background: var(--smartchat-bg-light);
}

.smartchat-modal-create {
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, var(--smartchat-primary) 0%, var(--smartchat-secondary) 100%);
    color: white;
    border-radius: var(--smartchat-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.smartchat-modal-create:hover {
    opacity: 0.9;
}

.smartchat-modal-create:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Form Groups & Inputs (Modals)
   ============================================ */
.smartchat-group-modal,
.smartchat-add-member-modal {
    min-width: 320px;
    max-width: 420px;
}

.smartchat-form-group {
    margin-bottom: 15px;
}

.smartchat-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
    color: #555;
}

.smartchat-user-search-container {
    position: relative;
}

.smartchat-user-search-input,
.smartchat-group-name-input,
.smartchat-group-desc-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--smartchat-border);
    border-radius: var(--smartchat-radius-sm);
    font-size: 14px;
    box-sizing: border-box;
    font-family: inherit;
    pointer-events: auto;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.smartchat-group-desc-input {
    resize: vertical;
    min-height: 60px;
}

.smartchat-user-search-input:focus,
.smartchat-group-name-input:focus,
.smartchat-group-desc-input:focus {
    outline: none;
    border-color: var(--smartchat-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.smartchat-user-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--smartchat-border);
    border-top: none;
    border-radius: 0 0 var(--smartchat-radius-sm) var(--smartchat-radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Chat Search (New Conversation)
   ============================================ */
.smartchat-chat-search-container {
    padding: 12px;
    border-bottom: 1px solid var(--smartchat-border);
    position: relative;
}

.smartchat-chat-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.smartchat-chat-search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: #9ca3af;
    pointer-events: none;
}

.smartchat-chat-search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    border: 1px solid var(--smartchat-border);
    border-radius: var(--smartchat-radius-sm);
    font-size: 14px;
    background: var(--smartchat-bg-light);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.smartchat-chat-search-input:focus {
    outline: none;
    border-color: var(--smartchat-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: white;
}

.smartchat-chat-search-input::placeholder {
    color: #9ca3af;
}

.smartchat-chat-search-results {
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    background: white;
    border: 1px solid var(--smartchat-border);
    border-radius: var(--smartchat-radius-sm);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 4px;
}

.smartchat-chat-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.smartchat-chat-search-result:hover {
    background: var(--smartchat-bg-light);
}

.smartchat-chat-search-result:not(:last-child) {
    border-bottom: 1px solid var(--smartchat-border);
}

.smartchat-chat-search-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--smartchat-primary) 0%, var(--smartchat-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.smartchat-chat-search-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.smartchat-chat-search-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.smartchat-chat-search-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--smartchat-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smartchat-chat-search-email {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smartchat-user-suggestion {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid var(--smartchat-border);
    transition: background 0.15s;
}

.smartchat-user-suggestion:hover {
    background: var(--smartchat-bg-light);
}

.smartchat-user-suggestion:last-child {
    border-bottom: none;
}

.smartchat-user-name {
    font-weight: 500;
    color: var(--smartchat-text);
}

.smartchat-user-email {
    font-size: 12px;
    color: var(--smartchat-text-light);
}

.smartchat-no-results {
    padding: 15px;
    text-align: center;
    color: var(--smartchat-text-light);
    font-size: 13px;
}

/* Selected User Card */
.smartchat-selected-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--smartchat-bg-light);
    border-radius: var(--smartchat-radius-sm);
    margin-bottom: 15px;
}

.smartchat-selected-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.smartchat-selected-user-name {
    font-weight: 600;
    color: var(--smartchat-text);
}

.smartchat-selected-user-email {
    font-size: 12px;
    color: var(--smartchat-text-light);
}

.smartchat-remove-selected {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--smartchat-border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: var(--smartchat-text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.smartchat-remove-selected:hover {
    background: var(--smartchat-danger);
    color: white;
}

/* Role Selector */
.smartchat-role-selector {
    margin-top: 15px;
}

.smartchat-role-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.smartchat-role-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--smartchat-border);
    border-radius: var(--smartchat-radius-sm);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.smartchat-role-option:hover {
    border-color: var(--smartchat-primary-light);
    background: #f5f3ff;
}

.smartchat-role-option input[type="radio"] {
    margin-top: 4px;
    accent-color: var(--smartchat-primary);
}

.smartchat-role-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.smartchat-role-info strong {
    font-size: 14px;
    color: var(--smartchat-text);
}

.smartchat-role-info small {
    font-size: 12px;
    color: var(--smartchat-text-light);
}

.smartchat-role-permissions {
    margin-top: 8px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    font-size: 11px;
}

.smartchat-role-permissions ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.smartchat-role-permissions li {
    margin: 4px 0;
    padding-left: 4px;
}

.smartchat-role-permissions .permission-yes {
    color: #059669;
}

.smartchat-role-permissions .permission-no {
    color: #dc2626;
}

/* Modal Add Button */
.smartchat-modal-add {
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, var(--smartchat-primary) 0%, var(--smartchat-secondary) 100%);
    color: white;
    border-radius: var(--smartchat-radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.smartchat-modal-add:hover {
    opacity: 0.9;
}

.smartchat-modal-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Group Actions (Add Member Button - Inline)
   ============================================ */
.smartchat-subtitle .smartchat-add-member-btn {
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 300;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    vertical-align: middle;
    padding-bottom: 1px;
}

.smartchat-header:hover .smartchat-subtitle .smartchat-add-member-btn {
    opacity: 1;
}

.smartchat-subtitle .smartchat-add-member-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ============================================
   AI Provider Headers
   ============================================ */
.smartchat-ai-provider-header {
    padding: 8px 16px;
    background: var(--smartchat-bg-light);
    font-size: 11px;
    font-weight: 600;
    color: var(--smartchat-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--smartchat-border);
}

.smartchat-ai-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.smartchat-ai-avatar svg {
    color: white;
}

/* ============================================
   Toast Notifications
   ============================================ */
.smartchat-toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: var(--smartchat-text);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    z-index: 200;
    animation: toastIn 0.3s ease;
}

.smartchat-toast.error {
    background: var(--smartchat-danger);
}

.smartchat-toast.success {
    background: var(--smartchat-success);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
    .smartchat-widget {
        bottom: 10px;
        right: 10px;
    }

    .smartchat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
    }

    .smartchat-bubble {
        width: 50px;
        height: 50px;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */
@media (prefers-color-scheme: dark) {
    .smartchat-window {
        background: #1f2937;
    }

    .smartchat-tabs {
        background: #1f2937;
        border-color: #374151;
    }

    .smartchat-tab {
        color: #9ca3af;
    }

    .smartchat-tab:hover {
        background: #374151;
        color: #f3f4f6;
    }

    .smartchat-tab.active {
        color: var(--smartchat-primary-light);
    }

    .smartchat-list-item {
        border-color: #374151;
    }

    .smartchat-list-item:hover {
        background: #374151;
    }

    .smartchat-list-name {
        color: #f3f4f6;
    }

    .smartchat-messages {
        background: #111827;
    }

    .smartchat-message-received .smartchat-message-bubble {
        background: #374151;
        color: #f3f4f6;
    }

    .smartchat-input-area {
        background: #1f2937;
        border-color: #374151;
    }

    .smartchat-input-wrapper {
        background: #374151;
    }

    .smartchat-input {
        color: #f3f4f6;
    }

    .smartchat-modal-content {
        background: #1f2937;
    }

    .smartchat-modal-content h3 {
        color: #f3f4f6;
    }

    .smartchat-empty {
        color: #9ca3af;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .smartchat-bubble::before {
        animation: none;
    }

    .smartchat-window,
    .smartchat-message,
    .smartchat-bubble,
    .smartchat-bubble-icon {
        transition: none;
    }

    .smartchat-typing-dots span {
        animation: none;
        opacity: 0.6;
    }
}
