/* -------------------------------------------------------
   Sela Modal — Container
------------------------------------------------------- */
#sela-modal {
  max-width: 720px;
  width: clamp(300px, 80vw, 720px);
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  animation: modalIn .18s ease-out;
  padding: 0;
}

#sela-modal::backdrop {
  background: rgba(0,0,0,0.12);
  backdrop-filter: none;   /* keep page text legible behind the persona modal */
}

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

/* -------------------------------------------------------
   Modal Inner Layout
------------------------------------------------------- */
#sela-modal .modal-inner {
  padding: 1rem;
  margin: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}

.modal-header .left {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.modal-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

#sela-modal-title {
  margin: 0;
}

/* -------------------------------------------------------
   Controls Row (icons, language selector)
------------------------------------------------------- */
.modal-controls {
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* Language selector */
.sela-lang-wrap {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .8rem;
}

.sela-lang-wrap select {
  border-radius: 999px;
  border: 1px solid #d0d0d0;
  padding: .15rem .6rem;
  font-size: .8rem;
  background: #fff;
  cursor: pointer;
}

.pill-lang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9rem;
  height: 1.4rem;
  border-radius: 999px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .03em;
}

.sela-lang-wrap.offline select {
  display: none;
}

.sela-lang-wrap.offline .pill-lang {
  opacity: 0.6;
}

/* -------------------------------------------------------
   Icons (mic, search, TTS)
------------------------------------------------------- */
#sela-modal .sela-icon {
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #555;
}

#sela-modal .sela-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  stroke: currentColor;
}

#sela-modal .sela-icon:hover {
  background: #e9e9e9;
  color: #222;
}

#sela-modal .sela-icon:focus-visible {
  outline: 2px solid #666;
  outline-offset: 2px;
}

/* Realtime mic bolt */
#sela-mic-rt-btn {
  position: relative;
}

#sela-mic-rt-btn::after {
  content: "⚡";
  position: absolute;
  right: -2px;
  bottom: -2px;
  font-size: 11px;
  line-height: 1;
  opacity: 0.85;
}

/* TTS loading spinner */
#sela-tts-btn[data-state="loading"] svg {
  opacity: 0.6;
  animation: sela-spin 1s linear infinite;
}

@keyframes sela-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* -------------------------------------------------------
   TTS Status + Audio Player
------------------------------------------------------- */
.sela-tts-status {
  font-size: 0.8rem;
  color: #666;
}

#sela-tts-player {
  display: none;
  width: 100%;
  margin-top: .25rem;
}

/* -------------------------------------------------------
   Conversation Thread
------------------------------------------------------- */
#sela-thread {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: #f9fbfa;
  padding: 1rem;
  border-radius: 14px;
  margin: .75rem 0;
  scroll-behavior: smooth;
}

/* -------------------------------------------------------
   Input Area
------------------------------------------------------- */
.sela-body {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-top: .5rem;
}

.sela-body label {
  font-size: .85rem;
  color: #555;
}

#sela-input {
  width: 100%;
  resize: vertical;
  padding: .6rem .75rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  font-size: .95rem;
  transition: border .15s ease, box-shadow .15s ease;
}

#sela-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(95,125,107,0.15);
}

/* -------------------------------------------------------
   Modal Footer — refined aesthetic
------------------------------------------------------- */
.sela-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;

  padding: .75rem 0 0;
  margin-top: 1rem;

  border-top: 1px solid #e3e8e5;   /* soft, subtle divider */
  font-size: .85rem;
  color: #556;                     /* slightly softer, more refined */
}

.sela-footer span {
  opacity: 0.85;
  line-height: 1.4;
}

.sela-footer-buttons {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sela-footer-buttons button {
  /* ensure buttons feel anchored and consistent */
  min-width: 90px;
}


/* -------------------------------------------------------
   11. Modal (Sela)
------------------------------------------------------- */
#sela-modal {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  animation: modalIn .18s ease-out;
  padding: 0;
}

#sela-modal::backdrop {
  background: rgba(0,0,0,0.12);
  backdrop-filter: none;   /* keep page text legible behind the persona modal */
}

#sela-modal .modal-inner {
  margin: 0;
}

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

/* -------------------------------------------------------
   12. Modal icons (mic, TTS, search)
------------------------------------------------------- */
#sela-modal .sela-icon {
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #555;
}

#sela-modal .sela-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  stroke: currentColor;
}

#sela-modal .sela-icon:hover {
  background: #e9e9e9;
  color: #222;
}

#sela-modal .sela-icon:focus-visible {
  outline: 2px solid #666;
  outline-offset: 2px;
}

.sela-tts-status {
  font-size: 0.8rem;
  color: #666;
  margin-left: 0.25rem;
}

#sela-tts-btn[data-state="loading"] svg {
  opacity: 0.6;
  animation: sela-spin 1s linear infinite;
}

#sela-mic-rt-btn {
  position: relative;
}

#sela-mic-rt-btn::after {
  content: "⚡";
  position: absolute;
  right: -2px;
  bottom: -2px;
  font-size: 11px;
  line-height: 1;
  opacity: 0.85;
}

@keyframes sela-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
