/* Praticore Web Asistan — sade, sağ alt köşe, mobil uyumlu */

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 240;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.chat-backdrop:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

.chat-widget {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 250;
  font-family: var(--font, "DM Sans", system-ui, sans-serif);
}

/* Toggle — minimal chat bubble */
.chat-toggle {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--accent, #3b82f6);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.chat-toggle:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.45);
}

.chat-toggle__icon {
  width: 22px;
  height: 22px;
  transition: opacity 0.2s, transform 0.2s;
}

.chat-toggle__icon--close {
  position: absolute;
  opacity: 0;
  transform: scale(0.8);
}

.chat-widget--open .chat-toggle__icon:not(.chat-toggle__icon--close) {
  opacity: 0;
  transform: scale(0.8);
}

.chat-widget--open .chat-toggle__icon--close {
  opacity: 1;
  transform: scale(1);
}

/* Panel — desktop: kart; mobil: alt sheet */
.chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(52px + 0.75rem);
  width: min(360px, calc(100vw - 2rem));
  height: min(480px, calc(100dvh - 6rem));
  background: var(--surface, #1a2234);
  border: 1px solid var(--border, rgba(148, 163, 184, 0.15));
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  transform-origin: bottom right;
  animation: chat-in 0.25s ease;
}

.chat-panel.hidden {
  display: none;
}

@keyframes chat-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border, rgba(148, 163, 184, 0.12));
  flex-shrink: 0;
}

.chat-header__info {
  min-width: 0;
  flex: 1;
}

.chat-header__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.chat-header__logo {
  flex-shrink: 0;
  width: 24px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.35));
}

.chat-header__titles {
  min-width: 0;
}

.chat-header strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #f1f5f9);
  line-height: 1.25;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 0.1rem;
}

.chat-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.chat-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.chat-close:hover {
  background: var(--bg-alt, rgba(255, 255, 255, 0.06));
  color: var(--text, #f1f5f9);
}

.chat-close svg {
  width: 18px;
  height: 18px;
}

.chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bg-alt, #111827);
  color: var(--text, #f1f5f9);
  border-bottom-left-radius: 4px;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent, #3b82f6);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.typing {
  align-self: flex-start;
  background: var(--bg-alt, #111827);
  color: var(--text-muted, #94a3b8);
  font-style: italic;
  font-size: 0.8rem;
}

.msg.error {
  align-self: stretch;
  max-width: 100%;
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  font-size: 0.82rem;
}

.msg.error p {
  margin: 0 0 0.5rem;
}

.msg-mail-link {
  display: inline-block;
  padding: 0.45rem 0.7rem;
  background: var(--accent, #3b82f6);
  color: #fff !important;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}

/* Chips — açılır/kapanır panel */
.chat-chips-panel {
  flex-shrink: 0;
  border-top: 1px solid var(--border, rgba(148, 163, 184, 0.08));
  background: rgba(10, 14, 23, 0.35);
}

[data-theme="light"] .chat-chips-panel {
  background: rgba(248, 250, 252, 0.6);
}

.chat-chips-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, background 0.15s ease;
}

.chat-chips-toggle:hover,
.chat-chips-toggle:focus-visible {
  color: var(--text, #f1f5f9);
  background: rgba(56, 189, 248, 0.06);
  outline: none;
}

.chat-chips-toggle__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.chat-chips-panel.is-collapsed .chat-chips-toggle__icon {
  transform: rotate(-90deg);
}

.chat-chips-body {
  overflow: hidden;
  max-height: 220px;
  opacity: 1;
  transition: max-height 0.28s ease, opacity 0.2s ease;
}

.chat-chips-panel.is-collapsed .chat-chips-body {
  max-height: 0;
  opacity: 0;
}

.chat-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0 0.75rem 0.75rem;
}

.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text-muted, #94a3b8);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: start;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

[data-theme="light"] .chat-chip {
  background: rgba(255, 255, 255, 0.9);
  color: #64748b;
}

.chat-chip__icon {
  flex-shrink: 0;
  font-size: 0.95rem;
  line-height: 1;
}

.chat-chip__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.chat-chip:hover {
  border-color: rgba(56, 189, 248, 0.45);
  color: #e2e8f0;
  background: rgba(56, 189, 248, 0.1);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.12);
}

[data-theme="light"] .chat-chip:hover {
  color: #0f172a;
  background: rgba(59, 130, 246, 0.08);
}

.chat-chip--featured {
  grid-column: 1 / -1;
  justify-content: center;
  border-color: rgba(56, 189, 248, 0.35);
  background:
    linear-gradient(rgba(15, 23, 42, 0.65), rgba(15, 23, 42, 0.65)) padding-box,
    linear-gradient(135deg, rgba(56, 189, 248, 0.5), rgba(139, 92, 246, 0.5)) border-box;
  color: #e2e8f0;
}

[data-theme="light"] .chat-chip--featured {
  background:
    linear-gradient(rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.95)) padding-box,
    linear-gradient(135deg, rgba(56, 189, 248, 0.45), rgba(139, 92, 246, 0.45)) border-box;
  color: #0f172a;
}

.chat-chip--featured .chat-chip__label {
  white-space: normal;
  text-align: center;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem max(0.65rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border, rgba(148, 163, 184, 0.12));
  flex-shrink: 0;
  background: var(--surface, #1a2234);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border, rgba(148, 163, 184, 0.15));
  border-radius: 10px;
  background: var(--bg, #0a0e17);
  color: var(--text, #f1f5f9);
  font-size: 16px; /* iOS zoom önleme */
  font-family: inherit;
}

.chat-form input:focus {
  outline: none;
  border-color: var(--accent, #3b82f6);
}

.chat-form button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--accent, #3b82f6);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.chat-form button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-form button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

/* Asistan açıkken arka plan kaydırma çubuğunu gizle; gutter ile kaymayı önle. */
html {
  scrollbar-gutter: stable;
}

body.chat-open {
  overflow: hidden;
}

/* RTL */
html[dir="rtl"] .chat-widget {
  right: auto;
  left: max(1rem, env(safe-area-inset-left));
}

html[dir="rtl"] .chat-panel {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

/* Mobil — alt sheet */
@media (max-width: 600px) {
  .chat-widget {
    right: 0;
    left: 0;
    bottom: 0;
    padding: 0;
  }

  .chat-toggle {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 252;
  }

  .chat-widget--open .chat-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
  }

  .chat-panel {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: min(88dvh, 560px);
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    transform-origin: bottom center;
    animation: chat-sheet-in 0.3s ease;
  }

  @keyframes chat-sheet-in {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  html[dir="rtl"] .chat-toggle {
    right: auto;
    left: max(1rem, env(safe-area-inset-left));
  }
}

/* Light theme */
[data-theme="light"] .chat-panel {
  background: #fff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .msg.bot {
  background: #f1f5f9;
  color: #0f172a;
}

[data-theme="light"] .chat-form input {
  background: #f8fafc;
  color: #0f172a;
}

/* Structured AI responses */
.msg--rich {
  align-self: flex-start;
  max-width: min(100%, 320px);
  width: 100%;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.rich-card {
  width: 100%;
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(99, 102, 241, 0.22);
  background:
    linear-gradient(165deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98)) padding-box,
    linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(139, 92, 246, 0.28)) border-box;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.rich-card__title {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.rich-card__summary {
  margin: 0 0 0.7rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: #cbd5e1;
}

.rich-sections,
.rich-more__body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.rich-section,
.rich-more {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
  overflow: hidden;
}

.rich-section__head,
.rich-more__toggle {
  list-style: none;
  cursor: pointer;
  padding: 0.55rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  user-select: none;
}

.rich-section__head::-webkit-details-marker,
.rich-more__toggle::-webkit-details-marker {
  display: none;
}

.rich-section__head::before,
.rich-more__toggle::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4rem;
  color: #818cf8;
  transition: transform 0.2s ease;
}

.rich-section[open] .rich-section__head::before,
.rich-more[open] .rich-more__toggle::before {
  transform: rotate(90deg);
}

.rich-section__body {
  padding: 0 0.65rem 0.6rem;
}

.rich-list {
  margin: 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.rich-list li {
  font-size: 0.76rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.rich-more {
  margin-top: 0.45rem;
}

.rich-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

.rich-reply {
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.12);
  color: #e0e7ff;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  max-width: 100%;
  white-space: normal;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.rich-reply:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.55);
  transform: translateY(-1px);
}

.rich-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff !important;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.28);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.rich-cta:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* Premium dokunuş: kart girişi ve hover derinliği */
.msg--rich {
  animation: rich-card-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rich-card-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.rich-card {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.rich-card:hover {
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.4);
}

.rich-cta {
  position: relative;
  overflow: hidden;
  letter-spacing: 0.01em;
}

/* CTA üzerinde ince parlama efekti */
.rich-cta::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}

.rich-cta:hover::after {
  transform: translateX(120%);
}

.rich-cta--contact.is-revealed {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

/* İletişim aksiyonları: WhatsApp + Arama */
.rich-contact-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.6rem;
  animation: rich-contact-in 0.25s ease;
}

@keyframes rich-contact-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.rich-contact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.6rem;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.rich-contact-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.rich-contact-btn:hover {
  transform: translateY(-1px);
}

.rich-contact-btn--whatsapp {
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.3);
}

.rich-contact-btn--whatsapp:hover {
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.42);
}

.rich-contact-btn--call {
  background: rgba(56, 189, 248, 0.14);
  color: #e0f2fe;
  border-color: rgba(56, 189, 248, 0.45);
}

.rich-contact-btn--call:hover {
  background: rgba(56, 189, 248, 0.22);
}

[data-theme="light"] .rich-contact-btn--call {
  background: rgba(59, 130, 246, 0.1);
  color: #0c4a6e;
  border-color: rgba(59, 130, 246, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .msg--rich,
  .rich-contact-actions { animation: none; }
  .rich-cta::after { display: none; }
}

[data-theme="light"] .rich-card {
  background:
    linear-gradient(165deg, #ffffff, #f8fafc) padding-box,
    linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(139, 92, 246, 0.28)) border-box;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .rich-card__title {
  color: #0f172a;
}

[data-theme="light"] .rich-card__summary,
[data-theme="light"] .rich-list li {
  color: #475569;
}

[data-theme="light"] .rich-section,
[data-theme="light"] .rich-more {
  background: rgba(248, 250, 252, 0.9);
  border-color: rgba(148, 163, 184, 0.25);
}

[data-theme="light"] .rich-section__head,
[data-theme="light"] .rich-more__toggle {
  color: #1e293b;
}

[data-theme="light"] .rich-reply {
  background: rgba(99, 102, 241, 0.08);
  color: #3730a3;
  border-color: rgba(99, 102, 241, 0.25);
}

@media (max-width: 600px) {
  .msg--rich {
    max-width: 100%;
  }

  .rich-card {
    padding: 0.75rem 0.8rem;
  }

  .rich-card__title {
    font-size: 0.9rem;
  }

  .rich-replies {
    flex-direction: column;
  }

  .rich-reply {
    width: 100%;
    border-radius: 10px;
  }
}
