/* Fonts: Cairo/Tajawal. Base RTL Arabic UI */
:root {
	--bg: #000000;
	--bg-elev: #0d0d0d;
	--text: #ffffff;
	--muted: #b5b5b5;
	--brand: #ffffff;
	--brand-2: #dcdcdc;
	--danger: #ff4d4d;
	--bubble-user: #111111;
	--bubble-bot: #0a0a0a;
	--ring: rgba(255, 255, 255, 0.35);
	--shadow: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	font-family: "Cairo", "Tajawal", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	line-height: 1.6;
	overscroll-behavior: none;
}

/* Buttons */
.btn {
	appearance: none;
	border: 0;
	border-radius: 14px;
	padding: 14px 18px;
	font-weight: 700;
	font-size: 15px;
	cursor: pointer;
	transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
	box-shadow: 0 8px 22px -8px var(--shadow);
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn.primary, .btn.btn-primary { background: linear-gradient(135deg, #ffffff, #dcdcdc); color: #000; }
.btn.btn-ghost { background: transparent; color: var(--muted); border: 1px solid #2a2a2a; }
.app-actions .btn#callBtn .icon { color: #ffffff; filter: none; font-size: 18px; }
.app-actions #callBtn { position: fixed; top: 10px; right: 65%; transform: translateX(50%); z-index: 12; }
.app-actions #callBtn.small { padding: 12px 14px; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.btn-full { width: 100%; }
.btn.send { min-width: 92px; }
.btn:hover { filter: brightness(1.05); }

/* Splash */
.splash {
	position: relative;
	min-height: 100dvh;
	display: grid;
	place-items: center;
	padding: 32px;
	background: radial-gradient(1200px 800px at 70% 10%, rgba(255,255,255,0.08), transparent 60%),
		linear-gradient(180deg, #000, #000 60%, #0a0a0a);
}
.splash .splash-inner { text-align: center; z-index: 2; }
.splash .brand { display: grid; gap: 10px; place-items: center; margin-bottom: 22px; }
.brand-mark { filter: drop-shadow(0 10px 24px rgba(255,255,255,0.2)); animation: float 4s ease-in-out infinite; }
.brand-title { font-size: 56px; letter-spacing: 1px; margin: 0; font-weight: 900; color: #ffffff; }
.brand-tag { margin: 0; color: var(--muted); font-weight: 500; }
.splash-gradient { position: absolute; inset: 0; background:
	radial-gradient(600px 300px at 30% 20%, rgba(255,255,255,0.06), transparent 50%),
	radial-gradient(800px 400px at 70% 80%, rgba(255,255,255,0.04), transparent 60%);
	filter: blur(30px) saturate(1.1);
	pointer-events: none;
}

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Modal */
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); animation: fadeIn .25s ease both; }
.modal-card { position: relative; width: min(520px, 92vw); background: var(--bg-elev); border: 1px solid #202a33; padding: 22px; border-radius: 18px; box-shadow: 0 24px 64px -24px var(--shadow); animation: scaleIn .25s ease both; }
.modal-card.call-card { width: min(820px, 96vw); }
.modal-title { margin: 6px 0 6px; font-weight: 800; }
.modal-sub { margin: 0 0 14px; color: var(--muted); font-weight: 500; }
.modal-form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field span { color: var(--muted); font-size: 14px; }
.field input { background: #0d1419; color: var(--text); border: 1px solid #22303a; border-radius: 12px; padding: 14px 12px; font-size: 16px; transition: border-color .2s ease, box-shadow .2s ease; }
.field input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 4px var(--ring); }
.shake { animation: shake .35s ease; }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes scaleIn { from { transform: translateY(8px) scale(.98); opacity: 0 } to { transform: translateY(0) scale(1); opacity: 1 } }

/* App */
.hidden { display: none !important; }
.app { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: rgba(17,23,29,0.85); backdrop-filter: blur(8px); border-bottom: 1px solid #1f2a33; position: sticky; top: 0; z-index: 10; }
.app-brand { display: flex; gap: 12px; align-items: center; }
.app-brand .dot { width: 10px; height: 10px; border-radius: 20px; background: linear-gradient(135deg, #ffffff, #cfcfcf); box-shadow: 0 0 0 6px rgba(255,255,255,0.12); animation: ping 1.6s cubic-bezier(.2,0,.2,1) infinite; }
.app-title { font-weight: 800; letter-spacing: .4px; }
.app-subtitle { font-size: 12px; color: var(--muted); margin-top: -2px; }

@keyframes ping { 0% { transform: scale(1); opacity: 1 } 80% { transform: scale(1.6); opacity: 0 } 100% { transform: scale(1.6); opacity: 0 } }

/* Chat */
.chat { position: relative; padding: 16px; display: grid; grid-template-rows: 1fr auto; overflow-y: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
.chat-watermark { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; font-weight: 900; letter-spacing: 6px; font-size: clamp(40px, 14vw, 140px); color: rgba(255,255,255,0.06); filter: blur(2px); text-transform: uppercase; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-width: 920px; width: 100%; margin-inline: auto; }
.chat-output { max-width: 920px; width: 100%; margin: 6px auto 0; color: var(--muted); font-size: 14px; }
.msg { display: grid; gap: 6px; max-width: 80%; }
.msg .meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.msg .bubble { padding: 12px 14px; border-radius: 16px; border: 1px solid #1f1f1f; box-shadow: 0 10px 24px -16px var(--shadow); animation: pop .18s ease both; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; hyphens: auto; }
.msg.user { justify-self: start; text-align: right; margin-right: 0; }
.msg.user .bubble { background: var(--bubble-user); border-color: #1f1f1f; }
.msg.bot { justify-self: end; text-align: right; margin-right: 36px; }
.msg.bot .bubble { background: var(--bubble-bot); border-color: #1a1a1a; }
.msg .ticks { color: var(--muted); font-size: 12px; }

@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0 } to { transform: translateY(0) scale(1); opacity: 1 } }

.typing { position: sticky; bottom: 92px; display: flex; align-items: center; gap: 8px; color: var(--muted); max-width: 920px; width: 100%; margin: 0 auto; padding: 0 6px; z-index: 2; }
.typing .bubble { width: 8px; height: 8px; border-radius: 20px; background: var(--muted); opacity: .7; animation: typing 1.2s infinite ease-in-out; }
.typing .bubble:nth-child(1) { animation-delay: 0s; }
.typing .bubble:nth-child(2) { animation-delay: .15s; }
.typing .bubble:nth-child(3) { animation-delay: .3s; }
.typing .typing-text { display: none; }

@keyframes typing { 0%, 80%, 100% { transform: translateY(0); opacity: .5 } 40% { transform: translateY(-4px); opacity: 1 } }

/* Composer */
.composer { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(0,0,0,0), #000 30%); padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.composer-inner { max-width: 920px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto; gap: 10px; background: var(--bg-elev); border: 1px solid #1a1a1a; border-radius: 16px; padding: 10px; box-shadow: 0 10px 30px -20px var(--shadow); }
.input { resize: none; border: 0; background: transparent; color: var(--text); padding: 8px 10px; font-size: 15px; line-height: 1.6; max-height: 180px; }
.input:focus { outline: none; }
.btn[disabled] { opacity: .6; cursor: not-allowed; filter: grayscale(.2); }
.btn.send.loading { position: relative; color: transparent; }
.btn.send.loading::after { content: "يتم الإرسال..."; color: white; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 14px; }

/* Utilities */
.active { opacity: 1; }
.fade-out { animation: fadeOut .35s ease both; }

@keyframes fadeOut { from { opacity: 1 } to { opacity: 0 } }

/* Toasts */
.toast-stack { position: fixed; left: 14px; bottom: 14px; display: grid; gap: 10px; z-index: 50; }
.toast { background: #0f0f0f; color: var(--text); border: 1px solid #1f1f1f; padding: 12px 14px; border-radius: 12px; box-shadow: 0 10px 30px -20px var(--shadow); animation: pop .18s ease both; }
.toast.error { border-color: #3a1f1f; background: #140b0b; color: #ffcccc; }

/* Password wrap */
.password-wrap { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.btn.eye { border: 1px solid #2a2a2a; background: #111; color: #fff; }

/* Call modal content */
.call-body { display: grid; gap: 12px; }
.call-body elevenlabs-convai { display: block; width: 100%; height: 60vh; border: 1px solid #1f1f1f; border-radius: 12px; background: #0a0a0a; }

/* Inline call widget */
.call-inline { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); width: min(820px, 96vw); max-width: 920px; z-index: 11; }
.call-inline elevenlabs-convai { display: block; width: 100%; height: 64vh; }
#callFrame { width: 100%; height: 60vh; background: #000; border: 1px solid #1f1f1f; border-radius: 12px; }
.call-controls { display: flex; gap: 10px; justify-content: center; }

/* Bottom glow */
.bottom-glow { position: fixed; left: 0; right: 0; bottom: 0; height: 220px; background: radial-gradient(60% 80% at 50% 100%, rgba(255,255,255,0.10), rgba(255,255,255,0.02) 40%, transparent 70%); filter: blur(28px); pointer-events: none; z-index: 0; }

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
	* { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
	.brand-mark { animation: none; }
	.app-brand .dot { animation: none; }
	.typing .bubble { animation: none; }
}

/* Fine-tuning for small screens */
@media (max-width: 420px) {
	.splash { padding: 24px; }
	.brand-title { font-size: 36px; }
	.composer-inner { grid-template-columns: 1fr auto; }
	.btn.send { min-width: 84px; }
}

/* Responsive */
@media (max-width: 640px) {
	.brand-title { font-size: 42px; }
	.msg { max-width: 88%; }
}


