/* Modern ChatGPT Design for Abboud with Theme Support */

/* Import Arabic fonts for proper Arabic typography */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@100;200;300;400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@100;200;300;400;500;600;700&display=swap');

/* CSS Variables - Light Theme (Default to match image) */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-hover: #f1f3f4;
    --bg-active: #e8eaed;
    
    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    
    --accent-primary: #1a73e8;
    --accent-hover: #1557b0;
    --accent-light: rgba(26, 115, 232, 0.1);
    
    --border-color: rgba(0, 0, 0, 0.1);
    --border-active: rgba(26, 115, 232, 0.5);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    --sidebar-width: 280px;
    --header-height: 64px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Arabic Typography Variables */
    --font-arabic-primary: 'Noto Sans Arabic', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-arabic-secondary: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', Arial, sans-serif;
    --font-arabic-mono: 'Courier New', monospace;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-primary: #0a1628;
    --bg-secondary: #1a2536;
    --bg-tertiary: #243142;
    --bg-hover: #2d3e51;
    --bg-active: #364960;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --accent-primary: #06b6d4;
    --accent-hover: #0891b2;
    --accent-light: rgba(6, 182, 212, 0.15);
    
    --border-color: rgba(203, 213, 225, 0.1);
    --border-active: rgba(6, 182, 212, 0.5);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}


/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Sidebar Main Logo */
.logo-icon-large .sidebar-main-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Page Header Logo */
.page-header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    margin-top: -8px;
    position: relative;
    z-index: 100;
    overflow: hidden;
}

.page-header-logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.text-logo-small {
    width: 40px;
    height: 40px;
    background: var(--accent-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-arabic-primary);
    font-weight: 600;
    font-size: 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 100;
    transition: var(--transition);
    overflow: hidden;
}

/* Disable hover effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    .app-logo:hover,
    .page-header-logo:hover,
    .text-logo-small:hover {
        background: none !important;
        transform: none !important;
    }
}

/* Avatar Logo in User Profile */
.user-avatar-sidebar .avatar-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* Proper RTL Support for Arabic Interface */
html {
    direction: rtl;
}

body {
    font-family: var(--font-arabic-primary);
    direction: rtl;
    text-align: right;
}

/* Enhanced RTL messaging layout */
.message {
    direction: rtl;
    text-align: right;
    font-family: var(--font-arabic-primary);
}

.message-group {
    direction: rtl;
    width: 100%;
}

.message-content {
    direction: rtl;
    font-family: var(--font-arabic-primary);
    line-height: 1.7;
    word-spacing: 0.05em;
}

/* Proper Arabic text spacing */
.arabic-text {
    letter-spacing: 0.01em;
    word-spacing: 0.1em;
}

/* English content within Arabic context */
.english-content {
    direction: ltr;
    text-align: left;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    height: 100%;
}

body {
    font-family: var(--font-arabic-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    direction: rtl;
    text-align: right;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    /* Better Arabic text rendering */
    font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
    text-rendering: optimizeLegibility;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    direction: rtl;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
    direction: rtl;
    font-family: var(--font-arabic-primary);
    /* Ensure sidebar stays on the right in RTL layout */
    order: 1;
}

.sidebar-header {
    padding: 0rem 1rem 1rem 1rem;
    margin-top: -3rem;
    border-bottom: none;
}

.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: pointer;
}

.app-logo:hover {
    background: var(--bg-hover);
}

.logo-icon-large {
    width: 240px;
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    position: relative;
}

.text-logo {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: white;
    font-size: 2rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    font-family: var(--font-arabic-primary);
}


/* New Chat Button */
.new-chat-btn {
    margin: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-arabic-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.new-chat-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-active);
}

.new-chat-btn i {
    font-size: 0.75rem;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-history-section {
    margin-bottom: 1.5rem;
}

.history-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 1rem;
}

.chat-item {
    padding: 0.625rem 1rem;
    margin: 0.125rem 0;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-primary);
}

.chat-item i {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Footer Controls */
.footer-controls {
    margin-bottom: 1rem;
}

.theme-switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.theme-text {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Theme Switch */
.theme-switch {
    position: relative;
}

.theme-checkbox {
    display: none;
}

.theme-label {
    display: block;
    width: 50px;
    height: 24px;
    background: var(--bg-hover);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.theme-slider {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: var(--bg-primary);
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.theme-icon {
    font-size: 10px;
    position: absolute;
    transition: var(--transition);
}

.light-icon {
    color: #fbbf24;
    opacity: 1;
}

.dark-icon {
    color: #6366f1;
    opacity: 0;
}

.theme-checkbox:checked + .theme-label {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.theme-checkbox:checked + .theme-label .theme-slider {
    transform: translateX(-26px);
    background: var(--accent-primary);
}

.theme-checkbox:checked + .theme-label .light-icon {
    opacity: 0;
}

.theme-checkbox:checked + .theme-label .dark-icon {
    opacity: 1;
    color: white;
}

.theme-label:hover {
    background: var(--bg-hover);
}

/* Sidebar Footer with User Section */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.user-section-sidebar {
    padding: 0.5rem 0;
}

.user-profile-sidebar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.user-profile-sidebar:hover {
    background: var(--bg-hover);
}

.user-avatar-sidebar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-details-sidebar {
    flex: 1;
    min-width: 0;
    direction: rtl;
    text-align: right;
}

.username-sidebar {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-arabic-primary);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-plan-sidebar {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-arabic-primary);
    line-height: 1;
    margin-top: 0.125rem;
}

.user-menu-toggle-sidebar {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.user-menu-toggle-sidebar:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

/* Sidebar User Dropdown */
.sidebar-user-dropdown {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-top: 0.5rem;
    padding: 0.5rem 0;
    box-shadow: var(--shadow-md);
    direction: rtl;
    text-align: right;
}

.sidebar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-arabic-primary);
}

.sidebar-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--text-muted);
    flex-shrink: 0;
    order: 2;
}

.sidebar-dropdown-item span {
    flex: 1;
    order: 1;
}

.sidebar-dropdown-item.logout-btn {
    color: #dc3545;
}

.sidebar-dropdown-item.logout-btn:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.sidebar-dropdown-divider {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* Sidebar Theme Toggle */
.sidebar-theme-toggle {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-switch-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    direction: rtl;
}

.theme-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    user-select: none;
    direction: rtl;
}

.sidebar-theme-toggle .theme-switch {
    transform: scale(0.9);
    flex-shrink: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-plan {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    direction: rtl;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    /* Main content should be on the left in RTL layout */
    order: 2;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    height: 100%;
    overflow: hidden;
    padding-bottom: 1rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 1rem 2rem 1rem;
    direction: rtl;
    background: var(--bg-primary);
    margin-bottom: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
    height: 0; /* Force flex child to respect parent height */
    min-height: 0; /* Prevent flex item from growing beyond container */
}

/* Messages - Chat Bubble Style */
.message-group {
    margin-bottom: 1.25rem;
    animation: fadeIn 0.3s ease-out;
    width: 100%;
    clear: both;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
    max-width: 100%;
    width: 100%;
}

.message.user-message {
    flex-direction: row;
    justify-content: flex-start;
    padding-left: 60px;
    direction: rtl;
}

.message.assistant-message {
    flex-direction: row-reverse;
    justify-content: flex-start;
    padding-left: 60px;
    direction: rtl;
}

.message-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0;
    position: relative;
}

.assistant-avatar {
    background: transparent;
    padding: 0;
    border: none;
    overflow: hidden;
    width: 44px;
    height: 44px;
}

.assistant-avatar img {
    width: 120%;
    height: 120%;
    object-fit: contain;
    border-radius: var(--radius-full);
    transform: scale(1.2);
}

.user-avatar-msg {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    color: white;
    font-weight: 600;
}

.user-message .message-content {
    max-width: 80%;
    position: relative;
    display: flex;
    justify-content: flex-start;
    margin-left: auto;
    direction: rtl;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.assistant-message .message-content {
    max-width: 80%;
    position: relative;
    display: flex;
    justify-content: flex-end;
    margin-left: auto;
    direction: rtl;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.message-bubble {
    padding: 0.875rem 1.125rem;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.6;
    font-size: 0.95rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    display: block;
    overflow: hidden;
}

/* User message bubbles (right side, cyan/blue) */
.user-message .message-bubble {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-hover) 100%);
    color: white;
    border-bottom-left-radius: 6px;
    text-align: right;
    margin-left: auto;
    font-weight: 500;
    direction: rtl;
}

/* Assistant message bubbles (right side, gray) */
.assistant-message .message-bubble {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 6px;
    text-align: right;
    margin-left: auto;
    position: relative;
    direction: rtl;
}

.message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    line-height: 1.7;
    direction: rtl;
    text-align: right;
    max-width: 100%;
    overflow: hidden;
}

.message-text p {
    margin-bottom: 0.5em;
}

.message-text p:last-child {
    margin-bottom: 0;
}

/* Analysis Text Formatting */
.analysis-main-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-light);
    line-height: 1.5;
}

.analysis-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--accent-light), rgba(8, 145, 178, 0.1));
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    margin: 0.5rem 0;
    border-right: 3px solid var(--accent-primary);
}

.analysis-section-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.analysis-levels {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0.25rem 0;
    padding: 0.25rem 0.5rem;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    direction: rtl;
}

.analysis-warning {
    font-size: 0.9rem;
    color: #dc2626;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.1), rgba(239, 68, 68, 0.1));
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border-right: 3px solid #dc2626;
    margin: 1rem 0;
    font-weight: 500;
    line-height: 1.6;
}

.analysis-footer {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    font-style: italic;
    text-align: center;
}

.analysis-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.7;
    margin: 0.5rem 0;
}

.line-break {
    height: 0.75rem;
}

/* Share Container */
.share-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    direction: rtl;
}

.share-dropdown {
    position: relative;
    display: inline-block;
    z-index: 1000;
}

.share-main-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-hover));
    color: var(--accent-primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    direction: rtl;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.share-main-btn:hover {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    border-color: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.share-arrow {
    transition: transform 0.3s ease;
    font-size: 0.75rem;
}

.share-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    margin-top: 0.5rem;
    z-index: 99999;
    overflow: hidden;
}

.share-menu[style*="block"] {
    animation: fadeInDown 0.2s ease;
}

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

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

.share-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: right;
    cursor: pointer;
    transition: all 0.2s ease;
    direction: rtl;
}

.share-option:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.share-option:first-child:hover {
    background: #1da1f2;
    color: white;
}

.share-option:nth-child(2):hover {
    background: #25d366;
    color: white;
}

.share-option:nth-child(3):hover {
    background: #0088cc;
    color: white;
}

.share-option:nth-child(4):hover {
    background: var(--accent-primary);
    color: white;
}

.share-option:nth-child(5):hover {
    background: var(--accent-hover);
    color: white;
}

.share-option.copied {
    background: #10b981;
    color: white;
}

.share-option i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Responsive Design for Share Dropdown */
@media (max-width: 768px) {
    .share-main-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }
    
    .share-menu {
        min-width: 200px;
        right: 0;
        left: auto;
    }
    
    .share-option {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .share-container {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
    }
    
    .share-main-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        width: 100%;
        justify-content: center;
    }
    
    .share-menu {
        min-width: 100%;
        right: 0;
        left: 0;
    }
    
    .share-option {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        justify-content: center;
    }
}

/* Message timestamp */
.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-align: center;
}

/* Typing Indicator */
.typing-indicator-with-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    direction: rtl;
    justify-content: flex-start;
    width: 100%;
}

.typing-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 50%;
}

.typing-indicator {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.input-area {
    padding: 1rem 1rem 3rem 1rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    direction: rtl;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-bottom: env(safe-area-inset-bottom, 1rem);
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
    direction: rtl;
}

/* DESKTOP INPUT SYSTEM - Responsive Design */
.input-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    transition: all 0.2s ease;
    position: relative;
    direction: rtl;
    flex-direction: row;
    overflow: visible;
    min-height: 44px;
    max-width: 100%;
    box-sizing: border-box;
}

.input-wrapper:focus-within {
    border-color: var(--border-active);
    box-shadow: 0 0 0 4px var(--accent-light);
}

/* DESKTOP TEXTAREA - Auto-expand with 3 line limit */
.message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    min-height: 24px;
    max-height: 72px; /* 3 lines: 24px * 3 */
    font-family: inherit;
    overflow-x: hidden;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    box-sizing: border-box;
    width: 100%;
    padding: 8px 0;
    margin: 0;
    /* Hide scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Hide scrollbar for Webkit browsers */
.message-input::-webkit-scrollbar {
    display: none;
}

.message-input::placeholder {
    color: var(--text-muted);
}

/* DESKTOP SEND BUTTON */
.send-button {
    width: auto;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.send-button:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

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

.send-button i {
    font-size: 0.875rem;
}

.abboud-send-btn {
    background: var(--accent-primary);
    position: relative;
}

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

.btn-loading-content {
    display: flex;
    align-items: center;
    gap: 6px;
    direction: rtl;
}

.send-abboud-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.loading-dots {
    display: flex;
    gap: 2px;
    align-items: center;
}

.loading-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
    animation: loading-pulse 1.4s infinite ease-in-out;
}

.loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading-pulse {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.input-footer {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    direction: rtl;
}

/* Loading Spinner */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

/* Utility Classes */
.d-none {
    display: none !important;
}

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

/* Login Page */
.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: var(--radius-lg);
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-primary {
    width: 100%;
    padding: 0.625rem 1rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .chat-area {
        max-width: 90%;
        padding: 0 1rem;
    }
    
    .message.user-message,
    .message.assistant-message {
        padding-left: 40px;
    }
    
    .user-message .message-content,
    .assistant-message .message-content {
        max-width: 85%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        right: -100%;
        z-index: 1;
        transition: right 0.3s ease;
        width: 280px;
    }
    
    /* Fix mobile logo overlap issue */
    .sidebar-header {
        margin-top: 0 !important;
    }
    
    .logo-icon-large {
        width: 96px !important;
        height: 96px !important;
        overflow: hidden !important;
    }
    
    .app-logo {
        padding: 0.5rem !important;
    }
    
    .sidebar.open {
        right: 0;
    }
    
    .main-content {
        margin-right: 0;
        padding: 0;
    }
    
    .chat-area {
        max-width: 100%;
        padding: 0;
    }
    
    .chat-messages {
        padding: 1rem 0.75rem 0.5rem 0.75rem;
    }
    
    .input-area {
        padding: 0.5rem 0.75rem 2rem 0.75rem;
    }
    
    .message.user-message,
    .message.assistant-message {
        padding-left: 20px;
        padding-right: 10px;
    }
    
    .user-message .message-content,
    .assistant-message .message-content {
        max-width: 90%;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
    }
    
    .assistant-avatar {
        width: 36px;
        height: 36px;
    }
    
    .message-bubble {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .chat-messages {
        padding: 0.75rem 0.5rem 0.5rem 0.5rem;
    }
    
    .input-area {
        padding: 0.375rem 0.5rem 1.5rem 0.5rem;
    }
    
    /* MOBILE INPUT SYSTEM - Compact Design */
    .input-wrapper {
        padding: 0.375rem 0.75rem;
        border-radius: var(--radius-lg);
        gap: 0.5rem;
        min-height: 36px;
        align-items: flex-end;
    }
    
    /* MOBILE TEXTAREA - Compact auto-expand */
    .message-input {
        font-size: 0.875rem;
        line-height: 1.4;
        min-height: 20px;
        max-height: 60px; /* 3 lines: 20px * 3 */
        padding: 6px 0;
        margin: 0;
        overflow-y: auto;
        /* Hide scrollbar but keep functionality */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    /* Hide scrollbar for Webkit browsers on mobile */
    .message-input::-webkit-scrollbar {
        display: none;
    }
    
    /* MOBILE SEND BUTTON - Compact */
    .send-button {
        min-width: 28px;
        height: 28px;
        padding: 0 6px;
        border-radius: var(--radius-sm);
        margin-bottom: 4px;
    }
    
    .send-button i {
        font-size: 0.75rem;
    }
    
    .input-footer {
        font-size: 0.6875rem;
        margin-top: 0.25rem;
    }
}

/* TABLET RESPONSIVE DESIGN - Medium screens */
@media (max-width: 768px) and (min-width: 481px) {
    /* TABLET INPUT SYSTEM */
    .input-wrapper {
        padding: 0.4rem 0.875rem;
        border-radius: var(--radius-lg);
        gap: 0.625rem;
        min-height: 40px;
        align-items: flex-end;
    }
    
    /* TABLET TEXTAREA */
    .message-input {
        font-size: 0.9375rem;
        line-height: 1.45;
        min-height: 22px;
        max-height: 66px; /* 3 lines: 22px * 3 */
        padding: 7px 0;
        margin: 0;
        overflow-y: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .message-input::-webkit-scrollbar {
        display: none;
    }
    
    /* TABLET SEND BUTTON */
    .send-button {
        min-width: 32px;
        height: 32px;
        padding: 0 8px;
        border-radius: var(--radius-md);
        margin-bottom: 4px;
    }
    
    .send-button i {
        font-size: 0.8125rem;
    }
    
    .message.user-message,
    .message.assistant-message {
        padding-left: 10px;
        padding-right: 5px;
        margin-bottom: 0.75rem;
    }
    
    .user-message .message-content,
    .assistant-message .message-content {
        max-width: 95%;
    }
    
    .message-bubble {
        font-size: 0.8125rem;
        padding: 0.625rem 0.875rem;
        line-height: 1.5;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    .assistant-avatar {
        width: 32px;
        height: 32px;
    }
}

/* User dropdown menu styles */
.user-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-bottom: 8px;
    min-width: 180px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    border: none;
    background: none;
    width: 100%;
    text-align: right;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.dropdown-item i {
    width: 16px;
    margin-left: 0.5rem;
}

.dropdown-divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.logout-btn {
    color: #e53e3e !important;
}

.logout-btn:hover {
    background: #fed7d7 !important;
    color: #c53030 !important;
}

[data-theme="dark"] .logout-btn:hover {
    background: rgba(229, 62, 62, 0.2) !important;
    color: #fc8181 !important;
}

.user-dropdown-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s;
    margin-right: 0.5rem;
}

.user-menu {
    position: relative;
    cursor: pointer;
}

@media (max-width: 768px) {
    .user-dropdown {
        left: auto;
        right: 0;
        min-width: 200px;
    }
}

/* ==== TOP HEADER LAYOUT STYLES ==== */

/* Top Header */
.top-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 2000 !important;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.5rem;
    max-width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.app-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Header User Menu */
.user-menu-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.user-menu-header:hover {
    background: var(--bg-hover);
}

.user-info-header {
    text-align: left;
    direction: ltr;
}

.user-name-header {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-plan-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1;
}

.user-avatar-header {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.user-dropdown-arrow-header {
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: var(--transition);
}

.user-menu-header:hover .user-dropdown-arrow-header {
    color: var(--text-secondary);
}

/* Header User Dropdown */
.user-dropdown-header {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1001;
    overflow: hidden;
    direction: rtl;
    text-align: right;
    font-family: var(--font-arabic-primary);
}

/* Header Theme Switch */
.theme-switch-container-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Content Layout Updates - Proper RTL Layout */
.content-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    flex-direction: row;
    direction: rtl;
}

/* Updated Layout Classes */
.sidebar.collapsed {
    width: 0;
    border-left: none;
    overflow: hidden;
}

.main-content.sidebar-collapsed {
    width: 100%;
}

/* Enhanced Mobile RTL Support */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }
    
    .app-title {
        display: none;
    }
    
    .user-info-header {
        display: none;
    }
    
    .user-menu-header {
        gap: 0.5rem;
        padding: 0.25rem 0.5rem;
    }
    
    .theme-switch-container-header {
        display: none;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .user-dropdown-header {
        left: -1rem;
        right: auto;
        min-width: 180px;
    }
    
    /* RTL Sidebar Mobile Behavior - Sidebar slides from right */
    .sidebar {
        transform: translateX(100%);
        position: fixed;
        top: var(--header-height);
        right: 0;
        left: auto;
        height: calc(100vh - var(--header-height));
        z-index: 999;
        border-left: none;
        border-right: 1px solid var(--border-color);
    }
    
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }
    
    .main-content {
        height: calc(100vh - var(--header-height));
        margin-right: 0;
        margin-left: 0;
        overflow: hidden;
    }
}

/* Autocomplete Styles */
.autocomplete-container {
    position: relative;
    width: 100%;
}

.autocomplete-dropdown {
    position: fixed;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.12),
        0 8px 16px rgba(0, 0, 0, 0.08),
        0 4px 8px rgba(0, 0, 0, 0.04);
    z-index: 9999;
    max-height: 380px;
    overflow: visible;
    animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: auto;
    visibility: visible;
    display: flex;
    flex-direction: column;
}

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

.autocomplete-header {
    padding: 16px 20px 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    color: #475569;
    font-family: 'Noto Sans Arabic', Arial, sans-serif;
    font-weight: 600;
    border-radius: 16px 16px 0 0;
    letter-spacing: 0.01em;
}

.autocomplete-header i {
    color: #60a5fa;
    font-size: 1em;
    filter: drop-shadow(0 1px 2px rgba(96, 165, 250, 0.2));
}

.autocomplete-results {
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
    padding: 8px 0;
    flex: 1;
    min-height: 0;
}

.autocomplete-results::-webkit-scrollbar {
    width: 8px;
}

.autocomplete-results::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}

.autocomplete-results::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.1));
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.autocomplete-results::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.15));
}

.autocomplete-item {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Noto Sans Arabic', Arial, sans-serif;
    background: #ffffff;
    margin: 0 8px;
    border-radius: 12px;
    position: relative;
    border: 1px solid transparent;
}

.autocomplete-item:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-color: rgba(96, 165, 250, 0.1);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 2px 6px rgba(0, 0, 0, 0.04);
}

.autocomplete-item.selected {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: rgba(96, 165, 250, 0.2);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(96, 165, 250, 0.15),
        0 2px 6px rgba(96, 165, 250, 0.1);
}

.autocomplete-item:not(:last-child) {
    margin-bottom: 4px;
}

.autocomplete-item-main {
    flex: 1;
    text-align: right;
    min-width: 0;
}

.autocomplete-item-title {
    color: #1e293b;
    font-size: 1.05em;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.4;
    letter-spacing: 0.01em;
    transition: color 0.25s ease;
}

.autocomplete-item-symbol {
    color: #60a5fa;
    font-size: 0.9em;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    opacity: 0.9;
    transition: all 0.25s ease;
}

.autocomplete-item:hover .autocomplete-item-title {
    color: #0f172a;
}

.autocomplete-item.selected .autocomplete-item-title {
    color: #1e40af;
}

.autocomplete-item:hover .autocomplete-item-symbol {
    color: #3b82f6;
    opacity: 1;
    transform: scale(1.02);
}

.autocomplete-item.selected .autocomplete-item-symbol {
    color: #1d4ed8;
    opacity: 1;
    transform: scale(1.02);
}

.autocomplete-item-icon {
    margin-left: 16px;
    color: #94a3b8;
    font-size: 1em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

.autocomplete-item:hover .autocomplete-item-icon {
    color: #60a5fa;
    transform: translateX(-3px);
    opacity: 1;
}

.autocomplete-item.selected .autocomplete-item-icon {
    color: #3b82f6;
    transform: translateX(-3px);
    opacity: 1;
}

.autocomplete-footer {
    padding: 14px 20px 18px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
    font-family: 'Noto Sans Arabic', Arial, sans-serif;
    border-radius: 0 0 16px 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.autocomplete-footer small {
    color: #374151;
    font-size: 0.9em;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    opacity: 0.9;
}

.autocomplete-loading {
    padding: 24px 20px;
    text-align: center;
    color: #60a5fa;
    font-size: 1em;
    font-family: 'Noto Sans Arabic', Arial, sans-serif;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 8px 0;
}

.autocomplete-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(96, 165, 250, 0.2);
    border-top: 2px solid #60a5fa;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.autocomplete-no-results {
    padding: 24px 20px;
    text-align: center;
    color: #64748b;
    font-size: 1em;
    font-family: 'Noto Sans Arabic', Arial, sans-serif;
    font-weight: 500;
    margin: 8px 0;
    letter-spacing: 0.01em;
}

/* Responsive adjustments for autocomplete */
@media (max-width: 768px) {
    .autocomplete-dropdown {
        max-height: 320px;
        border-radius: 14px;
        box-shadow: 
            0 16px 32px rgba(0, 0, 0, 0.12),
            0 6px 12px rgba(0, 0, 0, 0.08),
            0 3px 6px rgba(0, 0, 0, 0.04);
        min-width: 300px;
    }
    
    .autocomplete-header {
        padding: 14px 18px 12px;
        border-radius: 14px 14px 0 0;
        font-size: 0.85em;
    }
    
    .autocomplete-results {
        max-height: 200px;
        padding: 6px 0;
    }
    
    .autocomplete-item {
        padding: 14px 16px;
        margin: 0 6px;
        border-radius: 10px;
    }
    
    .autocomplete-item-title {
        font-size: 1em;
        margin-bottom: 5px;
    }
    
    .autocomplete-item-symbol {
        font-size: 0.85em;
    }
    
    .autocomplete-item-icon {
        margin-left: 14px;
        font-size: 0.9em;
    }
    
    .autocomplete-footer {
        padding: 12px 18px 16px;
        border-radius: 0 0 14px 14px;
    }
    
    .autocomplete-footer small {
        font-size: 0.85em;
        font-weight: 600;
    }
    
    .autocomplete-loading {
        padding: 20px 16px;
        font-size: 0.95em;
    }
    
    .autocomplete-no-results {
        padding: 20px 16px;
        font-size: 0.95em;
    }
}


/* ==== VISITOR COUNTER WIDGET STYLES ==== */

/* Visitor Counter Widget */
.visitor-counter-widget {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    direction: rtl;
    transition: var(--transition);
}

.visitor-counter-widget:hover {
    border-color: var(--border-active);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    direction: rtl;
}

.widget-icon {
    color: var(--accent-primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.widget-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    direction: rtl;
}

.widget-stats {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    direction: rtl;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    direction: rtl;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    transition: var(--transition);
}

.stat-item:hover {
    background: var(--bg-hover);
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.2;
    margin-bottom: 0.25rem;
    direction: rtl;
    font-family: "Inter", sans-serif;
    transition: all 0.3s ease;
    transform-origin: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    direction: rtl;
}

/* Loading animation for numbers */
.stat-number.loading {
    opacity: 0.6;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Mobile responsive adjustments for visitor widget */
@media (max-width: 768px) {
    .visitor-counter-widget {
        padding: 0.75rem;
    }
    
    .widget-stats {
        gap: 0.5rem;
    }
    
    .stat-number {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
}
