/* ============================================
   Webty Chatbot - Clean UI Styles
   ============================================ */

/* Variables */
:root {
  --webty-primary: #201F5A;
  --webty-secondary: #F26228;
  --webty-gradient: linear-gradient(135deg, #201F5A 0%, #F26228 100%);
  --webty-gradient-hover: linear-gradient(135deg, #2a2970 0%, #ff7538 100%);
  --webty-bg: #ffffff;
  --webty-bg-light: #f8f9fa;
  --webty-text: #1a1a1a;
  --webty-text-light: #6c757d;
  --webty-border: rgba(0, 0, 0, 0.08);
  --webty-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  --webty-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.25);
  --webty-radius: 20px;
  --webty-radius-sm: 12px;
  --webty-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* FAB Button */
#webty-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border: none;
  cursor: pointer;
  z-index: 999999;
  background: transparent;
  background-image: url("https://www.webtymize.com/wp-content/uploads/2025/10/Sanal-Asistan-Webty.webp");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 0 15px rgba(242, 98, 40, 0.4));
  animation: gentleGlow 2s ease-in-out infinite;
}

@keyframes gentleGlow {
  0%, 100% {
    filter: drop-shadow(0 0 15px rgba(242, 98, 40, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 25px rgba(242, 98, 40, 0.6));
  }
}

#webty-fab:hover {
  transform: scale(1.1);
  animation: none;
}

#webty-fab:active {
  transform: scale(0.95);
}

/* Panel Container */
#webty-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--webty-bg);
  border-radius: var(--webty-radius);
  border: none;
  box-shadow: var(--webty-shadow-lg);
  z-index: 999998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  backdrop-filter: blur(10px);
  /* Mobilde scroll davranışını kontrol et */
  touch-action: pan-y;
}

/* States */
.webty-hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: var(--webty-transition);
}

.webty-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition: var(--webty-transition);
}

/* Header */
.webty-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: #fff;
  background: var(--webty-gradient);
  padding: 0 20px;
  box-shadow: none;
  flex-shrink: 0;
  border-radius: 0;
  margin: 0;
}

.webty-title {
  font-size: 20px;
  font-weight: 700;
}

.webty-x {
  position: absolute;
  right: 12px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--webty-transition);
  font-size: 20px;
  line-height: 1;
}

.webty-x:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Messages Area */
.webty-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: var(--webty-bg-light);
  scroll-behavior: smooth;
  overscroll-behavior: contain;      /* 1. Kaydırmayı bu kutunun içine hapseder, siteyi kaydırmaz */
  -webkit-overflow-scrolling: touch; /* 2. Mobilde (iOS/Android) takılmadan akıcı kaymasını sağlar */
  touch-action: pan-y;
}

.webty-messages::-webkit-scrollbar {
  width: 8px;
}

.webty-messages::-webkit-scrollbar-track {
  background: rgba(242, 98, 40, 0.05);
  border-radius: 4px;
}

.webty-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #F26228 0%, #201F5A 100%);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Message Wrapper */
.webty-message-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 12px 0;
  animation: slideIn 0.3s ease-out;
  width: 100%;
}

.webty-wrapper-user {
  align-items: flex-end;
}

/* İçerik Satırı (Avatar + Balon) */
.webty-msg-row {
  display: flex;
  gap: 10px;
  max-width: 85%;
  align-items: flex-end;
}

.webty-row-bot {
  justify-content: flex-start;
}

.webty-row-user {
  justify-content: flex-end;
}

/* Avatar */
.webty-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background-image: url("https://www.webtymize.com/wp-content/uploads/2025/10/Sanal-Asistan-Webty.webp");
  background-size: contain;
  flex-shrink: 0;
  background-position: center;
  background-repeat: no-repeat;
}

/* Bubbles */
.webty-bubble {
  padding: 14px 18px;
  border-radius: var(--webty-radius-sm);
  line-height: 1.6;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  word-wrap: break-word;
  max-width: 100%;
}

.webty-bot {
  background: linear-gradient(135deg, #F26228 0%, #ff7538 100%);
  color: #fff;
  border-top-left-radius: 4px;
}

.webty-user {
  background: linear-gradient(135deg, #201F5A 0%, #2a2970 100%);
  color: #fff;
  border-top-right-radius: 4px;
  text-align: right;
}

/* Butonlar */
.webty-btn-container {
  margin-top: 8px;
  margin-left: 46px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(85% - 46px);
}

.webty-link-btn {
  display: inline-block;
  padding: 8px 14px;
  background-color: #fff;
  color: var(--webty-primary);
  border: 1px solid var(--webty-primary);
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

.webty-link-btn:hover {
  background-color: var(--webty-primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.webty-link-btn:active {
  transform: translateY(0);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typing */
.webty-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #F26228 0%, #ff7538 100%);
  border-radius: var(--webty-radius-sm);
  border-top-left-radius: 4px;
}

.webty-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: typing 1.4s infinite;
}

.webty-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.webty-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.7;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

/* Input */
.webty-input {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--webty-border);
  background: var(--webty-bg);
  flex-shrink: 0;
}

#webty-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: var(--webty-radius-sm);
  border: 2px solid var(--webty-border);
  outline: none;
  background: var(--webty-bg-light);
  font-size: 15px;
  font-family: inherit;
  color: var(--webty-text);
  /* Mobilde zoom'u engelle */
  touch-action: manipulation;
}

#webty-input::placeholder {
  color: var(--webty-text-light);
}

#webty-input:focus {
  border-color: var(--webty-secondary);
  background: #fff;
  /* Focus'ta scroll'u engelle */
  scroll-margin: 0;
}

#webty-send {
  width: 48px;
  height: 48px;
  border-radius: var(--webty-radius-sm);
  border: 0;
  cursor: pointer;
  background: var(--webty-gradient);
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--webty-transition);
  flex-shrink: 0;
}

#webty-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(242, 98, 40, 0.4);
}

#webty-send:active {
  transform: translateY(0);
}

/* Overlay */
.webty-overlay {
  position: fixed;
  inset: 0;
  z-index: 999997;
  background: transparent;
  transition: var(--webty-transition);
}

/* Mobile */
@media (max-width: 520px) {
  /* Body scroll'unu kilitle - panel açıkken */
  body:has(#webty-panel.webty-visible) {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
  
  #webty-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    /* Klavye açıldığında panelin sabit kalması için */
    position: fixed !important;
  }

  #webty-fab {
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }
  
  /* Panel açıkken FAB'ı gizle - daha iyi bir yöntem */
  #webty-panel.webty-visible ~ #webty-fab {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
    pointer-events: none;
  }

  .webty-header {
    height: 60px;
    padding: 0 16px;
  }

  .webty-title {
    font-size: 18px;
  }

  .webty-x {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }

  .webty-messages {
    padding: 16px;
  }

  .webty-msg-row {
    max-width: 90%;
  }

  .webty-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .webty-bubble {
    padding: 12px 16px;
    font-size: 14px;
  }

  .webty-btn-container {
    margin-left: 42px;
    max-width: calc(90% - 42px);
  }

  .webty-link-btn {
    padding: 7px 12px;
    font-size: 12px;
  }

  .webty-input {
    padding: 12px;
    gap: 8px;
  }

  #webty-input {
    padding: 12px 16px;
    font-size: 14px;
    /* Mobil Safari'de zoom'u önle */
    font-size: 16px;
  }

  #webty-send {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
}

/* Tablet */
@media (max-width: 768px) and (min-width: 521px) {
  #webty-panel {
    width: 360px;
    height: 550px;
  }

  .webty-msg-row {
    max-width: 88%;
  }

  .webty-btn-container {
    max-width: calc(88% - 46px);
  }
}

/* Small mobile devices */
@media (max-width: 360px) {
  #webty-panel {
    height: 90vh;
    max-height: 90vh;
  }

  .webty-header {
    height: 56px;
  }

  .webty-title {
    font-size: 16px;
  }

  .webty-messages {
    padding: 12px;
  }

  .webty-msg-row {
    max-width: 92%;
  }

  .webty-bubble {
    padding: 10px 14px;
    font-size: 13px;
  }

  .webty-btn-container {
    margin-left: 38px;
    max-width: calc(92% - 38px);
    gap: 6px;
  }

  .webty-link-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}