/* ============================================================
   Deliptv AI Canlı Destek & Maç Asistanı (Web Chat Widget)
   ============================================================ */

:root {
  --ai-primary: #e50914;
  --ai-primary-glow: rgba(229, 9, 20, 0.4);
  --ai-bg: #0f1015;
  --ai-card: rgba(22, 24, 32, 0.94);
  --ai-border: rgba(255, 255, 255, 0.1);
  --ai-text: #f3f4f6;
  --ai-muted: #9ca3af;
  --ai-gold: #d4af37;
  --ai-radius: 18px;
}

/* 1. Kayan Tetikleyici Buton (Floating Launcher) */
.ai-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #e50914 0%, #b20710 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50px;
  padding: 10px 18px 10px 12px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(229, 9, 20, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.ai-chat-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 36px rgba(229, 9, 20, 0.55), 0 6px 16px rgba(0, 0, 0, 0.6);
}

.ai-launcher-icon {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-launcher-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.ai-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  background: #10b981;
  border: 2px solid #b20710;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ai-launcher-label {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.ai-launcher-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.ai-launcher-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-launcher-sub::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

/* 2. Sohbet Penceresi (Chat Window) */
.ai-chat-window {
  position: fixed;
  right: 22px;
  bottom: 84px;
  width: min(390px, calc(100vw - 28px));
  height: min(600px, calc(100vh - 110px));
  background: var(--ai-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 1px 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(15, 16, 21, 0.9);
  border-bottom: 1px solid var(--ai-border);
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid rgba(229, 9, 20, 0.3);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.ai-chat-title-box h3 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

.ai-chat-title-box p {
  font-size: 11px;
  color: #10b981;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-chat-title-box p::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-chat-btn-wa {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: #25d366;
  display: grid;
  place-items: center;
  text-decoration: none;
  transition: background 0.2s;
}

.ai-chat-btn-wa:hover {
  background: rgba(37, 211, 102, 0.3);
}

.ai-chat-btn-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ai-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: all 0.2s;
}

.ai-chat-btn-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Messages Area */
.ai-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ai-chat-body::-webkit-scrollbar {
  width: 5px;
}
.ai-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: ai-fade-in 0.2s ease;
}

@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
  align-self: flex-end;
}

.ai-msg.assistant {
  align-self: flex-start;
}

.ai-msg-bubble {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 14px;
  word-break: break-word;
}

.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #e50914 0%, #c40812 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg.assistant .ai-msg-bubble {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ai-text);
  border-bottom-left-radius: 4px;
}

.ai-msg-time {
  font-size: 10px;
  color: var(--ai-muted);
  margin-top: 3px;
  padding: 0 4px;
}

.ai-msg.user .ai-msg-time {
  align-self: flex-end;
}

/* Markdown formatting inside bubbles */
.ai-msg-bubble p { margin: 0 0 8px; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble strong { color: #fff; font-weight: 700; }
.ai-msg-bubble ul, .ai-msg-bubble ol { margin: 6px 0 6px 18px; padding: 0; }
.ai-msg-bubble li { margin-bottom: 4px; }
.ai-msg-bubble a { color: #60a5fa; text-decoration: underline; font-weight: 600; }
.ai-msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.ai-msg-bubble th, .ai-msg-bubble td {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}
.ai-msg-bubble th {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Quick Actions (Pills) */
.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.ai-quick-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
  padding: 6px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  user-select: none;
}

.ai-quick-btn:hover {
  background: rgba(229, 9, 20, 0.2);
  border-color: rgba(229, 9, 20, 0.4);
  color: #fff;
  transform: translateY(-1px);
}

/* Typing Dots Animation */
.ai-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: ai-bounce 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Footer & Input */
.ai-chat-footer {
  padding: 12px 14px;
  background: rgba(15, 16, 21, 0.95);
  border-top: 1px solid var(--ai-border);
}

.ai-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s;
}

.ai-chat-input-row:focus-within {
  border-color: var(--ai-primary);
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.2);
}

.ai-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  padding: 6px 0;
}

.ai-chat-input::placeholder {
  color: #6b7280;
}

.ai-chat-btn-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ai-primary);
  border: none;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.ai-chat-btn-send:hover {
  background: #f40a16;
  transform: scale(1.05);
}

.ai-chat-btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ai-chat-powered {
  text-align: center;
  font-size: 10px;
  color: #6b7280;
  margin-top: 6px;
}

.ai-chat-powered a {
  color: #9ca3af;
  text-decoration: none;
}

/* 3. Ön Karşılama & Müşteri Kayıt Formu (Pre-chat Form) */
.ai-onboarding-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 20px;
  height: 100%;
  text-align: center;
  animation: ai-fade-in 0.3s ease;
}

.ai-onboarding-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid rgba(229, 9, 20, 0.3);
  display: grid;
  place-items: center;
  font-size: 26px;
  margin-bottom: 14px;
}

.ai-onboarding-title {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
}

.ai-onboarding-desc {
  font-size: 12.5px;
  color: var(--ai-muted);
  line-height: 1.5;
  margin: 0 0 20px;
}

.ai-onboarding-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.ai-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-input-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: #d1d5db;
}

.ai-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.ai-input-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0.7;
}

.ai-form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 12px 10px 36px;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-form-input:focus {
  border-color: var(--ai-primary);
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.ai-btn-start {
  background: linear-gradient(135deg, #e50914 0%, #b20710 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(229, 9, 20, 0.35);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.ai-btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(229, 9, 20, 0.5);
}

.ai-btn-start:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.ai-privacy-note {
  font-size: 10.5px;
  color: #6b7280;
  text-align: center;
  margin-top: 10px;
}

/* Mobil Uyumluluk */
@media (max-width: 480px) {
  .ai-chat-launcher {
    right: 14px;
    bottom: 14px;
    padding: 8px 14px 8px 10px;
  }
  .ai-chat-launcher .ai-launcher-sub {
    display: none;
  }
  .ai-chat-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
}
