/* styles.css - Modern Chat Page Styles */

@font-face {
    font-family: 'BYekan';
    src: url('/static/fonts/Yekan.ttf') format('truetype');
}

:root {
    --primary-color: #5f9fe9;
    --secondary-color: #1013d1;
    --text-color: #374151;
    --text-light-color: #6b7280;
    --background-color: #f9fafb;
    --surface-color: #ffffff;
    --border-color: #e5e7eb;
    --accent-color-green: #10b981;
    --accent-color-red: #ef4444;
}

/* Theme colors (adjust as needed for full page) */
.theme-black {
    --background-color: #1a1a1a;
    --surface-color: #2c2c2c;
    --text-color: #ffffff;
    --text-light-color: #d1d5db;
    --border-color: #4b5563;
}

.theme-gray {
    --background-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-color: #374151;
    --text-light-color: #6b7280;
    --border-color: #e5e7eb;
}

.theme-cream {
    --background-color: #fdf6e3;
    --surface-color: #ffffff;
    --text-color: #374151;
    --text-light-color: #6b7280;
    --border-color: #e5e7eb;
}

.theme-offwhite {
    --background-color: #f5f5f5;
    --surface-color: #ffffff;
    --text-color: #374151;
    --text-light-color: #6b7280;
    --border-color: #e5e7eb;
}

body {
    font-family: 'BYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; /* BYekan as primary font */
    background-color: var(--background-color); /* Revert temporary red background */
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
    direction: rtl;
}

.modern-chat-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
    text-align: center;
}

/* Header Styles */
.modern-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 900;
}

.modern-header-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

.nav-link i {
    font-size: 16px;
}

.modern-header-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
}


/* Chat Container and Body */
.modern-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--background-color);
    padding: 30px 0;
}

.modern-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    height: calc(100vh - 200px); /* Set a specific height */
    max-height: calc(100vh - 200px); /* Ensure it doesn't exceed viewport */
}

/* Message Styles (similar to widget for consistency) */
.modern-message-row {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column; /* Stack body and actions vertically */
    gap: 8px; /* Space between message body and actions */
    align-items: flex-start; /* Default align to left for bot */
    animation: messageFadeIn 0.4s ease-out;
}

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

.modern-message-row.user {
    flex-direction: column; /* Stack body and actions vertically for user */
    align-items: flex-start; /* Align the entire user message block to the right */
}

.modern-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modern-avatar.user {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.modern-avatar.bot,
.modern-avatar.bot-avatar {
    background: white;
    color: transparent;
    overflow: hidden;
}

.modern-avatar.bot img,
.modern-avatar.bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.modern-bubble {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 25px;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    white-space: pre-wrap; /* Preserve line breaks by default */
}

.modern-bubble.user-bubble {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-bottom-right-radius: 8px;
    text-align: right;
    width: fit-content;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.modern-bubble.bot-bubble {
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.modern-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

/* Reference badge next to answers */
.ref-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #eef2ff;
    color: #394577;
    font-weight: 700;
    font-size: 12px;
    margin-inline-start: 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.15);
    white-space: nowrap;
}

.ref-badge:hover {
    background: #e6ebff;
}

/* Sources modal */
.sources-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: none; /* hidden by default, shown as flex */
    align-items: center;
    justify-content: center;
}

.sources-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.sources-modal-content {
    position: relative;
    background: var(--surface-color);
    border-radius: 16px;
    width: min(800px, calc(100% - 40px));
    margin: 0 20px; /* centered by flex container */
    padding: 20px 20px 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    max-height: 80vh; /* limit height */
    overflow: auto;   /* make modal itself scrollable */
    z-index: 2;       /* above backdrop */
}

.sources-modal-title {
    margin: 0 0 12px 0;
    font-weight: 700;
    color: var(--text-color);
}

.sources-modal-close {
    position: absolute;
    top: 12px;
    left: 12px;
    border: none;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    color: var(--text-light-color);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 60vh;
    overflow: auto;
}

.source-item {
    display: flex;
    gap: 10px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
}

.source-badge {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #eef2ff;
    border: 1px solid #d9e0ff;
    color: #394577;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.source-text {
    white-space: pre-wrap;
    color: var(--text-color);
}

/* New style for the wrapper around avatar and bubble */
.modern-message-body {
    display: flex;
    align-items: flex-start;
    gap: 15px; /* Space between avatar and bubble */
}

.modern-message-row.user .modern-message-body {
    flex-direction: row; /* Avatar on right, bubble on left for user messages */
}

.modern-message-row.bot .modern-message-body {
    flex-direction: row; /* Avatar on left, bubble on right for bot messages */
}

/* Message Actions (like, dislike, copy, edit) - Clean version */
.modern-message-row:hover .modern-message-actions {
    opacity: 1;
}

.modern-message-row.user .modern-message-actions {
    justify-content: flex-end; /* Align actions to the right for user messages */
}

/* Icon button base styles are now in the clean section above */

.modern-icon-btn:hover {
    background: var(--border-color);
    border-color: var(--text-light-color);
    color: var(--text-color);
    transform: translateY(-1px);
}

.modern-icon-btn.active.like {
    color: white !important;
    border-color: #10b981 !important;
    background: #10b981 !important;
}

.modern-icon-btn.active.dislike {
    color: white !important;
    border-color: #ef4444 !important;
    background: #ef4444 !important;
}

.modern-icon-btn i {
    font-size: 16px;
}

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

/* Suggested questions chips */
.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    justify-content: flex-start;
    align-items: center;
}

.suggestion-chip {
    background: linear-gradient(135deg, #f5f7ff 0%, #eef2ff 100%);
    color: #394577;
    border: 1px solid #d9e0ff;
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.08);
}

.suggestion-chip i {
    color: #667eea;
}

.suggestion-chip:hover {
    background: linear-gradient(135deg, #eef2ff 0%, #e6ebff 100%);
    border-color: #c7d2fe;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

/* Composer/Input Area */
.modern-composer-wrap {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 20px 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    position: sticky;
    bottom: 0;
    z-index: 900;
}

.modern-composer-form {
    max-width: 800px; /* Aligns with container if needed */
    margin: 0 auto;
    padding: 0 0px; /* Matches container padding */
}

.modern-composer {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    background: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: 28px;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.modern-composer:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: var(--surface-color);
}

.modern-composer-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 10px;
    resize: none;
    font-family: inherit;
    font-size: 16px;
    outline: none;
    color: var(--text-color);
    max-height: 150px;
    min-height: 24px;
    direction: rtl;
}

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

.modern-btn {
    border: none;
    padding: 10px 18px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 15px;
}

.modern-btn-send {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-color), 0.3);
    flex-shrink: 0;
}

.modern-btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(var(--primary-color), 0.4);
}

.modern-btn-send:active {
    transform: translateY(0);
}

.modern-btn-clear {
    background: var(--border-color);
    color: var(--text-color);
    flex-shrink: 0;
}

.modern-btn-clear:hover {
    background: #d1d5db;
    transform: translateY(-2px);
}

/* Spinner Styles (keep consistent) */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner-card {
    background: white;
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.loader-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
    margin-bottom: 20px;
}

.loader-dots span {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    margin: 0 5px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loader-dots span:nth-child(1) { animation-delay: -0.32s; }
.loader-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.spinner-text {
    color: var(--text-light-color);
    font-size: 16px;
    margin: 0;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .modern-header-title {
        font-size: 20px;
    }
    
    .modern-header-content {
        flex-direction: column;
        gap: 15px;
        justify-content: center;
    }
    
    .header-nav {
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-link {
        font-size: 13px;
        padding: 6px 12px;
    }

    
    .modern-chat-body {
        padding: 0 15px;
        height: calc(100vh - 180px); /* Adjust for mobile */
        max-height: calc(100vh - 180px);
    }
    
    .modern-bubble {
        max-width: 85%;
        font-size: 15px;
    }
    
    .modern-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .modern-composer-input {
        font-size: 15px;
    }
    
    .modern-btn {
        padding: 8px 15px;
        font-size: 14px;
    }
}

/* Upload Page Styles */
.upload-page {
    font-family: 'BYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

@media (max-width: 768px) {
    .upload-page {
        padding: 10px;
    }
}

.upload-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.upload-form {
    order: 1;
}

.files-section {
    order: 2;
}

@media (max-width: 1024px) {
    .upload-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
    
    .upload-form {
        order: 2;
    }
    
    .files-section {
        order: 1;
    }
}

@media (max-width: 768px) {
    .upload-container {
        padding: 20px;
    }
    
    .upload-grid {
        gap: 20px;
    }
}

.upload-header {
    text-align: center;
    margin-bottom: 30px;
}

.upload-header h2 {
    color: #374151;
    font-weight: 700;
    margin-bottom: 16px;
}

.upload-header h5 {
    color: #6b7280;
    font-size: 18px;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .upload-header h2 {
        font-size: 24px;
        margin-bottom: 12px;
    }
    
    .upload-header h5 {
        font-size: 16px;
        line-height: 1.5;
    }
}

.upload-form {
    background: #f9fafb;
    border-radius: 16px;
    padding: 30px;
    border: 1px solid #e5e7eb;
}

@media (max-width: 768px) {
    .upload-form {
        padding: 20px;
    }
    
    .upload-form .form-control {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .upload-form .btn_send {
        font-size: 14px;
        padding: 10px 20px;
    }
}

.upload-form .form-control {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
}

.upload-form .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.upload-form .btn_send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.upload-form .btn_send:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.files-section {
    background: #f9fafb;
    border-radius: 16px;
    padding: 25px;
    border: 1px solid #e5e7eb;
    height: fit-content;
    min-height: 400px;
}

@media (max-width: 768px) {
    .files-section {
        padding: 20px;
        min-height: 300px;
    }
}

.files-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    color: #374151;
}

.files-header h4 {
    margin: 0;
    font-weight: 600;
    margin-right: 10px;
}

.files-count {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.files-search-container {
    margin-bottom: 20px;
}

.files-search-container input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    background: white;
    transition: all 0.3s ease;
}

.files-search-container input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.files-dropdown {
    position: relative;
}

.files-toggle {
    width: 100%;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.files-toggle i {
    transition: transform 0.3s ease;
}

.files-toggle:hover {
    border-color: #667eea;
}

.files-toggle.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.files-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

@media (max-width: 768px) {
    .files-list {
        max-height: 300px;
    }
}

.files-list.show {
    display: block;
}

.file-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-item.highlighted {
    background-color: #fef3c7;
    border-left: 3px solid #f59e0b;
}

.file-item:hover {
    background-color: #f9fafb;
}

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

.file-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.file-icon {
    margin-left: 10px;
    font-size: 18px;
    color: #667eea;
}

.file-name {
    font-weight: 500;
    color: #374151;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

@media (max-width: 768px) {
    .file-name {
        max-width: 150px;
        font-size: 12px;
    }
    
    .file-date {
        font-size: 10px;
    }
    
    .file-item {
        padding: 6px 10px;
    }
}

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

.file-size {
    font-size: 12px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
}

.no-files {
    text-align: center;
    padding: 20px;
    color: #6b7280;
    font-style: italic;
}

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner-card {
    background: white;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.loader-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
}

.loader-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    animation: loader 1.4s infinite ease-in-out;
}

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

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

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

.spinner-text {
    color: #374151;
    font-weight: 600;
    margin: 0;
}

/* Markdown Page Styles */
.markdown-page {
    font-family: 'BYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

@media (max-width: 768px) {
    .markdown-page {
        padding: 10px;
    }
}

.markdown-container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .markdown-container {
        padding: 20px;
    }
}

.markdown-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f3f4f6;
}

.markdown-header h2 {
    color: #374151;
    font-weight: 700;
    margin-bottom: 16px;
}

.markdown-header .subtitle {
    color: #6b7280;
    font-size: 16px;
}

.markdown-content {
    background: #f9fafb;
    border-radius: 16px;
    padding: 30px;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .markdown-content {
        padding: 20px;
    }
}

.question-section {
    margin-bottom: 30px;
}

.question-section h3 {
    color: #374151;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.question-section h3 i {
    margin-left: 10px;
    color: #667eea;
}

.question-text {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    font-size: 16px;
    line-height: 1.6;
    color: #374151;
}

@media (max-width: 768px) {
    .question-text {
        padding: 15px;
        font-size: 14px;
    }
}

.answer-section h3 {
    color: #374151;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.answer-section h3 i {
    margin-left: 10px;
    color: #10b981;
}

.answer-text {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    font-size: 16px;
    line-height: 1.8;
    color: #374151;
}

@media (max-width: 768px) {
    .answer-text {
        padding: 15px;
        font-size: 14px;
    }
}

.markdown-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

@media (max-width: 768px) {
    .markdown-actions {
        flex-direction: column;
        align-items: center;
    }
}

.btn-markdown {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modern-icon-btn.markdown {
    background: var(--background-color);
    color: var(--text-light-color);
    text-decoration: none;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 16px;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    cursor: pointer;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 10 !important;
}

.modern-icon-btn.markdown:hover {
    background: var(--border-color);
    border-color: var(--text-light-color);
    color: var(--text-color);
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-markdown:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
    color: white;
    text-decoration: none;
}

.btn-markdown.btn-secondary {
    background: #6b7280;
}

.btn-markdown.btn-secondary:hover {
    background: #4b5563;
    color: white;
}

/* Markdown content styling */
.answer-text h1, .answer-text h2, .answer-text h3, .answer-text h4, .answer-text h5, .answer-text h6 {
    color: #374151;
    margin-top: 20px;
    margin-bottom: 10px;
}

.answer-text h1 { font-size: 24px; }
.answer-text h2 { font-size: 22px; }
.answer-text h3 { font-size: 20px; }
.answer-text h4 { font-size: 18px; }
.answer-text h5 { font-size: 16px; }
.answer-text h6 { font-size: 14px; }

.answer-text p {
    margin-bottom: 15px;
}

.answer-text ul, .answer-text ol {
    margin-bottom: 15px;
    padding-right: 20px;
}

.answer-text li {
    margin-bottom: 8px;
}

.answer-text strong {
    font-weight: 700;
    color: #1f2937;
}

.answer-text em {
    font-style: italic;
    color: #4b5563;
}

.answer-text code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #dc2626;
}

.answer-text pre {
    background: #f3f4f6;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 15px;
}

.answer-text blockquote {
    border-right: 4px solid #667eea;
    padding-right: 15px;
    margin: 15px 0;
    color: #6b7280;
    font-style: italic;
}

/* Markdown code display */
.answer-text pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0;
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #333;
}

.answer-text code {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 0;
    border-radius: 0;
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Markdown Text Styles - برای محتوای Markdown در چت */
.markdown-text {
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    font-family: 'BYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.markdown-text h1,
.markdown-text h2,
.markdown-text h3,
.markdown-text h4,
.markdown-text h5,
.markdown-text h6 {
    color: #374151;
    font-weight: 700;
    margin: 1.5em 0 0.5em 0;
    line-height: 1.3;
}

.markdown-text h1 {
    font-size: 1.8em;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.3em;
}

.markdown-text h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.2em;
}

.markdown-text h3 {
    font-size: 1.3em;
}

.markdown-text h4 {
    font-size: 1.1em;
}

.markdown-text h5,
.markdown-text h6 {
    font-size: 1em;
}

.markdown-text p {
    margin: 1em 0;
    color: #4b5563;
}

.markdown-text strong {
    font-weight: 700;
    color: #1f2937;
}

.markdown-text em {
    font-style: italic;
    color: #6b7280;
}

.markdown-text code {
    background-color: #f3f4f6;
    color: #e11d48;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    border: 1px solid #e5e7eb;
}

.markdown-text pre {
    background-color: #1f2937;
    color: #f9fafb;
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
    border: 1px solid #374151;
}

.markdown-text pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
    font-size: 0.9em;
}

.markdown-text ul,
.markdown-text ol {
    margin: 1em 0;
    padding-right: 1.5em;
    color: #4b5563;
}

.markdown-text li {
    margin: 0.5em 0;
    line-height: 1.5;
}

.markdown-text ul li {
    list-style-type: disc;
}

.markdown-text ol li {
    list-style-type: decimal;
}

.markdown-text a {
    color: #3b82f6;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.markdown-text a:hover {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

.markdown-text blockquote {
    border-right: 4px solid #e5e7eb;
    margin: 1em 0;
    padding: 0.5em 1em;
    background-color: #f9fafb;
    color: #6b7280;
    font-style: italic;
}

.markdown-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.markdown-text th,
.markdown-text td {
    padding: 0.75em 1em;
    text-align: right;
    border-bottom: 1px solid #e5e7eb;
}

.markdown-text th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.markdown-text tr:hover {
    background-color: #f9fafb;
}

.markdown-text hr {
    border: none;
    height: 2px;
    background-color: #e5e7eb;
    margin: 2em 0;
}

/* Chat Widget Markdown Styles */
.chat-widget-bubble .markdown-text {
    font-size: 14px;
    line-height: 1.5;
}

.chat-widget-bubble .markdown-text h1,
.chat-widget-bubble .markdown-text h2,
.chat-widget-bubble .markdown-text h3 {
    font-size: 1.2em;
    margin: 0.8em 0 0.4em 0;
}

.chat-widget-bubble .markdown-text h4,
.chat-widget-bubble .markdown-text h5,
.chat-widget-bubble .markdown-text h6 {
    font-size: 1.1em;
    margin: 0.6em 0 0.3em 0;
}

.chat-widget-bubble .markdown-text pre {
    font-size: 12px;
    padding: 0.8em;
    margin: 0.8em 0;
}

.chat-widget-bubble .markdown-text code {
    font-size: 12px;
    padding: 0.1em 0.3em;
}

.chat-widget-bubble .markdown-text ul,
.chat-widget-bubble .markdown-text ol {
    padding-right: 1.2em;
    margin: 0.8em 0;
}

.chat-widget-bubble .markdown-text li {
    margin: 0.3em 0;
}

/* Modern Message Markdown Styles */
.modern-bubble .markdown-text {
    font-size: 15px;
    line-height: 1.6;
}

.modern-bubble .markdown-text h1,
.modern-bubble .markdown-text h2,
.modern-bubble .markdown-text h3 {
    font-size: 1.3em;
    margin: 1em 0 0.5em 0;
}

.modern-bubble .markdown-text h4,
.modern-bubble .markdown-text h5,
.modern-bubble .markdown-text h6 {
    font-size: 1.1em;
    margin: 0.8em 0 0.4em 0;
}

.modern-bubble .markdown-text pre {
    font-size: 13px;
    padding: 1em;
    margin: 1em 0;
}

.modern-bubble .markdown-text code {
    font-size: 13px;
    padding: 0.2em 0.4em;
}

.modern-bubble .markdown-text ul,
.modern-bubble .markdown-text ol {
    padding-right: 1.5em;
    margin: 1em 0;
}

.modern-bubble .markdown-text li {
    margin: 0.5em 0;
}

/* Clean action buttons styling */
.modern-message-actions {
    display: flex !important;
    gap: 10px !important;
    margin-top: 8px !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 10 !important;
}

.modern-message-actions.user-actions {
    justify-content: flex-end !important;
}

.modern-icon-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: var(--background-color) !important;
    color: var(--text-light-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px !important;
    padding: 8px 12px !important;
    min-width: 36px !important;
    height: 36px !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 10 !important;
    text-decoration: none !important;
}

/* Widget specific styling */
.chat-widget-actions {
    display: flex !important;
    gap: 10px !important;
    margin-top: 8px !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.chat-widget-icon-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    visibility: visible !important;
    background: var(--background-color) !important;
    color: var(--text-light-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px !important;
    padding: 8px 12px !important;
    min-width: 36px !important;
    height: 36px !important;
    cursor: pointer !important;
    text-decoration: none !important;
}


/* Register Page Styles */
.register-page {
    font-family: 'BYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.register-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.register-header {
    text-align: center;
    margin-bottom: 30px;
}

.register-header h2 {
    color: #374151;
    font-weight: 700;
    margin-bottom: 16px;
}

.register-header h5 {
    color: #6b7280;
    font-size: 18px;
    line-height: 1.6;
}

.register-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.register-form {
    background: #f9fafb;
    border-radius: 16px;
    padding: 30px;
    border: 1px solid #e5e7eb;
}

.users-section {
    background: #f9fafb;
    border-radius: 16px;
    padding: 25px;
    border: 1px solid #e5e7eb;
    height: fit-content;
    min-height: 400px;
}

.users-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    color: #374151;
}

.users-header h4 {
    margin: 0;
    font-weight: 600;
    margin-right: 10px;
}

.users-count {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.register-form .form-control,
.form-control.register-form {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
    margin-bottom: 15px;
}

.register-form .form-control:focus,
.form-control.register-form:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.btn_register {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    width: 100%;
}

.btn_register:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.btn_register:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.user-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.user-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.user-info h6 {
    margin: 0;
    color: #374151;
    font-weight: 600;
}

.user-info p {
    margin: 5px 0 0 0;
    color: #6b7280;
    font-size: 14px;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.btn-delete {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.btn-delete:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.alert {
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border: none;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.no-users {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.no-users i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #d1d5db;
}

@media (max-width: 1024px) {
    .register-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }
}

@media (max-width: 768px) {
    .register-container {
        padding: 20px;
    }
    
    .register-grid {
        gap: 20px;
    }
    
    .register-form {
        padding: 20px;
    }
    
    .users-section {
        padding: 20px;
    }
}

/* Login Modal Styles */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-modal.show {
    display: flex;
}

.login-modal-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-header h3 {
    color: #374151;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: #6b7280;
    font-size: 14px;
}

.login-form .form-control {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
    margin-bottom: 15px;
    width: 100%;
}

.login-form .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.btn_login {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    width: 100%;
}

.btn_login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.btn_login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    font-size: 14px;
    display: none;
}

/* Login Sidebar */
.login-sidebar {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
    z-index: 1000;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.login-sidebar i {
    font-size: 20px;
}

.login-sidebar span {
    font-size: 12px;
    font-weight: 500;
}

/* User Sidebar - کادر یکپارچه با تم اصلی */
.user-sidebar {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
    z-index: 1000;
    transition: all 0.3s ease;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.user-sidebar .user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.user-sidebar .user-info i {
    font-size: 20px;
}

.user-sidebar .user-info span {
    font-size: 12px;
    font-weight: 500;
}

.logout-btn-vertical {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    gap: 4px;
    width: 50px;
    height: 50px;
}

.logout-btn-vertical i {
    font-size: 14px;
}

.logout-btn-vertical span {
    font-size: 10px;
    font-weight: 500;
}

.logout-btn-vertical:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.user-sidebar:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
}


.login-sidebar:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
}

.login-sidebar i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.login-sidebar span {
    font-size: 12px;
    font-weight: 600;
    display: block;
}

.login-sidebar.logged-in {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.login-sidebar.logged-in i {
    color: white;
}

@media (max-width: 768px) {
    .login-sidebar {
        left: 10px;
        padding: 15px;
        min-width: 50px;
    }
    
    .login-sidebar i {
        font-size: 20px;
    }
    
    .login-sidebar span {
        font-size: 10px;
    }
}

/* Chat Widget Login Styles */
.chat-widget-login {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 20px;
    margin: 15px 0;
    border: none;
}

.chat-widget-login .login-header {
    text-align: center;
    margin-bottom: 15px;
}

.chat-widget-login .login-header h4 {
    color: white;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 16px;
}

.chat-widget-login .login-header p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin: 0;
}

.chat-widget-login .form-control {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    margin-bottom: 10px;
    width: 100%;
}

.chat-widget-login .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
    outline: none;
}

.chat-widget-login .btn_login {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    width: 100%;
}

.chat-widget-login .btn_login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-widget-login .btn_login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chat-widget-login .login-error {
    background: rgba(220, 38, 38, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 10px;
    font-size: 12px;
    display: none;
}

.chat-widget-user-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 15px;
    margin: 15px 0;
    display: none;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-user-info .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.chat-widget-user-info .user-info i {
    font-size: 16px;
}

.chat-widget-user-info .btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    transition: all 0.3s ease;
}

.chat-widget-user-info .btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}