/* =====================================================================
   Defne — AI concierge widget for Etemoğlu Diş / Tower Dental Clinic
   Powered by OZAI AIRA.
   Clinical-luxury: warm porcelain whites, deep petrol-teal accent,
   generous whitespace, soft depth. Light theme by design — the calm,
   daytime reassurance a nervous patient needs.
   Self-contained: no external CSS frameworks. All tokens scoped under
   .aira-widget so it can be embedded into any host page safely.
   ===================================================================== */

.aira-widget,
.aira-widget *,
.aira-widget *::before,
.aira-widget *::after {
  box-sizing: border-box;
}

.aira-widget {
  /* --- Palette (OKLCH, neutrals tinted toward the petrol hue ~195) --- */
  --porcelain:     oklch(0.985 0.004 195);   /* page-level bone white      */
  --surface:       oklch(0.995 0.003 195);   /* card / panel               */
  --surface-soft:  oklch(0.965 0.006 195);   /* recessed wells, user bubble */
  --line:          oklch(0.915 0.008 200);   /* hairline borders           */
  --line-soft:     oklch(0.945 0.006 200);

  --ink:           oklch(0.275 0.022 220);   /* primary text (deep slate)  */
  --ink-soft:      oklch(0.470 0.018 220);   /* secondary text             */
  --ink-faint:     oklch(0.620 0.014 220);   /* tertiary / meta            */

  /* The single refined accent: a deep petrol-teal. Clinical, not cyan. */
  --teal:          oklch(0.520 0.072 205);
  --teal-deep:     oklch(0.420 0.070 210);
  --teal-bright:   oklch(0.600 0.085 200);
  --teal-wash:     oklch(0.965 0.018 200);   /* assistant bubble tint      */
  --teal-ghost:    oklch(0.955 0.012 200);

  --gold:          oklch(0.760 0.085 85);    /* warm trust spark, used rarely */
  --whatsapp:      oklch(0.640 0.150 155);   /* WhatsApp green             */
  --whatsapp-deep: oklch(0.560 0.145 155);
  --danger:        oklch(0.580 0.150 28);

  /* --- Type --- */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;

  /* --- Elevation (soft, layered, tinted shadows — never harsh black) --- */
  --shadow-sm: 0 1px 2px oklch(0.40 0.03 220 / 0.06),
               0 2px 6px oklch(0.40 0.03 220 / 0.05);
  --shadow-md: 0 4px 14px oklch(0.40 0.03 220 / 0.08),
               0 10px 30px oklch(0.40 0.03 220 / 0.07);
  --shadow-lg: 0 8px 24px oklch(0.38 0.03 220 / 0.10),
               0 24px 60px oklch(0.38 0.03 220 / 0.12);

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 13px;
  --radius-bubble: 20px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1); /* ease-out-expo-ish */

  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* =====================================================================
   Panel shell
   ===================================================================== */
.aira-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  height: min(680px, 86vh);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

/* a whisper of warmth at the very top of the panel */
.aira-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 180px;
  background:
    radial-gradient(120% 80% at 18% -10%, var(--teal-ghost), transparent 60%),
    radial-gradient(90% 60% at 100% -20%, oklch(0.97 0.02 85 / 0.5), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* =====================================================================
   Header
   ===================================================================== */
.aira-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(to bottom, var(--surface), oklch(0.99 0.004 195 / 0.85));
  backdrop-filter: saturate(1.05);
}

.aira-avatar {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 120% at 30% 20%, var(--teal-bright), var(--teal-deep) 78%);
  color: oklch(0.99 0.01 200);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.01em;
  box-shadow:
    0 4px 12px oklch(0.45 0.07 205 / 0.30),
    inset 0 1px 1px oklch(1 0 0 / 0.25);
}

/* live presence dot */
.aira-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--whatsapp);
  border: 2.5px solid var(--surface);
  box-shadow: 0 0 0 0 oklch(0.64 0.15 155 / 0.5);
  animation: aira-pulse 2.6s var(--ease-out) infinite;
}
@keyframes aira-pulse {
  0%   { box-shadow: 0 0 0 0 oklch(0.64 0.15 155 / 0.45); }
  70%  { box-shadow: 0 0 0 7px oklch(0.64 0.15 155 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(0.64 0.15 155 / 0); }
}

.aira-id {
  min-width: 0;
  flex: 1;
}
.aira-id .aira-name {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.005em;
  color: var(--ink);
}
.aira-id .aira-name small {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.aira-id .aira-sub {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aira-id .aira-sub b { color: var(--teal-deep); font-weight: 600; }

/* Language switcher */
.aira-langs {
  display: inline-flex;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.aira-lang {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
.aira-lang:hover { color: var(--ink); }
.aira-lang[aria-pressed="true"] {
  background: var(--surface);
  color: var(--teal-deep);
  box-shadow: var(--shadow-sm);
}
.aira-lang:focus-visible {
  outline: 2px solid var(--teal-bright);
  outline-offset: 2px;
}

/* =====================================================================
   Message stream
   ===================================================================== */
.aira-stream {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.aira-stream::-webkit-scrollbar { width: 9px; }
.aira-stream::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 3px solid var(--surface);
}
.aira-stream::-webkit-scrollbar-thumb:hover { background: oklch(0.86 0.01 200); }

.aira-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: aira-rise 0.42s var(--ease-out) both;
}
@keyframes aira-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.aira-row.user { align-self: flex-end; align-items: flex-end; }
.aira-row.bot  { align-self: flex-start; align-items: flex-start; }

.aira-bubble {
  padding: 12px 15px;
  font-size: 14.5px;
  line-height: 1.56;
  border-radius: var(--radius-bubble);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.aira-row.bot .aira-bubble {
  background: var(--teal-wash);
  color: var(--ink);
  border: 1px solid oklch(0.92 0.012 200);
  border-bottom-left-radius: 7px;
}
.aira-row.user .aira-bubble {
  background: var(--ink);
  color: oklch(0.97 0.005 200);
  border-bottom-right-radius: 7px;
  box-shadow: var(--shadow-sm);
}
.aira-bubble p { margin: 0 0 0.55em; }
.aira-bubble p:last-child { margin-bottom: 0; }
.aira-bubble strong { font-weight: 650; }
.aira-bubble a {
  color: var(--teal-deep);
  font-weight: 600;
  text-underline-offset: 2px;
}
.aira-row.user .aira-bubble a { color: oklch(0.85 0.04 200); }
.aira-bubble ul { margin: 0.3em 0; padding-left: 1.15em; }
.aira-bubble li { margin: 0.2em 0; }

/* speaker label above bot bubbles */
.aira-row.bot .aira-who {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 5px 4px;
}
.aira-row.bot .aira-who::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--teal);
  vertical-align: middle;
}

/* streaming caret */
.aira-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -0.18em;
  background: var(--teal-deep);
  border-radius: 1px;
  animation: aira-blink 1s steps(2) infinite;
}
@keyframes aira-blink { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }

/* typing dots (pre-first-token) */
.aira-typing {
  display: inline-flex;
  gap: 4px;
  padding: 3px 1px;
}
.aira-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--teal);
  opacity: 0.5;
  animation: aira-bob 1.15s var(--ease-out) infinite;
}
.aira-typing span:nth-child(2) { animation-delay: 0.16s; }
.aira-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes aira-bob {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 0.95; }
}

/* inline error notice */
.aira-error {
  align-self: center;
  max-width: 92%;
  text-align: center;
  font-size: 13px;
  color: var(--danger);
  background: oklch(0.97 0.02 28);
  border: 1px solid oklch(0.90 0.04 28);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
}
.aira-error button {
  appearance: none;
  margin-top: 6px;
  border: 1px solid oklch(0.85 0.05 28);
  background: var(--surface);
  color: var(--danger);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
.aira-error button:hover { background: oklch(0.98 0.02 28); }

/* =====================================================================
   Quick-action chips
   ===================================================================== */
.aira-chips {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 18px 12px;
}
.aira-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-out), border-color 0.2s,
              color 0.2s, background 0.2s;
}
.aira-chip svg { width: 15px; height: 15px; flex: none; color: var(--teal); }
.aira-chip:hover {
  transform: translateY(-1px);
  border-color: oklch(0.84 0.04 200);
  color: var(--ink);
  background: var(--teal-ghost);
}
.aira-chip:active { transform: translateY(0); }
.aira-chip:focus-visible {
  outline: 2px solid var(--teal-bright);
  outline-offset: 2px;
}
.aira-chip.is-human {
  border-color: oklch(0.86 0.07 155);
  color: var(--whatsapp-deep);
}
.aira-chip.is-human svg { color: var(--whatsapp); }
.aira-chip.is-human:hover { background: oklch(0.97 0.03 155); }

/* =====================================================================
   Composer
   ===================================================================== */
.aira-composer {
  position: relative;
  z-index: 1;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.aira-inputwrap {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  background: var(--surface-soft);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 7px 7px 7px 15px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.aira-inputwrap:focus-within {
  border-color: var(--teal-bright);
  background: var(--surface);
  box-shadow: 0 0 0 4px oklch(0.60 0.085 200 / 0.12);
}
.aira-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  resize: none;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 120px;
  padding: 6px 0;
}
.aira-input::placeholder { color: var(--ink-faint); }
.aira-input:focus { outline: none; }

.aira-send {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--teal-bright), var(--teal-deep));
  color: oklch(0.99 0.01 200);
  cursor: pointer;
  box-shadow: 0 3px 10px oklch(0.45 0.07 205 / 0.30);
  transition: transform 0.18s var(--ease-out), box-shadow 0.2s, opacity 0.2s;
}
.aira-send svg { width: 19px; height: 19px; }
.aira-send:hover:not(:disabled) { transform: translateY(-1px); }
.aira-send:active:not(:disabled) { transform: translateY(0) scale(0.96); }
.aira-send:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.aira-send:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; }

.aira-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding: 0 2px;
}
.aira-footer .aira-disclaimer {
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-faint);
}
.aira-footer .aira-powered {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.aira-footer .aira-powered b { color: var(--teal-deep); font-weight: 600; }

/* prominent WhatsApp handoff button (always visible above composer) */
.aira-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0 16px 10px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--whatsapp), var(--whatsapp-deep));
  color: oklch(0.99 0.01 155);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 4px 14px oklch(0.62 0.15 155 / 0.28);
  transition: transform 0.18s var(--ease-out), box-shadow 0.2s;
  position: relative; z-index: 1;
}
.aira-wa svg { width: 19px; height: 19px; }
.aira-wa:hover { transform: translateY(-1px); box-shadow: 0 6px 20px oklch(0.62 0.15 155 / 0.34); }
.aira-wa:active { transform: translateY(0); }
.aira-wa:focus-visible { outline: 2px solid var(--whatsapp); outline-offset: 3px; }

/* =====================================================================
   Reduced motion + responsive
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .aira-widget *,
  .aira-widget *::before,
  .aira-widget *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 480px) {
  .aira-panel {
    max-width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
  }
  .aira-id .aira-sub { font-size: 12px; }
  .aira-row { max-width: 90%; }
}
