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

        #mainMenu {
            min-width: 220px;
            border-radius: 16px;
            padding: 8px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
            backdrop-filter: blur(10px);
        }

        #mainMenu .dropdown-item {
            border-radius: 12px;
            margin-bottom: 4px;
            transition: all .2s ease;
        }

        #mainMenu .dropdown-item:hover {
            background: rgba(0, 191, 255, 0.08);
            transform: translateX(-2px);
        }

        :root {
            /* Premium Tut Design System */
            --primary: #76d6d5;
            --secondary: #e9c176;
            --accent: #76d6d5;

            /* Light mode */
            --bg-light: #f7faf9;
            --bg-secondary-light: #f1f4f3;
            --border-light: #bec9c8;
            --text-light: #181c1c;
            --text-secondary-light: #3e4948;

            /* Dark mode — premium deep navy */
            --bg-dark: #0e131f;
            --bg-secondary-dark: #1a1f2c;
            --border-dark: #3e4949;
            --text-dark: #dee2f3;
            --text-secondary-dark: #bdc9c8;

            --shadow-sm: 0 2px 8px rgba(0,0,0,0.12);
            --shadow-md: 0 4px 16px rgba(0,0,0,0.18);
            --shadow-lg: 0 10px 40px rgba(118,214,213,0.15);
        }

        body {
            font-family: 'Almarai', 'Poppins', sans-serif;
            background: var(--bg-light);
            color: var(--text-light);
            transition: background-color 0.3s ease, color 0.3s ease;
            direction: rtl;
        }

        /* When user switches to English */
        body[dir="ltr"],
        html[dir="ltr"] body {
            direction: ltr;
        }

        /* Arabic RTL text in messages */
        [dir="rtl"] .message-bubble,
        body:not([dir="ltr"]) .message-bubble {
            text-align: right;
        }

        [dir="ltr"] .message-bubble {
            text-align: left;
        }

        body.dark-mode {
            background: var(--bg-dark);
            color: var(--text-dark);
        }

        /* ===== MODAL ===== */
        .modal {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 9999;
            animation: fadeIn 0.3s ease-out;
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background: var(--bg-light);
            border-radius: 20px;
            padding: 40px;
            box-shadow: var(--shadow-lg);
            max-width: 400px;
            width: 100%;
            animation: slideUp 0.4s ease-out;
            position: relative;
        }

        .dark-mode .modal-content {
            background: var(--bg-secondary-dark);
        }

        .modal-close {
            position: absolute;
            top: 15px;
            left: 15px;
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            color: var(--text-secondary-light);
            transition: all 0.3s ease;
        }

        .dark-mode .modal-close {
            color: var(--text-secondary-dark);
        }

        .modal-close:hover {
            transform: scale(1.2);
        }

        .modal-title {
            font-size: 28px;
            margin-bottom: 10px;
            background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .modal-subtitle {
            color: var(--text-secondary-light);
            margin-bottom: 25px;
            font-size: 14px;
        }

        .dark-mode .modal-subtitle {
            color: var(--text-secondary-dark);
        }

        .form-group {
            margin-bottom: 18px;
        }

        .form-group label {
            display: block;
            margin-bottom: 6px;
            font-weight: 600;
            font-size: 13px;
            text-transform: uppercase;
            color: var(--text-secondary-light);
        }

        .dark-mode .form-group label {
            color: var(--text-secondary-dark);
        }

        .form-group input,
        .form-group select {
            width: 100%;
            padding: 12px 14px;
            border: 2px solid var(--border-light);
            border-radius: 10px;
            font-family: inherit;
            font-size: 14px;
            transition: all 0.3s ease;
            background: var(--bg-light);
            color: var(--text-light);
        }

        .dark-mode .form-group input,
        .dark-mode .form-group select {
            background: var(--bg-secondary-dark);
            border-color: var(--border-dark);
            color: var(--text-dark);
        }

        .form-group input:focus,
        .form-group select:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.1);
        }

        .btn {
            width: 100%;
            padding: 12px;
            border: none;
            border-radius: 10px;
            font-weight: 700;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-family: inherit;
            margin-top: 8px;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
            color: white;
            box-shadow: var(--shadow-md);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-lg);
        }

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

        .toggle-form {
            text-align: center;
            margin-top: 15px;
            font-size: 13px;
            color: var(--text-secondary-light);
        }

        .dark-mode .toggle-form {
            color: var(--text-secondary-dark);
        }

        .toggle-form button {
            background: none;
            border: none;
            color: var(--primary);
            cursor: pointer;
            font-weight: 600;
            text-decoration: underline;
            font-family: inherit;
        }

        /* ===== MAIN APP ===== */
        .app-container {
            display: flex;
            flex-direction: column;
            height: 100vh;
            background: var(--bg-light);
            transition: background-color 0.3s ease;
            overflow: hidden;
        }

        .dark-mode .app-container {
            background: var(--bg-dark);
        }

        /* ===== HEADER ===== */
        .app-header {
            background: linear-gradient(135deg, #0e131f 0%, #1a2333 60%, #004f4f 100%);
            color: white;
            padding: 10px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: var(--shadow-md);
            height: 60px;
        }

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

        .logo {
            width: 44px;
            height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: rgba(233,193,118,0.12);
            border: 1.5px solid rgba(233,193,118,0.4);
            overflow: hidden;
        }

        .logo img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .header-text {
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        .logo-text {
            font-size: 16px;
            font-weight: 800;
            letter-spacing: -0.5px;
            line-height: 1.2;
            color: #e9c176;
            text-shadow: 0 0 12px rgba(233,193,118,0.4);
        }

        .website-name {
            font-size: 11px;
            font-weight: 600;
            opacity: 0.9;
        }

        .header-right {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .header-button {
            background: rgba(255, 255, 255, 0.15);
            border: none;
            color: white;
            padding: 8px 14px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 6px;
            font-family: inherit;
        }

        .header-button:hover {
            background: rgba(255, 255, 255, 0.25);
            transform: translateY(-1px);
        }

        .header-button-icon {
            font-size: 14px;
        }

        .dropdown {
            position: relative;
        }

        .dropdown-menu {
            display: none;
            position: fixed;
            top: auto;
            left: auto;
            right: auto;
            background: var(--bg-light);
            border: 1px solid var(--border-light);
            border-radius: 10px;
            box-shadow: var(--shadow-lg);
            min-width: 200px;
            margin-top: 8px;
            z-index: 9999;
        }

        .dark-mode .dropdown-menu {
            background: var(--bg-secondary-dark);
            border-color: var(--border-dark);
        }

        .dropdown-menu.active {
            display: block;
        }

        .dropdown-item {
            padding: 12px 16px;
            border: none;
            background: none;
            cursor: pointer;
            font-family: inherit;
            font-size: 13px;
            width: 100%;
            text-align: right;
            color: var(--text-light);
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
        }

        .dark-mode .dropdown-item {
            color: var(--text-dark);
        }

        .dropdown-item:hover {
            background: var(--bg-secondary-light);
        }

        .dark-mode .dropdown-item:hover {
            background: var(--bg-secondary-dark);
        }

        .dropdown-divider {
            height: 1px;
            background: var(--border-light);
            margin: 6px 0;
        }

        .dark-mode .dropdown-divider {
            background: var(--border-dark);
        }

        /* ===== MAIN LAYOUT ===== */
        .app-main {
            display: flex;
            flex: 1;
            overflow: hidden;
            min-height: 0;
        }

        /* ===== CHAT SECTION ===== */
        .chat-section {
            display: flex;
            flex-direction: column;
            flex: 1;
            overflow: hidden;
            background: var(--bg-light);
            min-height: 0;
        }

        .dark-mode .chat-section {
            background: var(--bg-dark);
        }

        .messages-container {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 16px 20px 8px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-height: 0;
            scroll-behavior: smooth;
        }

        /* ===== MESSAGES ===== */
        .message {
            display: flex;
            animation: slideIn 0.3s ease-out;
            align-items: flex-end;
            gap: 8px;
            width: 100%;
            margin-bottom: 4px;
        }

        /* BOT: icon always on the LEFT (start), bubble on right */
        .message.bot {
            flex-direction: row !important;
            justify-content: flex-start;
        }

        /* USER: bubble on right edge, no icon */
        .message.user {
            flex-direction: row !important;
            justify-content: flex-end;
        }

        .message-icon {
            width: 36px;
            height: 36px;
            min-width: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(233,193,118,0.1);
            border: 1.5px solid rgba(233,193,118,0.35);
            overflow: hidden;
            flex-shrink: 0;
            order: 0;
        }

        .dark-mode .message-icon {
            background: rgba(233,193,118,0.08);
            border-color: rgba(233,193,118,0.3);
        }

        .message-icon img {
            width: 36px;
            height: 36px;
            object-fit: cover;
            border-radius: 50%;
        }

        .message-bot-name {
            font-size: 11px;
            font-weight: 700;
            color: #e9c176;
            text-shadow: 0 0 8px rgba(233,193,118,0.35);
            margin-bottom: 3px;
            display: block;
            text-align: left;
        }

        .message-bubble {
            max-width: 68%;
            padding: 10px 14px;
            border-radius: 18px;
            word-wrap: break-word;
            line-height: 1.55;
            font-size: 14px;
        }

        /* Bot bubble: left-aligned text, left accent */
        .message.bot .message-content {
            align-items: flex-start;
        }

        .message.bot .message-bubble {
            background: var(--bg-secondary-light);
            color: var(--text-light);
            border-radius: 18px;
            border-left: 3px solid rgba(233,193,118,0.7);
        }

        .dark-mode .message.bot .message-bubble {
            background: rgba(26,31,44,0.85);
            color: var(--text-dark);
            border-left: 3px solid rgba(233,193,118,0.6);
            backdrop-filter: blur(12px);
            border-top: 1px solid rgba(255,255,255,0.08);
        }

        /* User bubble: right-aligned */
        .message.user .message-content {
            align-items: flex-end;
            max-width: 75%;
        }

        .message.user .message-bubble {
            background: linear-gradient(135deg, #1a2f3f 0%, #0e1f2e 100%);
            color: #dee2f3;
            border-radius: 18px;
            text-align: center;
            width: fit-content;
            max-width: 100%;
            word-break: break-word;
            white-space: nowrap;
            border: 1px solid rgba(118,214,213,0.2);
        }

        .message-time {
            font-size: 10px;
            opacity: 0.5;
            margin-top: 3px;
            padding: 0 4px;
        }

        .message.user .message-time {
            text-align: right;
        }

        .message.bot .message-time {
            text-align: left;
        }

        .message-content {
            display: flex;
            flex-direction: column;
            max-width: 70%;
        }

        /* ===== INPUT AREA ===== */
        .input-area {
            padding: 12px 20px;
            background: var(--bg-secondary-light);
            border-top: 1px solid var(--border-light);
            display: flex;
            gap: 10px;
            flex-shrink: 0;
        }

        .dark-mode .input-area {
            background: var(--bg-secondary-dark);
            border-top-color: var(--border-dark);
        }

        .input-wrapper {
            flex: 1;
            display: flex;
            background: var(--bg-light);
            border: 1px solid var(--border-light);
            border-radius: 8px;
            padding: 8px 12px;
            transition: all 0.3s ease;
        }

        .dark-mode .input-wrapper {
            background: var(--bg-secondary-dark);
            border-color: var(--border-dark);
        }

        .input-wrapper:focus-within {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.1);
        }

        .input-wrapper input {
            flex: 1;
            border: none;
            outline: none;
            background: none;
            font-family: inherit;
            font-size: 14px;
            color: var(--text-light);
        }

        .dark-mode .input-wrapper input {
            color: var(--text-dark);
        }

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

        .dark-mode .input-wrapper input::placeholder {
            color: var(--text-secondary-dark);
        }

        .send-btn {
            width: 36px;
            height: 36px;
            border-radius: 6px;
            border: none;
            background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            font-size: 16px;
        }

        .send-btn:hover {
            transform: scale(1.05);
        }

        /* ===== SIDEBAR ===== */
        .sidebar {
            width: 260px;
            min-width: 260px;
            background: var(--bg-secondary-light);
            border-inline-start: 1px solid var(--border-light);
            display: none;
            flex-direction: column;
            overflow: hidden;
            flex-shrink: 0;
        }

        .sidebar.open {
            display: flex;
        }

        .dark-mode .sidebar {
            background: var(--bg-secondary-dark);
            border-left-color: var(--border-dark);
        }

        .sidebar-header {
            padding: 15px;
            border-bottom: 1px solid var(--border-light);
            font-weight: 700;
            font-size: 14px;
        }

        .dark-mode .sidebar-header {
            border-bottom-color: var(--border-dark);
        }

        .chat-history {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
        }

        .history-item {
            padding: 10px;
            background: var(--bg-light);
            border-radius: 6px;
            margin-bottom: 8px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s ease;
            border-right: 3px solid transparent;
            color: var(--text-secondary-light);
            word-break: break-word;
            max-height: 60px;
            overflow: hidden;
        }

        .dark-mode .history-item {
            background: var(--bg-secondary-dark);
            color: var(--text-secondary-dark);
        }

        .history-item:hover {
            background: var(--bg-light);
            border-right-color: var(--primary);
            color: var(--text-light);
        }

        .dark-mode .history-item:hover {
            background: #3a3a3a;
        }

        /* ===== ANIMATIONS ===== */
        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateX(-10px);
            }

            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        @keyframes pulse {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.5;
            }
        }

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

        .typing-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--primary);
            animation: pulse 1.4s infinite;
        }

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

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

        /* ===== RESPONSIVE ===== */
        @media (max-width: 768px) {
            .app-main {
                grid-template-columns: 1fr;
            }

            .sidebar {
                display: none;
            }

            .message-bubble {
                max-width: 85%;
            }

            .modal-content {
                margin: 20px;
            }

            .header-right {
                gap: 5px;
            }

            .header-button {
                padding: 6px 10px;
                font-size: 11px;
            }
        }

        /* ===== SCROLLBAR ===== */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--bg-secondary-light);
        }

        .dark-mode ::-webkit-scrollbar-track {
            background: var(--bg-secondary-dark);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--border-light);
            border-radius: 4px;
        }

        .dark-mode ::-webkit-scrollbar-thumb {
            background: var(--border-dark);
        }

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

        .form-toggle {
            display: none;
        }

        .form-toggle.active {
            display: block;
        }

        /* ===== MENU ICON ONLY BUTTON ===== */
        .menu-icon-only {
            padding: 8px 12px !important;
            min-width: unset !important;
        }

        .menu-icon-only .header-button-icon {
            font-size: 20px;
            margin: 0;
        }

        /* ===== SLIDING NAV SIDEBAR ===== */
        .nav-sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.45);
            z-index: 1200;
            backdrop-filter: blur(2px);
            animation: fadeIn 0.25s ease;
        }

        .nav-sidebar-overlay.open {
            display: block;
        }

        .nav-sidebar {
            position: fixed;
            top: 0;
            left: -300px;
            width: 270px;
            height: 100vh;
            background: linear-gradient(160deg, #0e131f 0%, #1a2333 60%, #0a2020 100%);
            z-index: 1300;
            display: flex;
            flex-direction: column;
            padding: 0;
            box-shadow: 6px 0 30px rgba(0,0,0,0.4);
            transition: left 0.32s cubic-bezier(0.4, 0, 0.2, 1);
            border-right: 1px solid rgba(118,214,213,0.12);
            overflow: hidden;
        }

        [dir="ltr"] .nav-sidebar {
            left: unset;
            right: -300px;
            border-right: none;
            border-left: 1px solid rgba(118,214,213,0.12);
            box-shadow: -6px 0 30px rgba(0,0,0,0.4);
            transition: right 0.32s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .nav-sidebar.open {
            left: 0;
        }

        [dir="ltr"] .nav-sidebar.open {
            left: unset;
            right: 0;
        }

        .nav-sidebar-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 22px 20px 18px;
            border-bottom: 1px solid rgba(118,214,213,0.15);
            background: rgba(118,214,213,0.05);
        }

        .nav-sidebar-title {
            font-size: 16px;
            font-weight: 700;
            color: var(--primary);
            letter-spacing: 0.5px;
        }

        .nav-sidebar-close {
            background: none;
            border: none;
            color: rgba(255,255,255,0.5);
            font-size: 18px;
            cursor: pointer;
            padding: 4px 8px;
            border-radius: 6px;
            transition: all 0.2s;
            font-family: inherit;
        }

        .nav-sidebar-close:hover {
            color: var(--primary);
            background: rgba(118,214,213,0.1);
        }

        /* Nav items */
        .nav-item {
            display: flex;
            align-items: center;
            gap: 14px;
            width: 100%;
            padding: 16px 22px;
            background: none;
            border: none;
            border-bottom: 1px solid rgba(255,255,255,0.05);
            color: rgba(222,226,243,0.85);
            font-size: 14px;
            font-weight: 600;
            font-family: inherit;
            cursor: pointer;
            text-align: right;
            transition: all 0.2s ease;
            position: relative;
        }

        [dir="ltr"] .nav-item {
            text-align: left;
        }

        .nav-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 3px;
            background: var(--primary);
            border-radius: 0 3px 3px 0;
            transform: scaleY(0);
            transition: transform 0.2s ease;
        }

        [dir="ltr"] .nav-item::before {
            left: unset;
            right: 0;
            border-radius: 3px 0 0 3px;
        }

        .nav-item:hover {
            background: rgba(118,214,213,0.08);
            color: #fff;
            padding-left: 28px;
        }

        [dir="ltr"] .nav-item:hover {
            padding-left: 22px;
            padding-right: 28px;
        }

        .nav-item:hover::before {
            transform: scaleY(1);
        }

        .nav-item-icon {
            font-size: 18px;
            flex-shrink: 0;
        }