@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
    --bg-dark: #050102; /* deeper black-red */
    --bg-panel: rgba(15, 4, 6, 0.45); /* much more transparent */
    --bg-card: rgba(22, 6, 9, 0.4);
    --border-crimson: rgba(239, 68, 68, 0.2);
    --border-highlight: rgba(255, 255, 255, 0.08); /* inner light for premium feel */
    --border-hover: rgba(239, 68, 68, 0.5);
    --primary-blood: #dc2626;
    --primary-blood-hover: #ef4444;
    --primary-dark: #991b1b;
    --text-white: #f8fafc;
    --text-muted: #fca5a5;
    --text-sub: #94a3b8;
    --glass-blur: blur(24px) saturate(180%);
    --shadow-obsidian: 0 12px 40px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html {
    font-size: 13.8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(220, 38, 38, 0.35) 0%, transparent 45%),
        radial-gradient(circle at 90% 90%, rgba(185, 28, 28, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(153, 27, 27, 0.2) 0%, transparent 65%);
    background-attachment: fixed;
    color: var(--text-white);
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    direction: rtl;
}

body::before {
    content: '';
    position: absolute;
    top: -150px;
    right: -150px;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.18) 0%, transparent 70%);
    filter: blur(80px);
    z-index: 0;
    pointer-events: none;
}

.svg-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    transition: transform 0.2s ease, stroke 0.2s ease;
}

.brand-logo-img {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.6));
    flex-shrink: 0;
}

.sidebar-logo-img {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.7));
    flex-shrink: 0;
}

.auth-logo-img {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(239, 68, 68, 0.8));
    margin-bottom: 4px;
}

.sender-avatar-img {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.5));
    flex-shrink: 0;
}

/* ================== الشريط الجانبي المدمج (235px) ================== */
.sidebar {
    width: 235px;
    background: rgba(12, 3, 5, 0.45);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--border-crimson);
    border-right: 1px solid rgba(255,255,255,0.03);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary-dark);
    border-radius: 8px;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-crimson);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.08rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
    letter-spacing: -0.01em;
}

.btn-close-sidebar {
    display: none;
}

.sidebar-content {
    padding: 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-glass, .select-glass {
    background: rgba(10, 3, 5, 0.85);
    border: 1px solid var(--border-crimson);
    color: var(--text-white);
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.82rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

.input-glass:focus, .select-glass:focus {
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(10, 3, 5, 0.4);
    border: 1px solid var(--border-crimson);
    border-radius: 10px;
    padding: 8px 10px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
    font-weight: 700;
    color: #fecaca;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(220, 38, 38, 0.2);
    border-radius: 4px;
    outline: none;
    margin: 4px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ef4444;
    cursor: pointer;
    box-shadow: 0 0 8px #ef4444;
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.btn-sidebar {
    background: rgba(220, 38, 38, 0.14);
    border: 1px solid var(--border-crimson);
    color: #fca5a5;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.btn-sidebar:hover {
    background: rgba(220, 38, 38, 0.32);
    border-color: #ef4444;
    color: #fff;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.35);
}

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border-crimson);
    font-size: 0.72rem;
    color: var(--text-sub);
    text-align: center;
}

.user-profile-card {
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid var(--border-crimson);
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-profile-card.pro {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(185, 28, 28, 0.25));
    border-color: rgba(234, 179, 8, 0.5);
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.25);
}

.user-profile-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.user-profile-info strong {
    font-size: 0.84rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile-info small {
    font-size: 0.7rem;
    color: #4ade80;
    font-weight: 700;
}

.user-profile-card.pro small {
    color: #facc15;
    text-shadow: 0 0 8px rgba(250, 204, 21, 0.5);
}

/* ================== الحاوية الرئيسية للمحادثة ================== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    z-index: 5;
    min-width: 0;
}

.chat-navbar {
    background: rgba(14, 6, 9, 0.88);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 0 14px;
    height: 46px;
    border-bottom: 1px solid var(--border-crimson);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    gap: 10px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.btn-mobile-menu {
    display: none;
}

.nav-title h1 {
    font-size: 1rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fff 0%, #fca5a5 60%, #ef4444 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.nav-center-model {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 280px;
    margin: 0 10px;
}

.top-model-select {
    background: rgba(220, 38, 38, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 99px;
    padding: 5px 14px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    width: 100%;
    text-overflow: ellipsis;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

.top-model-select:hover, .top-model-select:focus {
    background: rgba(220, 38, 38, 0.28);
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-upgrade-pro {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: 1px solid #fbbf24;
    color: #fff;
    font-size: 0.74rem;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 99px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
    white-space: nowrap;
}

.btn-upgrade-pro:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.6);
}

.badge-pro-nav {
    background: rgba(234, 179, 8, 0.2);
    border: 1px solid rgba(234, 179, 8, 0.5);
    color: #facc15;
    font-size: 0.74rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 99px;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.25);
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(220, 38, 38, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.35);
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fca5a5;
    flex-shrink: 0;
}

.pulse-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px #ef4444; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

.messages-container {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.messages-container::-webkit-scrollbar {
    width: 4px;
}
.messages-container::-webkit-scrollbar-thumb {
    background: rgba(220, 38, 38, 0.3);
    border-radius: 8px;
}

.chat-center-col {
    max-width: 740px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-card {
    border-radius: 14px;
    padding: 14px 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.18s ease;
}

.message-card.user {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.2), rgba(153, 27, 27, 0.05));
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom-right-radius: 4px;
    max-width: 82%;
    box-shadow: 0 8px 24px rgba(185, 28, 28, 0.25), inset 0 1px 0 rgba(255,255,255,0.1);
}

.message-card.ai {
    align-self: flex-end;
    background: rgba(18, 5, 8, 0.5);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-crimson);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom-left-radius: 4px;
    width: 100%;
    box-shadow: var(--shadow-obsidian);
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 700;
    color: #fecaca;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.message-sender {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sender-avatar {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 900;
    background: rgba(239, 68, 68, 0.22);
    color: #fff;
    border: 1px solid rgba(239, 68, 68, 0.45);
}

.message-body {
    line-height: 1.7;
    font-size: 0.92rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: #f8fafc;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-sub);
    padding-top: 4px;
}

.btn-copy {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.12);
    color: #fca5a5;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-copy:hover {
    background: rgba(239,68,68,0.22);
    border-color: #ef4444;
    color: #fff;
}

/* ================== شريط الإدخال العائم الأنيق ================== */
.input-section {
    background: transparent;
    padding: 0 16px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.input-container-centered {
    max-width: 740px;
    width: 100%;
    margin: 0 auto;
}

.input-box {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(14, 5, 8, 0.88);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 18px;
    padding: 8px 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75);
    transition: all 0.2s ease;
}

.input-box:focus-within {
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35), 0 10px 30px rgba(0, 0, 0, 0.8);
}

.input-box textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-white);
    padding: 6px 4px;
    resize: none;
    height: 40px;
    outline: none;
    font-size: 0.9rem;
}

.btn-submit {
    background: linear-gradient(135deg, #ef4444 0%, #991b1b 100%);
    color: #fff;
    border: 1px solid rgba(248, 113, 113, 0.4);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.4);
    flex-shrink: 0;
}

.btn-submit:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #f87171 0%, #b91c1c 100%);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.btn-submit:disabled {
    background: rgba(30, 10, 16, 0.7);
    border-color: rgba(239, 68, 68, 0.15);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-stop {
    background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%);
    color: #fff;
    border: 1px solid #f87171;
    height: 38px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
    flex-shrink: 0;
}

.btn-stop:hover {
    background: linear-gradient(135deg, #f87171 0%, #b91c1c 100%);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    transform: scale(1.03);
}

/* ================== نافذة إعدادات الحساب وربط AI Horde ================== */
.account-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 2, 3, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 999999 !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    direction: rtl;
}

.account-modal-overlay.open {
    display: flex !important;
}

.account-modal-card {
    background: rgba(18, 6, 10, 0.94);
    border: 2px solid #ef4444;
    border-radius: 22px;
    max-width: 580px;
    width: 100%;
    padding: 26px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95), 0 0 35px rgba(239, 68, 68, 0.3);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.account-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-crimson);
    padding-bottom: 14px;
}

.wg-membership-box {
    background: rgba(10, 3, 5, 0.85);
    border: 1px solid var(--border-crimson);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #cbd5e1;
    border-bottom: 1px solid rgba(220, 38, 38, 0.1);
    padding-bottom: 6px;
}

.stat-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-item strong {
    color: #4ade80;
}

/* ================== أزرار المرفقات وصور الـ Vision ورسم الصور (WormGPT Art & Uploads) ================== */
.btn-input-action {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-sub);
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-input-action:hover {
    background: rgba(220, 38, 38, 0.16);
    color: #fff;
    border-color: var(--border-crimson);
}

.btn-input-action.active {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.25), rgba(185, 28, 28, 0.35));
    border: 1px solid #facc15;
    color: #facc15;
    box-shadow: 0 0 14px rgba(250, 204, 21, 0.35);
}

.attached-img-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #fca5a5;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.attached-img-preview button {
    background: transparent;
    border: none;
    color: #f87171;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
}

.msg-generated-img {
    max-width: 100%;
    max-height: 480px;
    border-radius: 14px;
    border: 1px solid var(--border-crimson);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85);
    margin-top: 10px;
    display: block;
}

.btn-download-img {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fff;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    margin-top: 8px;
    transition: all 0.2s;
}

.btn-download-img:hover {
    background: #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

/* ================== صناديق الأكواد البرمجية والأوامر (WormGPT Syntax Code Blocks) ================== */
.code-box-wrapper {
    background: #090305;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 12px;
    margin: 14px 0;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
    direction: ltr;
    text-align: left;
}

.code-box-header {
    background: rgba(220, 38, 38, 0.16);
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    font-weight: 800;
    color: #fecaca;
}

.code-lang-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4ade80;
    font-family: 'Consolas', 'Fira Code', monospace;
    font-weight: 700;
}

.btn-copy-code {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fca5a5;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Cairo', sans-serif;
}

.btn-copy-code:hover {
    background: rgba(239, 68, 68, 0.35);
    border-color: #ef4444;
    color: #fff;
}

.code-box-pre {
    padding: 14px 16px;
    margin: 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
    font-size: 0.88rem;
    line-height: 1.65;
    color: #f8fafc;
    background: transparent;
    text-align: left;
}

.code-box-pre::-webkit-scrollbar {
    height: 6px;
}
.code-box-pre::-webkit-scrollbar-thumb {
    background: rgba(239, 68, 68, 0.4);
    border-radius: 4px;
}

.inline-code {
    background: rgba(239, 68, 68, 0.22);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 2px 7px;
    border-radius: 5px;
    font-family: 'Consolas', monospace;
    font-size: 0.86em;
    direction: ltr;
    display: inline-block;
}

/* ================== نافذة مقارنة الباقات والترقية (PRO VIP Modal) ================== */
.pro-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 2, 3, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.pro-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.pro-modal-card {
    background: rgba(18, 6, 10, 0.94);
    border: 2px solid #ef4444;
    border-radius: 22px;
    max-width: 650px;
    width: 100%;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.95), 0 0 35px rgba(239, 68, 68, 0.3);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.pro-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-crimson);
    padding-bottom: 14px;
}

.pro-price-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.95rem;
    font-weight: 900;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.pro-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.pro-table th {
    text-align: right;
    padding: 12px 14px;
    background: rgba(220, 38, 38, 0.15);
    border-bottom: 2px solid var(--border-crimson);
    color: #fff;
    font-weight: 800;
}

.pro-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(220, 38, 38, 0.12);
    color: #cbd5e1;
}

.pro-table tr td:last-child {
    color: #4ade80;
    font-weight: 700;
}

/* ================== بوابة الدخول والتسجيل ================== */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, rgba(136, 19, 55, 0.45) 0%, rgba(5, 2, 3, 0.95) 75%);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    direction: rtl;
}

.auth-card {
    background: rgba(15, 4, 6, 0.5);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid var(--border-crimson);
    border-top: 1px solid var(--border-highlight);
    border-left: 1px solid var(--border-highlight);
    padding: 35px 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    position: relative;
    overflow: hidden;
}

.auth-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.auth-tabs {
    display: flex;
    background: rgba(10, 3, 5, 0.8);
    border: 1px solid var(--border-crimson);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-sub);
    padding: 10px;
    border-radius: 99px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab.active {
    background: linear-gradient(135deg, #ef4444, #991b1b);
    color: #fff;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.35);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form .form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-form label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #fecaca;
}

.captcha-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-question {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid var(--border-crimson);
    color: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 900;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.otp-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.otp-box input {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    padding: 12px;
}

/* ================== التصميم الذكي للهواتف ================== */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 860px) {
    html {
        font-size: 13.1px;
    }

    .btn-mobile-menu {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 9px;
        background: rgba(220, 38, 38, 0.15);
        border: 1px solid var(--border-crimson);
        color: #fff;
        cursor: pointer;
        transition: background 0.2s;
        flex-shrink: 0;
    }

    .btn-close-sidebar {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: rgba(239, 68, 68, 0.22);
        border: 1px solid rgba(239, 68, 68, 0.45);
        color: #fff;
        cursor: pointer;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 82%;
        max-width: 270px;
        height: 100vh;
        height: 100dvh;
        z-index: 999;
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        border-left: 1px solid var(--border-crimson);
        box-shadow: -15px 0 50px rgba(0, 0, 0, 0.9);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .hide-mobile {
        display: none !important;
    }

    .chat-navbar {
        padding: 0 8px;
        height: 44px;
        gap: 6px;
    }

    .nav-left {
        gap: 4px;
    }

    .brand-logo-img {
        width: 24px;
        height: 24px;
    }

    .nav-center-model {
        flex: 1;
        display: flex;
        justify-content: center;
        max-width: none;
        margin: 0 4px;
    }

    .wg-model-pill-btn {
        max-width: 175px;
        padding: 5px 10px;
        font-size: 0.74rem;
    }

    .btn-nav-action {
        padding: 5px 8px;
        font-size: 0.75rem;
    }

    .btn-upgrade-pro, .badge-pro-nav {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .status-pill {
        display: none;
    }

    .messages-container {
        padding: 12px 8px;
        gap: 10px;
    }

    .message-card {
        max-width: 98%;
        padding: 8px 11px;
        font-size: 0.8rem;
        border-radius: 12px;
    }

    .message-header {
        font-size: 0.72rem;
        margin-bottom: 6px;
    }

    .input-section {
        padding: 0 8px 8px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .chat-input-bar {
        padding: 6px 10px;
        border-radius: 16px;
    }

    .chat-input {
        font-size: 0.85rem;
        min-height: 20px;
    }

    .btn-send {
        width: 36px;
        height: 36px;
    }

    .account-modal-card {
        padding: 16px;
        border-radius: 16px;
        max-width: 95% !important;
    }
}

/* ====================================================================== */
/* شريط إشعار الخادم العام الفوري (WormGPT Live Server Broadcast Banner) */
/* ====================================================================== */
.wg-server-banner {
    width: 100%;
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.95), rgba(153, 27, 27, 0.95));
    border-bottom: 1px solid #facc15;
    color: #fff;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4);
    animation: slideDownBanner 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDownBanner {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.wg-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 700;
}

.wg-banner-close {
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: #fff;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.wg-banner-close:hover {
    background: rgba(0, 0, 0, 0.6);
}

/* ====================================================================== */
/* إشعار عائم للتحديث التلقائي الفوري عند أي إجراء من قبل الخادم */
/* ====================================================================== */
.wg-server-toast {
    position: fixed;
    top: 22px;
    left: 22px;
    max-width: 380px;
    width: calc(100% - 44px);
    background: rgba(18, 6, 10, 0.96);
    border: 1px solid #facc15;
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.85), 0 0 20px rgba(234, 179, 8, 0.3);
    z-index: 100000;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.wg-server-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.wg-toast-icon {
    font-size: 1.4rem;
    background: rgba(234, 179, 8, 0.2);
    border: 1px solid rgba(234, 179, 8, 0.5);
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wg-toast-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wg-toast-close {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px;
}
.wg-toast-close:hover {
    color: #fff;
}

/* ====================================================================== */
/* تصميم قائمة المحادثات وزر المحادثة الجديدة (Enterprise Multi-Chat UI) */
/* ====================================================================== */
.btn-new-chat {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(153, 27, 27, 0.22));
    border: 1px solid rgba(239, 68, 68, 0.55);
    color: #fff;
    font-size: 0.86rem;
    font-weight: 800;
    padding: 11px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    margin-bottom: 4px;
}

.btn-new-chat:hover {
    background: linear-gradient(135deg, #ef4444, #991b1b);
    border-color: #facc15;
    box-shadow: 0 6px 25px rgba(239, 68, 68, 0.5);
    transform: translateY(-1px);
}

.sidebar-sessions-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0 10px;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--text-sub);
    padding: 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-clear-sessions {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-clear-sessions:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.sidebar-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 210px;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding-right: 2px;
}

.sidebar-session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--text-main);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-session-item:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fff;
    transform: translateX(-2px);
}

.sidebar-session-item.active {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fff;
    font-weight: 700;
    border-right: 3px solid #ef4444;
}

.sess-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.btn-del-sess {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0.6;
    transition: all 0.2s;
}

.sidebar-session-item:hover .btn-del-sess {
    opacity: 1;
}

.btn-del-sess:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.5);
}

/* ====================================================================== */
/* أزرار الموجه ومسح الدردشة في الشريط العلوي (Main Chat Navbar Buttons) */
/* ====================================================================== */
.btn-nav-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    color: #fecaca;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-nav-action:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #fff;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.35);
}

.btn-nav-clear:hover {
    background: rgba(239, 68, 68, 0.35);
    border-color: #ef4444;
    color: #fff;
}

.prompt-active-dot {
    width: 6px;
    height: 6px;
    border-radius: 99px;
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}

.btn-prompt-preset {
    padding: 6px 11px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fecaca;
    font-size: 0.77rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-prompt-preset:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #fff;
}

/* ====================================================================== */
/* تمرير ناعم وأشرطة تمرير رفيعة فخمة (Ultra-Smooth Slim Scrollbars) */
/* ====================================================================== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: rgba(10, 3, 5, 0.3);
}
::-webkit-scrollbar-thumb {
    background: rgba(239, 68, 68, 0.35);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(239, 68, 68, 0.35) rgba(10, 3, 5, 0.3);
    scroll-behavior: smooth;
}

/* ====================================================================== */
/* قائمة اختيار النموذج المخصصة الفخمة (WormGPT Custom Glass Dropdown) */
/* ====================================================================== */
.wg-custom-select-wrap {
    position: relative;
    display: inline-block;
}

.wg-custom-select-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(18, 6, 10, 0.85);
    border: 1px solid rgba(239, 68, 68, 0.45);
    border-radius: 12px;
    padding: 8px 14px;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.wg-custom-select-btn:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35);
}

.wg-select-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.svg-chevron {
    color: var(--text-sub);
    transition: transform 0.25s;
    margin-right: auto;
}

.wg-custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-height: 360px;
    overflow-y: auto;
    background: rgba(14, 5, 8, 0.98);
    border: 1px solid #ef4444;
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.95), 0 0 25px rgba(239, 68, 68, 0.25);
    z-index: 100000;
    display: none;
    flex-direction: column;
    gap: 6px;
    animation: fadeInDropdown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.wg-custom-dropdown-menu.show {
    display: flex;
}

.sidebar-dropdown {
    width: 100%;
    left: 0;
    right: auto;
}

@keyframes fadeInDropdown {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.wg-dropdown-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
}

.wg-dropdown-item:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.45);
    transform: translateX(-3px);
}

.wg-dropdown-item.active {
    background: rgba(239, 68, 68, 0.22);
    border-color: #ef4444;
    border-right: 3px solid #facc15;
}

.wg-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.wg-item-name {
    font-size: 0.84rem;
    font-weight: 800;
    color: #fff;
}

.wg-power-tag {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(234, 179, 8, 0.18);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.45);
}

.wg-power-tag.badge-auto {
    background: rgba(74, 222, 128, 0.18);
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.45);
}

.wg-item-desc, .wg-item-meta {
    font-size: 0.75rem;
    color: var(--text-sub);
}

/* ====================================================================== */
/* زر اختيار النموذج في أعلى الشاشة والقائمة الجانبية (Sleek Model Pill Button) */
/* ====================================================================== */
.wg-model-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(18, 6, 10, 0.85);
    border: 1px solid rgba(239, 68, 68, 0.45);
    border-radius: 99px;
    padding: 7px 14px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    max-width: 260px;
}

.wg-model-pill-btn:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.35);
}

/* ====================================================================== */
/* تصميم بطاقات النماذج داخل نافذة الاختيار (Models Modal Card List) */
/* ====================================================================== */
.models-modal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-card-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: right;
}

.model-card-item:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.55);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

.model-card-item.active {
    background: rgba(239, 68, 68, 0.22);
    border-color: #ef4444;
    border-right: 4px solid #facc15;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.model-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.model-item-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
}

.model-item-desc {
    font-size: 0.8rem;
    color: var(--text-sub);
    margin: 0;
    line-height: 1.5;
}

.model-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--text-sub);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
}

.model-select-hint {
    color: #4ade80;
    font-weight: 700;
}

/* ====================================================================== */
/* بطاقات لوحة الإدارة المحمولة المتجاوبة (Mobile-First Admin User Cards) */
/* ====================================================================== */
.show-mobile {
    display: none;
}

.admin-user-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 16px;
    transition: all 0.2s;
    text-align: right;
}

.admin-user-card:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.user-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.user-card-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
}

.user-card-email {
    font-size: 0.82rem;
    color: #fecaca;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.user-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.76rem;
    color: var(--text-sub);
}

.user-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 10px;
}

@media (max-width: 768px) {
    .show-mobile {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }
    .hide-mobile {
        display: none !important;
    }
    .admin-container {
        width: 96%;
        margin: 12px auto;
        padding: 16px;
        gap: 16px;
    }
    .admin-settings-card {
        padding: 16px !important;
    }
    .admin-settings-card > div {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================================== */
/* أزرار الإدخال ورسم الصور السحابي (WormGPT Art & Input Actions) */
/* ====================================================================== */
.btn-input-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fecaca;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-input-action:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fff;
    transform: translateY(-1px);
}

.btn-input-action.active {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.35), rgba(234, 179, 8, 0.35));
    border-color: #facc15;
    color: #facc15;
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.45);
}

.msg-art-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 6px;
}

.art-prompt-label {
    font-size: 0.84rem;
    color: #fecaca;
    line-height: 1.5;
}

.art-img-wrap {
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid #ef4444;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.8), 0 0 20px rgba(239, 68, 68, 0.3);
    max-width: 100%;
}

.msg-generated-img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 520px;
    object-fit: cover;
}

.art-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-art-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #ef4444, #991b1b);
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
    transition: all 0.2s;
}

.btn-art-download:hover {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
    transform: translateY(-1px);
}

.auth-card::before {
    content: '';
    position: absolute;
    top: -50px;
    left: -50px;
    width: 150px;
    height: 150px;
    background: rgba(239, 68, 68, 0.3);
    border-radius: 50%;
    filter: blur(50px);
    z-index: -1;
    pointer-events: none;
}

.account-modal-content::after, .models-modal-content::after {
    content: '';
    position: absolute;
    bottom: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: rgba(220, 38, 38, 0.15);
    border-radius: 50%;
    filter: blur(50px);
    z-index: -1;
    pointer-events: none;
}

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


/* =========================================================
   ULTIMATE PREMIUM GLASSMORPHISM OVERRIDES (Site-Wide)
   ========================================================= */

/* 1. Modals & Overlays */
.auth-overlay, .account-modal-overlay, .sidebar-backdrop {
    background: rgba(2, 0, 1, 0.75) !important;
    backdrop-filter: blur(18px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(150%) !important;
}

/* 2. Scrollbars (Dark Glassy Crimson) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(220, 38, 38, 0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(239, 68, 68, 0.6); }

/* 3. Global Inputs (Auth, Modals, Admin) */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.6) !important;
    border-radius: 12px;
    transition: all 0.3s ease !important;
}
input:focus, select:focus, textarea:focus {
    border-color: rgba(239, 68, 68, 0.6) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2), inset 0 2px 6px rgba(0,0,0,0.6) !important;
    outline: none !important;
}

/* 4. Primary Buttons */
.btn-submit, .btn-primary, .auth-btn, .btn-upgrade-pro {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.8), rgba(153, 27, 27, 0.9)) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.25), inset 0 1px 0 rgba(255,255,255,0.2) !important;
    border-radius: 12px !important;
    color: #fff !important;
    font-weight: 700 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    overflow: hidden;
}
.btn-submit:hover, .btn-primary:hover, .auth-btn:hover, .btn-upgrade-pro:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4), inset 0 1px 0 rgba(255,255,255,0.3) !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(185, 28, 28, 1)) !important;
}

/* 5. Secondary / Sidebar Buttons */
.btn-sidebar, .btn-close-sidebar {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s ease;
}
.btn-sidebar:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

/* 6. Model Cards */
.model-card-item {
    background: rgba(15, 4, 6, 0.5) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 16px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.model-card-item:hover {
    background: rgba(239, 68, 68, 0.05) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.15) !important;
}
.model-card-item.active {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: #ef4444 !important;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.2), inset 0 0 15px rgba(239, 68, 68, 0.1) !important;
}

/* 7. Sidebar Sessions */
.sidebar-session-item {
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.02) !important;
    border-radius: 12px !important;
    margin-bottom: 8px !important;
    transition: all 0.2s ease !important;
}
.sidebar-session-item:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
}
.sidebar-session-item.active {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.15), transparent) !important;
    border-right: 3px solid #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

/* 8. Admin & Dev Cards Overrides */
.admin-settings-card, .admin-user-card, .dev-card, .stats-card {
    background: rgba(15, 4, 6, 0.5) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    border: 1px solid var(--border-crimson) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05) !important;
    border-radius: 20px !important;
    position: relative;
    overflow: hidden;
}

/* Subtle glow for admin cards */
.admin-settings-card::before, .dev-card::before, .stats-card::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 120px;
    height: 120px;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 50%;
    filter: blur(40px);
    pointer-events: none;
    z-index: 0;
}
.admin-settings-card > *, .dev-card > *, .stats-card > * {
    position: relative;
    z-index: 1;
}

/* 9. Image Generation Art Card */
.msg-art-card {
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    padding: 12px !important;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5) !important;
}
.msg-generated-img {
    border-radius: 12px !important;
    box-shadow: 0 8px 25px rgba(0,0,0,0.8) !important;
}

/* 10. Toasts / Alerts */
.wg-server-toast {
    background: rgba(15, 4, 6, 0.75) !important;
    backdrop-filter: blur(24px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(200%) !important;
    border: 1px solid var(--border-crimson) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.8) !important;
    border-radius: 16px !important;
}


/* =========================================================
   COMPACT MODEL CARDS
   ========================================================= */
.model-card-compact {
    background: rgba(15, 4, 6, 0.4);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.model-card-compact:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.15);
}
.model-card-compact.active {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.15), rgba(153, 27, 27, 0.05));
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2), inset 0 1px 0 rgba(255,255,255,0.05);
}
.model-compact-main {
    display: flex;
    align-items: center;
    gap: 12px;
}
.model-compact-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.model-card-compact.active .model-compact-radio {
    border-color: #ef4444;
}
.model-card-compact.active .model-compact-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 8px #ef4444;
}
.model-compact-name {
    font-size: 1rem;
    color: #f8fafc;
    font-weight: 600;
}
/* Reduce modal size since items are smaller */
.models-modal-content {
    max-width: 480px !important;
}
.models-modal-list {
    max-height: 50vh !important;
    padding: 10px 0 !important;
}


/* Revert chat input textarea to its original transparent state */
.input-box textarea {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 6px 4px !important;
}
.input-box textarea:focus {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}


.auth-switch-text {
    text-align: center;
    margin-top: 20px;
    font-size: 0.95rem;
    color: var(--text-sub);
}
.auth-switch-text a {
    color: #ef4444;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
}
.auth-switch-text a:hover {
    color: #fca5a5;
    text-decoration: underline;
}
.auth-card {
    width: 95% !important;
    max-width: 520px !important;
    padding: 45px 35px !important;
}
@media (max-width: 768px) {
    .auth-overlay {
        padding: 8px !important;
    }
    .auth-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 35px 20px !important;
        border-radius: 24px !important;
    }
    
    /* Make the logo and title a bit larger on mobile to match the bigger box */
    .auth-header .brand-logo {
        font-size: 1.6rem !important;
    }
    .auth-header p {
        font-size: 1rem !important;
    }
    .form-field label {
        font-size: 0.95rem !important;
    }
    .input-glass {
        height: 48px !important;
        font-size: 1.05rem !important;
    }
    .btn-submit.auth-btn {
        height: 52px !important;
        font-size: 1.1rem !important;
    }
}

/* ===== UI Fix 2026-07-30: top bar alignment + reliable clickable controls ===== */
.chat-header.app-topbar {
    height: 54px;
    min-height: 54px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(14, 6, 9, 0.88);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-crimson);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 30;
    flex-shrink: 0;
}

.topbar-model-side,
.topbar-clear-side,
.topbar-model-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-clear-side {
    margin-inline-start: auto;
}

.btn-clear-current-chat {
    border-color: rgba(239, 68, 68, 0.42);
    color: #ef4444;
    background: rgba(239, 68, 68, 0.10);
    font-weight: 800;
    white-space: nowrap;
    position: relative;
    z-index: 2;
}

.btn-clear-current-chat:hover {
    background: rgba(239, 68, 68, 0.26);
    color: #fff;
}

@media (max-width: 860px) {
    .chat-header.app-topbar {
        height: 48px;
        min-height: 48px;
        padding: 6px 8px;
        gap: 6px;
    }

    .topbar-model-side,
    .topbar-model-wrap {
        gap: 6px;
    }

    .topbar-clear-side {
        flex-shrink: 0;
    }

    .btn-clear-current-chat {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        border-radius: 10px;
    }
}

/* ===== UI Fix 2026-07-30 #2: scrollable models modal + opposite top delete button ===== */
.account-modal-overlay.open {
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
}

.account-modal-content.models-modal-content {
    width: min(92vw, 520px) !important;
    max-width: 520px !important;
    max-height: min(86vh, 720px) !important;
    max-height: min(86dvh, 720px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
}

.models-modal-content > div:first-child,
.models-modal-content > div:last-child {
    flex: 0 0 auto !important;
}

.models-modal-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: calc(86vh - 145px) !important;
    max-height: calc(86dvh - 145px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 10px 12px !important;
    scrollbar-gutter: stable both-edges;
}

/* Force the top-bar controls to stay on opposite sides, never stacked under each other */
.chat-header.app-topbar {
    position: relative !important;
    justify-content: center !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
}

.chat-header.app-topbar .topbar-model-side {
    position: absolute !important;
    inset-inline-start: 14px !important; /* right side in RTL */
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 3 !important;
    max-width: calc(100% - 86px) !important;
}

.chat-header.app-topbar .topbar-clear-side {
    position: absolute !important;
    inset-inline-end: 14px !important; /* left side in RTL */
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    z-index: 4 !important;
    flex-shrink: 0 !important;
}

.chat-header.app-topbar .wg-model-pill-btn {
    max-width: min(235px, calc(100vw - 110px)) !important;
}

.chat-header.app-topbar .wg-select-label {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

@media (max-width: 860px) {
    .account-modal-content.models-modal-content {
        width: 94vw !important;
        max-height: 84dvh !important;
    }

    .models-modal-list {
        max-height: calc(84dvh - 138px) !important;
        padding: 8px 10px !important;
    }

    .chat-header.app-topbar .topbar-model-side {
        inset-inline-start: 8px !important;
        max-width: calc(100% - 58px) !important;
        gap: 6px !important;
    }

    .chat-header.app-topbar .topbar-clear-side {
        inset-inline-end: 8px !important;
    }

    .chat-header.app-topbar .wg-model-pill-btn {
        max-width: min(168px, calc(100vw - 104px)) !important;
        min-width: 0 !important;
    }
}

@media (max-width: 380px) {
    .chat-header.app-topbar .wg-model-pill-btn {
        max-width: min(145px, calc(100vw - 104px)) !important;
        padding-inline: 8px !important;
    }
}

/* ===== Mobile-only hard fix 2026-07-30: model list touch scroll + fixed opposite delete icon ===== */
@media (max-width: 860px) {
    .account-modal-overlay#wormgptModelSelectModal.open {
        align-items: center !important;
        justify-content: center !important;
        touch-action: none !important;
    }

    #wormgptModelSelectModal .account-modal-content.models-modal-content {
        width: 94vw !important;
        height: 82vh !important;
        height: 82dvh !important;
        max-height: 82vh !important;
        max-height: 82dvh !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        margin: 0 auto !important;
    }

    #wormgptModelSelectModal .models-modal-list {
        height: auto !important;
        flex: 1 1 0 !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: scroll !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        overscroll-behavior-y: contain !important;
        padding: 10px 10px 16px !important;
    }

    #wormgptModelSelectModal .model-card-compact {
        flex: 0 0 auto !important;
    }

    /* Explicit right/left for older mobile browsers that may ignore logical inset properties */
    .chat-header.app-topbar {
        height: 50px !important;
        min-height: 50px !important;
        padding: 0 !important;
        position: relative !important;
        display: block !important;
        overflow: visible !important;
    }

    .chat-header.app-topbar .topbar-model-side {
        position: absolute !important;
        right: 8px !important;
        left: auto !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: auto !important;
        max-width: calc(100vw - 58px) !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        z-index: 3 !important;
    }

    .chat-header.app-topbar .topbar-clear-side {
        position: absolute !important;
        left: 8px !important;
        right: auto !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 36px !important;
        height: 36px !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 5 !important;
    }

    .chat-header.app-topbar .btn-clear-current-chat {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 10px !important;
    }

    .chat-header.app-topbar .wg-model-pill-btn {
        width: auto !important;
        max-width: 150px !important;
        min-width: 0 !important;
        padding: 6px 9px !important;
    }
}

@media (min-width: 390px) and (max-width: 860px) {
    .chat-header.app-topbar .wg-model-pill-btn {
        max-width: 178px !important;
    }
}
