/* AI Smart Login V2 — Frontend */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

#aislv2-wrapper * { box-sizing: border-box; }
#aislv2-wrapper {
  --bg:#fff; --fg:#0f172a; --muted:#64748b; --border:#e2e8f0; --soft:#f8fafc;
  font-family: 'Tajawal', system-ui, sans-serif;
  direction: rtl; max-width: 1100px; margin: 30px auto; background: var(--bg);
  border-radius: 24px; box-shadow: 0 25px 80px -20px rgba(0,0,0,.15), 0 0 0 1px rgba(0,0,0,.03);
  display: grid; grid-template-columns: 1.1fr 1.4fr; overflow: hidden; min-height: 640px;
}
@media (prefers-color-scheme: dark) {
  #aislv2-wrapper { --bg:#0f172a; --fg:#f1f5f9; --muted:#94a3b8; --border:#1e293b; --soft:#1e293b; }
}
@media (max-width: 860px) {
  #aislv2-wrapper { grid-template-columns: 1fr; margin: 12px; border-radius: 20px; min-height: auto; }
  #aislv2-left { padding: 28px 24px !important; min-height: auto; }
  #aislv2-left h1 { font-size: 26px !important; }
  .aislv2-feats { display: none !important; }
  #aislv2-right { padding: 24px 20px !important; }
}
@media (max-width: 480px) {
  #aislv2-wrapper { margin: 8px; border-radius: 16px; }
  #aislv2-left { padding: 22px 18px !important; }
  #aislv2-left h1 { font-size: 20px !important; line-height: 1.3; }
  #aislv2-right { padding: 18px 14px !important; }
  .aislv2-tabs .tab { font-size: 12px !important; padding: 10px 6px !important; }
  #aislv2-chat { height: 300px !important; }
  .msg { max-width: 92% !important; font-size: 13px !important; }
}

#aislv2-left {
  background: linear-gradient(135deg, var(--p) 0%, var(--s) 100%);
  padding: 48px 40px; color: #fff; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
}
#aislv2-left::before, #aislv2-left::after {
  content:''; position:absolute; border-radius:50%;
  background: radial-gradient(circle, rgba(255,255,255,.15), transparent 70%); pointer-events:none;
}
#aislv2-left::before { width:400px; height:400px; top:-100px; left:-100px; animation: aislv2float 8s ease-in-out infinite; }
#aislv2-left::after  { width:300px; height:300px; bottom:-80px; right:-80px; animation: aislv2float 10s ease-in-out infinite reverse; }
@keyframes aislv2float { 0%,100%{transform:translate(0,0);} 50%{transform:translate(20px,-20px);} }
#aislv2-left > * { position: relative; z-index: 1; }
.aislv2-logo { max-height: 54px; margin-bottom: 18px; }
#aislv2-left h1 { font-size: 34px; font-weight: 800; line-height: 1.2; margin: 0 0 14px; }
#aislv2-left .lead { opacity: .92; font-size: 15px; line-height: 1.7; margin: 0 0 26px; }
.aislv2-feats { display: flex; flex-direction: column; gap: 10px; }
.aislv2-feats .feat { display: flex; align-items: center; gap: 10px; font-size: 14px; opacity: .95; }
.aislv2-feats .feat span { width: 24px; height: 24px; background: rgba(255,255,255,.2); border-radius: 8px; display: grid; place-items: center; font-size: 11px; }
.aislv2-brand-foot { margin-top: 24px; font-size: 12px; opacity: .7; }

#aislv2-right { padding: 40px 36px; background: var(--bg); color: var(--fg); display: flex; flex-direction: column; }
.aislv2-tabs { display: flex; background: var(--soft); border-radius: 14px; padding: 5px; margin-bottom: 24px; gap: 4px; }
.aislv2-tabs .tab { flex: 1; padding: 12px 8px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); transition: all .25s; font-family: inherit; }
.aislv2-tabs .tab.active { background: var(--bg); box-shadow: 0 2px 8px rgba(0,0,0,.08); color: var(--p); }
.pane { display: none; animation: aislv2fade .3s ease; }
.pane.active { display: flex; flex-direction: column; flex: 1; }
@keyframes aislv2fade { from{opacity:0;transform:translateY(8px);} to{opacity:1;transform:translateY(0);} }

#aislv2-chat { flex:1; min-height:360px; max-height:420px; overflow-y:auto; padding:8px; display:flex; flex-direction:column; gap:10px; scroll-behavior:smooth; }
#aislv2-chat::-webkit-scrollbar { width: 6px; }
#aislv2-chat::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.msg { max-width:80%; padding:12px 16px; border-radius:18px; font-size:14px; line-height:1.6; word-wrap:break-word; animation: aislv2pop .25s ease; }
@keyframes aislv2pop { from{opacity:0;transform:scale(.95);} to{opacity:1;transform:scale(1);} }
.msg.bot { background: var(--soft); color: var(--fg); align-self: flex-start; border-bottom-right-radius: 4px; }
.msg.user { background: linear-gradient(135deg, var(--p), var(--s)); color: #fff; align-self: flex-end; border-bottom-left-radius: 4px; }
.msg.typing { display: flex; gap: 4px; align-items: center; }
.msg.typing span { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; animation: aislv2dot 1.2s infinite; }
.msg.typing span:nth-child(2){ animation-delay:.2s; } .msg.typing span:nth-child(3){ animation-delay:.4s; }
@keyframes aislv2dot { 0%,60%,100%{transform:translateY(0);opacity:.4;} 30%{transform:translateY(-6px);opacity:1;} }

.input-area { display: flex; gap: 8px; margin-top: 16px; background: var(--soft); padding: 6px; border-radius: 14px; border: 1px solid var(--border); transition: .2s; }
.input-area:focus-within { border-color: var(--p); box-shadow: 0 0 0 4px rgba(109,40,217,.1); }
.input-area input { flex:1; border:0; background: transparent; padding: 12px 14px; outline: none; font-family: inherit; font-size: 14px; color: var(--fg); }

.btn { background: linear-gradient(135deg, var(--p), var(--s)); color: #fff; border: 0; padding: 12px 22px; border-radius: 10px; cursor: pointer; font-weight: 700; font-family: inherit; font-size: 14px; transition: transform .15s, box-shadow .2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -6px rgba(109,40,217,.4); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; padding: 14px; }
.btn.ghost { background: var(--bg); color: var(--fg); border: 1px solid var(--border); }

.field { width: 100%; padding: 13px 15px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; outline: none; transition: .2s; font-family: inherit; font-size: 14px; background: var(--bg); color: var(--fg); }
.field:focus { border-color: var(--p); box-shadow: 0 0 0 4px rgba(109,40,217,.1); }
.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content:''; flex:1; height:1px; background: var(--border); }

/* ------- Toast ------- */
.aislv2-toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 14px 24px; border-radius: 12px; color: #fff; font-weight: 600; z-index: 999999; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-family: 'Tajawal', sans-serif; }
.aislv2-toast.ok { background: #10b981; } .aislv2-toast.err { background: #ef4444; }

/* ------- OTP Modal ------- */
.aislv2-modal { position: fixed; inset: 0; z-index: 999998; display: none; align-items: center; justify-content: center; padding: 16px; font-family: 'Tajawal', sans-serif; direction: rtl; }
.aislv2-modal.open { display: flex; animation: aislv2modalIn .25s ease; }
@keyframes aislv2modalIn { from { opacity: 0; } to { opacity: 1; } }
.aislv2-modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.6); backdrop-filter: blur(6px); }
.aislv2-modal-box { position: relative; width: 100%; max-width: 440px; background: #fff; border-radius: 24px; padding: 36px 28px 28px; box-shadow: 0 30px 90px -20px rgba(0,0,0,.4); text-align: center; animation: aislv2boxIn .3s cubic-bezier(.34,1.56,.64,1); }
@keyframes aislv2boxIn { from { opacity:0; transform: translateY(30px) scale(.92); } to { opacity:1; transform: translateY(0) scale(1); } }
.aislv2-modal-box .close { position: absolute; top: 14px; left: 14px; background: #f1f5f9; border: 0; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; color: #64748b; transition: .2s; }
.aislv2-modal-box .close:hover { background: #e2e8f0; color: #0f172a; }
.aislv2-modal-box .icon { font-size: 44px; margin-bottom: 8px; }
.aislv2-modal-box h2 { margin: 4px 0 8px; font-size: 22px; font-weight: 800; color: #0f172a; }
.aislv2-modal-box .sub { margin: 0 0 22px; font-size: 14px; color: #64748b; line-height: 1.7; }
.aislv2-modal-box .sub strong { color: var(--p); }

.otp-inputs { display: flex; gap: 8px; justify-content: center; margin-bottom: 22px; direction: ltr; }
.otp-cell { width: 48px; height: 56px; border: 2px solid #e2e8f0; border-radius: 12px; text-align: center; font-size: 22px; font-weight: 800; color: #0f172a; background: #f8fafc; outline: none; transition: .2s; font-family: 'Courier New', monospace; }
.otp-cell:focus { border-color: var(--p); background: #fff; box-shadow: 0 0 0 4px rgba(109,40,217,.12); transform: translateY(-2px); }
.otp-cell.filled { border-color: var(--p); background: #fff; color: var(--p); }

.aislv2-modal-box .btn.block { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--p), var(--s)); color: #fff; border: 0; border-radius: 12px; font-weight: 700; font-size: 15px; cursor: pointer; font-family: inherit; }
.otp-foot { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #64748b; }
.otp-foot .link { background: none; border: 0; color: var(--p); cursor: pointer; font-weight: 700; font-family: inherit; font-size: 13px; }
.otp-foot .link:disabled { color: #cbd5e1; cursor: not-allowed; }
.otp-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.otp-msg.ok { color: #10b981; } .otp-msg.err { color: #ef4444; }

@media (max-width: 480px) {
  .aislv2-modal-box { padding: 28px 20px 22px; border-radius: 20px; }
  .aislv2-modal-box h2 { font-size: 19px; }
  .otp-cell { width: 40px; height: 50px; font-size: 19px; }
  .otp-inputs { gap: 6px; }
}
@media (prefers-color-scheme: dark) {
  .aislv2-modal-box { background: #0f172a; }
  .aislv2-modal-box h2 { color: #f1f5f9; }
  .otp-cell { background: #1e293b; border-color: #334155; color: #f1f5f9; }
  .aislv2-modal-box .close { background: #1e293b; color: #94a3b8; }
}
