/* ─────────────────────────────────────────────────────────
   Tayareh Assistant Widget  |  Phase 2B  |  v1.0
   Brand: Navy #0D0777 · Orange #FF834F · Font: Comfortaa
───────────────────────────────────────────────────────── */
:root {
  --tya-navy:   #0D0777;
  --tya-orange: #FF834F;
  --tya-white:  #ffffff;
  --tya-light:  #f4f6fb;
  --tya-border: #e5e8f0;
  --tya-shadow: 0 8px 40px rgba(13,7,119,0.16);
  --tya-font:   'Comfortaa', 'Segoe UI', system-ui, sans-serif;
  --tya-radius: 18px;
}

/* ── Floating button ─────────────────────────────────── */
#tya-btn {
  position: fixed;
  bottom: 88px; /* above WhatsApp button */
  right: 24px;
  width: 56px;
  height: 56px;
  background: var(--tya-navy);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--tya-shadow);
  transition: transform .2s ease, background .2s ease;
  outline: none;
}
#tya-btn:hover { transform: scale(1.08); background: #1814a8; }
#tya-btn.tya-active { background: var(--tya-orange); }
#tya-btn svg { display: block; }

/* Pulse ring on first load */
#tya-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--tya-navy);
  animation: tya-pulse 2.5s ease-out 1s 3;
  opacity: 0;
}
@keyframes tya-pulse {
  0%   { transform: scale(1);   opacity: .6; }
  100% { transform: scale(1.5); opacity: 0;  }
}

/* ── Panel ───────────────────────────────────────────── */
#tya-panel {
  position: fixed;
  bottom: 156px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  background: #fff;
  border-radius: var(--tya-radius);
  box-shadow: var(--tya-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9997;
  overflow: hidden;
  transform: translateY(16px) scale(.97);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
}
#tya-panel.tya-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ─────────────────────────────────────────── */
#tya-header {
  background: var(--tya-navy);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 10px;
}
#tya-header-info { display: flex; align-items: center; gap: 12px; }
#tya-avatar {
  width: 38px; height: 38px;
  background: var(--tya-orange);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
#tya-name   { font-family: var(--tya-font); font-weight: 700; font-size: 14px; line-height: 1.2; }
#tya-status { font-size: 11px; opacity: .75; font-family: var(--tya-font); margin-top: 2px; }
#tya-close  {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; padding: 2px 4px; opacity: .7;
  transition: opacity .15s; line-height: 1; flex-shrink: 0;
}
#tya-close:hover { opacity: 1; }

/* ── Privacy notice ─────────────────────────────────── */
#tya-privacy {
  padding: 18px 20px;
  background: #edf0fb;
  border-bottom: 1px solid var(--tya-border);
  flex-shrink: 0;
  display: none;
}
#tya-privacy p {
  margin: 0 0 14px;
  font-size: 13px; line-height: 1.55;
  color: #3a3a5c; font-family: var(--tya-font);
}
#tya-privacy-ok {
  width: 100%;
  background: var(--tya-navy); color: #fff; border: none;
  padding: 10px 16px; border-radius: 10px;
  font-family: var(--tya-font); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .2s;
}
#tya-privacy-ok:hover { background: #1814a8; }

/* ── Messages ───────────────────────────────────────── */
#tya-messages {
  flex: 1; overflow-y: auto;
  padding: 16px; display: flex;
  flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
#tya-messages::-webkit-scrollbar { width: 4px; }
#tya-messages::-webkit-scrollbar-track { background: transparent; }
#tya-messages::-webkit-scrollbar-thumb { background: var(--tya-border); border-radius: 4px; }

.tya-msg {
  max-width: 83%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px; line-height: 1.55;
  font-family: var(--tya-font);
  word-wrap: break-word; word-break: break-word;
  animation: tya-fadein .2s ease;
}
@keyframes tya-fadein { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.tya-msg-user {
  background: var(--tya-navy); color: #fff;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.tya-msg-assistant {
  background: var(--tya-light); color: #1a1a3e;
  align-self: flex-start; border-bottom-left-radius: 4px;
}

/* ── WhatsApp handoff card ──────────────────────────── */
.tya-handoff {
  background: #f0faf4;
  border: 1px solid #b7e4c7;
  border-radius: 14px;
  padding: 14px 16px;
  align-self: stretch;
  max-width: 100% !important;
  animation: tya-fadein .2s ease;
}
.tya-handoff p {
  margin: 0 0 12px;
  font-size: 13px; line-height: 1.5;
  color: #2d4a35; font-family: var(--tya-font);
}
.tya-wa-btn {
  display: flex; align-items: center; gap: 8px;
  background: #25D366; color: #fff;
  text-decoration: none;
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  font-family: var(--tya-font);
  transition: background .2s;
}
.tya-wa-btn:hover { background: #1aad52; color: #fff; }

/* ── Typing indicator ───────────────────────────────── */
#tya-typing {
  padding: 6px 20px 4px;
  display: none; align-items: center; gap: 5px;
  flex-shrink: 0;
}
#tya-typing span {
  width: 7px; height: 7px;
  background: var(--tya-navy); border-radius: 50%;
  opacity: .35;
  animation: tya-bounce 1.1s ease-in-out infinite;
}
#tya-typing span:nth-child(2) { animation-delay: .18s; }
#tya-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes tya-bounce {
  0%,80%,100% { transform: translateY(0); opacity:.35; }
  40%          { transform: translateY(-7px); opacity:1; }
}

/* ── Input area ─────────────────────────────────────── */
#tya-input-area {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--tya-border);
  display: none; align-items: flex-end; gap: 10px;
  background: #fff; flex-shrink: 0;
}
#tya-input {
  flex: 1;
  border: 1.5px solid var(--tya-border);
  border-radius: 12px;
  padding: 9px 13px;
  font-family: var(--tya-font); font-size: 13.5px;
  resize: none; outline: none;
  color: #1a1a3e; line-height: 1.45;
  max-height: 96px; overflow-y: auto;
  transition: border-color .2s;
}
#tya-input:focus { border-color: var(--tya-navy); }
#tya-input::placeholder { color: #aab; }
#tya-send {
  width: 40px; height: 40px; flex-shrink: 0;
  background: var(--tya-navy); color: #fff;
  border: none; border-radius: 10px;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .2s;
}
#tya-send:hover { background: #1814a8; }
#tya-send:disabled { opacity: .4; cursor: default; }

/* ── Mobile ─────────────────────────────────────────── */
@media (max-width: 480px) {
  #tya-panel {
    position: fixed;
    inset: 0;
    width: 100%; max-height: 100%;
    border-radius: 0;
    bottom: 0; right: 0;
  }
  #tya-btn { bottom: 84px; right: 18px; }
}

/* ─── v1.3 additions ─────────────────────────────────── */

/* Quick-select option buttons */
.tya-btns {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 4px 0; align-self: flex-start;
  max-width: 100%;
}
.tya-opt-btn {
  background: #fff; color: var(--tya-navy);
  border: 1.5px solid var(--tya-navy);
  border-radius: 20px; padding: 7px 14px;
  font-family: var(--tya-font); font-size: 13px;
  cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.tya-opt-btn:hover {
  background: var(--tya-navy); color: #fff;
}

/* Submit card */
.tya-submit-card {
  background: #f0f4ff; border: 1.5px solid #b8c8f8;
  border-radius: 14px; padding: 16px;
  align-self: stretch; max-width: 100% !important;
  animation: tya-fadein .2s ease;
}
.tya-submit-card p { margin: 0 0 10px; font-family: var(--tya-font); font-size: 13px; color: #222; }
.tya-summary { color: #555; font-size: 12px !important; }
.tya-submit-btn {
  width: 100%; background: var(--tya-navy); color: #fff;
  border: none; border-radius: 10px; padding: 11px;
  font-family: var(--tya-font); font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.tya-submit-btn:hover { background: #1814a8; }
.tya-submit-btn:disabled { opacity: .6; cursor: default; }

/* Success card */
.tya-success-card {
  background: #f0faf4; border: 1.5px solid #b7e4c7;
  border-radius: 14px; padding: 16px;
  align-self: stretch; max-width: 100% !important;
  animation: tya-fadein .2s ease;
}
.tya-success-card p { margin: 0 0 8px; font-family: var(--tya-font); font-size: 13px; color: #1a3a25; }
.tya-success-card p:last-child { margin: 0; }
.tya-hours { font-size: 11.5px !important; color: #555 !important; }

/* Header new-conversation button */
#tya-header-actions { display: flex; align-items: center; gap: 4px; }
#tya-new {
  background: none; border: none; color: rgba(255,255,255,.7);
  font-size: 18px; cursor: pointer; padding: 4px 6px;
  transition: color .15s; line-height: 1;
}
#tya-new:hover { color: #fff; }

/* ─── Language selector ──────────────────────────────── */
.tya-lang-row { gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.tya-lang-btn {
  font-size: 14px !important;
  padding: 9px 18px !important;
  border-radius: 22px !important;
  font-weight: 600 !important;
}
.tya-lang-btn:nth-child(1) { border-color: var(--tya-navy); }
.tya-lang-btn:nth-child(2) { font-family: 'Tahoma', sans-serif !important; letter-spacing: 0; }
.tya-lang-btn:nth-child(3) { font-family: 'Tahoma', sans-serif !important; letter-spacing: 0; }

/* RTL message alignment */
#tya-messages[style*="rtl"] .tya-msg-user    { align-self: flex-start; border-bottom-left-radius: 4px; border-bottom-right-radius: 14px; }
#tya-messages[style*="rtl"] .tya-msg-assistant { align-self: flex-end; border-bottom-right-radius: 4px; border-bottom-left-radius: 14px; }

/* ─── v1.5 Language picker screen ───────────────────── */
#tya-lang-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 24px 20px;
  gap: 20px;
  background: #fff;
}
#tya-lang-title {
  text-align: center;
  font-family: var(--tya-font);
  font-size: 17px;
  font-weight: 700;
  color: var(--tya-navy);
  margin: 0;
  line-height: 1.5;
}
#tya-lang-title span {
  font-size: 13px;
  font-weight: 400;
  color: #666;
}
#tya-lang-boxes {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}
.tya-flag-box {
  flex: 1;
  padding: 18px 8px;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Tahoma', 'Arial', sans-serif;
  letter-spacing: 0;
  transition: transform .15s, opacity .15s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  line-height: 1.4;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tya-flag-box:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.22);
  opacity: .95;
}
.tya-flag-box:active { transform: scale(.97); }

/* Arabic box (KSA green) */
.tya-flag-box[data-lang="ar"] { font-size: 16px; }
/* English box (Tayareh navy) */
.tya-flag-box[data-lang="en"] { font-size: 14px; letter-spacing: .3px; }
/* Farsi box (Iran green) */
.tya-flag-box[data-lang="fa"] { font-size: 16px; }

/* Privacy screen */
#tya-priv-screen {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  flex: 1;
  padding: 24px 20px;
}
#tya-priv-inner { display: flex; flex-direction: column; gap: 16px; }
#tya-priv-text {
  font-family: var(--tya-font);
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  margin: 0;
  background: #f0f4ff;
  padding: 16px;
  border-radius: 12px;
  border-left: 3px solid var(--tya-navy);
}
#tya-priv-ok {
  background: var(--tya-navy);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-family: var(--tya-font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
#tya-priv-ok:hover { background: #1814a8; }
