/* TABESH AI - Public Chat Interface Styles */

.tabesh-ai-chat-container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Vazir", "Tahoma", sans-serif;
    position: relative;
    direction: rtl;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    color: #fff;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.assistant-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.assistant-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.9);
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.assistant-avatar-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.assistant-details {
    flex: 1;
}

.assistant-name {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.assistant-role {
    margin: 6px 0 0;
    font-size: 14px;
    opacity: 0.95;
    font-weight: 500;
}

.chat-actions {
    display: flex;
    gap: 12px;
}

.btn-history,
.btn-new-chat {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.btn-history:hover,
.btn-new-chat:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-history .dashicons,
.btn-new-chat .dashicons {
    font-size: 22px;
}

/* Chat Messages */
.chat-messages {
    height: 550px;
    overflow-y: auto;
    padding: 24px;
    background: linear-gradient(180deg, #f9fafb 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 24px;
    animation: fadeInUp 0.4s ease-out;
    position: relative;
}

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

.user-message {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

.assistant-message {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 12px;
}

.message-number {
    min-width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    margin-top: 4px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.message-wrapper {
    flex: 1;
    max-width: 85%;
}

.message-content {
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.7;
    word-wrap: break-word;
    position: relative;
}

.user-message .message-content {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    margin-right: auto;
}

.assistant-message .message-content {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.message-content p {
    margin: 0;
    white-space: pre-wrap;
    font-size: 15px;
}

.message-content p + p {
    margin-top: 12px;
}

/* Code Blocks */
.message-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 12px 0;
    position: relative;
    border: 1px solid #334155;
}

.message-content code {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.message-content :not(pre) > code {
    background: #f1f5f9;
    color: #e11d48;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
    border: 1px solid #e2e8f0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #0f172a;
    border-radius: 8px 8px 0 0;
    margin: -16px -16px 8px -16px;
    border-bottom: 1px solid #334155;
}

.code-language {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
}

.btn-copy-code {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-copy-code:hover {
    background: #475569;
    border-color: #64748b;
}

.btn-copy-code.copied {
    background: #22c55e;
    border-color: #16a34a;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.btn-copy-message,
.btn-regenerate {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-copy-message:hover,
.btn-regenerate:hover {
    background: #e5e7eb;
    color: #374151;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-copy-message.copied {
    background: #d1fae5;
    color: #065f46;
    border-color: #10b981;
}

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

.btn-regenerate:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* File Upload Area */
.file-upload-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    background: #f9fafb;
    transition: all 0.3s;
}

.file-upload-area.drag-over {
    border-color: #6366f1;
    background: #eef2ff;
}

.file-upload-btn {
    background: #fff;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.file-upload-btn:hover {
    background: #f9fafb;
    border-color: #6366f1;
    color: #6366f1;
}

.uploaded-files {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.uploaded-file {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 6px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.uploaded-file-name {
    color: #374151;
}

.btn-remove-file {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    font-size: 16px;
}

/* Image/File Preview in Messages */
.message-attachments {
    margin-bottom: 12px;
}

.message-media {
    margin: 12px 0;
    border-radius: 12px;
    overflow: hidden;
}

.message-media img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    display: block;
    border: 1px solid #e5e7eb;
}

.message-media audio {
    width: 100%;
    margin: 8px 0;
}

.message-file {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}

.message-file-icon {
    font-size: 24px;
    color: #6366f1;
}

.message-file-info {
    flex: 1;
}

.message-file-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
}

.message-file-name a {
    color: #6366f1;
    text-decoration: none;
}

.message-file-name a:hover {
    text-decoration: underline;
}

.message-file-size {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

/* Uploaded Files Display */
.uploaded-file {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin: 4px;
}

.uploaded-file-icon {
    font-size: 18px;
}

.uploaded-file-name {
    color: #374151;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uploaded-file-size {
    color: #6b7280;
    font-size: 11px;
}

.btn-remove-file {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    font-size: 20px;
    line-height: 1;
    font-weight: bold;
    transition: color 0.2s;
}

.btn-remove-file:hover {
    color: #dc2626;
}

/* Typing Indicator */
.typing-indicator {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.typing-indicator-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}

.typing-indicator-dots {
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 12px 20px;
    border-radius: 18px;
    display: inline-flex;
    gap: 4px;
}

.typing-indicator-dots span {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-12px) scale(1.1);
        opacity: 1;
    }
}

/* Chat Input */
.chat-input-container {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 20px 24px;
}

.chat-input-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.chat-input-wrapper-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex: 1;
}

.chat-input-controls {
    display: flex;
    gap: 8px;
    padding-bottom: 14px;
}

.file-upload-btn {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #6b7280;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.file-upload-btn:hover {
    background: #e5e7eb;
    border-color: #6366f1;
    color: #6366f1;
}

.file-upload-btn .dashicons {
    font-size: 20px;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input {
    flex: 1;
    width: 100%;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 14px 24px;
    font-size: 15px;
    resize: none;
    min-height: 52px;
    max-height: 150px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.chat-input:focus {
    outline: none;
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn-send {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    color: #fff;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-send:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

.btn-send .dashicons {
    font-size: 26px;
}

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

.btn-send:disabled:hover {
    transform: none;
}

/* Login Notice */
.login-notice {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-top: 16px;
}

.login-notice-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-notice p {
    margin: 0 0 16px;
    font-size: 16px;
    color: #92400e;
    font-weight: 600;
    line-height: 1.6;
}

.login-notice .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s ease;
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.login-notice .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

/* History Sidebar */
.chat-history-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 340px;
    height: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
    border-left: 1px solid #e5e7eb;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.btn-close-sidebar {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    padding: 8px;
    color: #fff;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-close-sidebar:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.history-item {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    background: #fff;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
    position: relative;
}

.history-item:hover {
    background: #f3f4f6;
    border-color: #6366f1;
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.history-item-title {
    font-weight: 700;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1f2937;
    font-size: 14px;
}

.history-item-date {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-item-date::before {
    content: "🕐";
    font-size: 14px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar,
.sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.sidebar-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb,
.sidebar-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 48px 24px;
}

.welcome-message .message {
    display: inline-block;
    text-align: right;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: wave 2s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Error Message */
.error-message .message-content {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid #ef4444;
    color: #991b1b;
}

/* Responsive */
@media (max-width: 768px) {
    .tabesh-ai-chat-container {
        border-radius: 0;
        max-width: 100%;
    }
    
    .chat-messages {
        height: 450px;
    }
    
    .message-wrapper {
        max-width: 90%;
    }
    
    .chat-history-sidebar {
        width: 100%;
    }
    
    .chat-header {
        padding: 16px 20px;
    }
    
    .assistant-avatar,
    .assistant-avatar-placeholder {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
}

/* Dark Theme */
.tabesh-ai-chat-container[data-theme="dark"] {
    background: #1f2937;
}

.tabesh-ai-chat-container[data-theme="dark"] .chat-messages {
    background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
}

.tabesh-ai-chat-container[data-theme="dark"] .assistant-message .message-content {
    background: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

.tabesh-ai-chat-container[data-theme="dark"] .chat-input-container {
    background: #1f2937;
    border-top-color: #374151;
}

.tabesh-ai-chat-container[data-theme="dark"] .chat-input {
    background: #374151;
    color: #f3f4f6;
    border-color: #4b5563;
}

.tabesh-ai-chat-container[data-theme="dark"] .chat-input:focus {
    background: #4b5563;
}

.tabesh-ai-chat-container[data-theme="dark"] .message-actions button {
    background: #374151;
    color: #9ca3af;
    border-color: #4b5563;
}

.tabesh-ai-chat-container[data-theme="dark"] .message-actions button:hover {
    background: #4b5563;
    color: #f3f4f6;
}
