/* Softer base reset: remove aggressive margin/padding & font overrides */
#ailc-widget {
  box-sizing: border-box;
  font-family: 'Inter', Arial, sans-serif;
  font-size: 14px; /* consistent baseline */
  line-height: 1.4;
}
#ailc-widget *,
#ailc-widget *::before,
#ailc-widget *::after { box-sizing: inherit; }

/* Normalize headings & paragraphs if present */
#ailc-widget h1, #ailc-widget h2, #ailc-widget h3,
#ailc-widget h4, #ailc-widget h5, #ailc-widget h6,
#ailc-widget p { margin:0; }

#ailc-widget {
  --ailc-color: #1566ce;
  --ailc-color-dark: #0f4a9e;
  --ailc-bg-light: #f8fafc;
  --ailc-bg-ai: #f1f8ff;
  --ailc-text-ai: #193264;
  --ailc-border-light: #e1e8f5;
  --ailc-border-focus: #3fa4ff;
  --ailc-typing-color: #3a7bd5;
  position: fixed !important;
  bottom: 32px;
  right: 32px;
  width: 340px !important;
  max-width: 95vw !important;
  font-family: 'Inter', Arial, sans-serif;
  z-index: 99999 !important;
  border-radius: 20px !important;
  box-shadow: 0 8px 32px 0 rgba(60,60,100,0.14), 0 1.5px 8px 0 rgba(0,0,0,0.06) !important;
  overflow: hidden;
  background: #fff;
  animation: ailc-popin 0.3s cubic-bezier(.29,.7,.49,1.3) 1;
}

#ailc-widget.pos-bl { right:auto; left:32px; }
#ailc-widget.pos-tr { bottom:auto; top:32px; }
#ailc-widget.pos-tl { right:auto; bottom:auto; top:32px; left:32px; }

@keyframes ailc-popin {
  from { transform: scale(0.93) translateY(24px); opacity: 0.4; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

#ailc-header {
  background: var(--ailc-color);
  color: #fff;
  padding: 16px 20px;
  font-weight: 600;
  letter-spacing: .02em;
  font-size: 1.15rem;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--ailc-color-dark);
}

#ailc-title {
  flex: 1;
  margin-right: auto;
}
#ailc-header::before {
  content: '💬';
  font-size: 1.5rem;
  margin-right: 8px;
}

/* Flexible height improves responsiveness & avoids clipping */
#ailc-body {
  display: flex;
  flex-direction: column;
  background: var(--ailc-bg-light);
  min-height: 380px;
  max-height: 450px;
  height: auto;
  border-radius: 0 0 20px 20px;
  position: relative;
}

#ailc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 6px 14px;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--ailc-border-light) var(--ailc-bg-light);
}
#ailc-messages::-webkit-scrollbar {
  width: 8px;
  background: var(--ailc-bg-light);
}
#ailc-messages::-webkit-scrollbar-thumb {
  background: var(--ailc-border-light);
  border-radius: 6px;
}

.ailc-chat-message {
  display: flex;
  align-items: flex-end;
  margin-bottom: 16px;
  gap: 10px;
}

.ailc-chat-message:nth-child(1) { animation-delay: 0.1s; }
.ailc-chat-message:nth-child(2) { animation-delay: 0.2s; }
.ailc-chat-message:nth-child(3) { animation-delay: 0.3s; }
.ailc-chat-message:nth-child(4) { animation-delay: 0.4s; }
.ailc-chat-message:nth-child(5) { animation-delay: 0.5s; }
.ailc-user { justify-content: flex-end; }
.ailc-ai   { justify-content: flex-start; }

.ailc-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eaf1fb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin: 0 2px;
  box-shadow: 0 1.5px 5px 0 rgba(40,80,160,0.07);
  border: 2px solid var(--ailc-border-light);
}

.ailc-ai   .ailc-avatar { background: #e8effd; color: var(--ailc-color); border-color: #b3d1fa; }
.ailc-user .ailc-avatar { background: #e7fbe7; color: #218921; border-color: #baf6c5; }

.ailc-bubble {
  max-width: 77%;
  min-width: 42px;
  font-size: 1.05rem;
  padding: 11px 16px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 9px 0 rgba(80,120,200,0.07);
  word-break: break-word;
  position: relative;
  white-space: pre-line;
  background: #fff;
  color: #222;
  border: 1px solid var(--ailc-border-light);
  line-height: 1.5;
  animation: ailc-bubble-in .25s ease;
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

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

.ailc-user .ailc-bubble {
  background: var(--ailc-color);
  color: #fff;
  border: none;
  border-radius: 16px 16px 16px 4px;
  align-self: flex-end;
}
.ailc-ai .ailc-bubble {
  background: var(--ailc-bg-ai);
  color: var(--ailc-text-ai);
  border-radius: 16px 16px 4px 16px;
}

#ailc-input {
  display: flex;
  border-top: 1px solid var(--ailc-border-light);
  padding: 8px 8px 8px 10px;
  background: var(--ailc-bg-light);
  align-items: center;
  gap: 8px;
}

#ailc-input input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.08rem;
  padding: 10px 15px;
  border: 1px solid var(--ailc-border-light);
  border-radius: 14px;
  outline: none;
  transition: border .18s;
  background: #fff;
}
#ailc-input input:focus {
  border-color: var(--ailc-border-focus);
}

#ailc-input button {
  background: var(--ailc-color);
  color: #fff;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  padding: 10px 18px;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1.5px 5px 0 rgba(90,160,255,0.09);
}

#ailc-input button:hover {
  background: var(--ailc-color-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px 0 rgba(90,160,255,0.15);
}

#ailc-input button:disabled {
  opacity: 0.7;
  cursor: default;
  transform: none;
  position: relative;
}

#ailc-input button:disabled::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: ailc-loading-spin 1s linear infinite;
}

@keyframes ailc-loading-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Enhanced button interactions */
#ailc-input button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(90, 160, 255, 0.2);
}

#ailc-toggle:active,
#ailc-end:active {
  transform: scale(0.95);
}

/* Targeted transitions only (better performance) */
.ailc-bubble,
#ailc-input input,
#ailc-input button,
.ailc-avatar,
#ailc-intro button,
#ailc-intro input,
#ailc-intro select,
#ailc-messages::-webkit-scrollbar-thumb { transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease, color .2s ease; }

/* Enhanced focus states */
#ailc-input input:focus {
  border-color: var(--ailc-border-focus);
  box-shadow: 0 0 0 3px rgba(63, 164, 255, 0.15);
  transform: translateY(-1px);
}

/* Avatar hover effects */
.ailc-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 12px rgba(40, 80, 160, 0.15);
}

/* Scrollbar hover effects */
#ailc-messages::-webkit-scrollbar-thumb:hover {
  background: var(--ailc-border-focus);
}

#ailc-intro {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(135deg, var(--ailc-bg-light) 0%, #f0f4ff 100%);
  border-radius: 16px;
  margin: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  flex: 1;
  justify-content: center;
}

#ailc-intro input,
#ailc-intro select {
  padding: 12px 16px;
  border: 2px solid var(--ailc-border-light);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  transition: all 0.3s ease;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

#ailc-intro input:focus,
#ailc-intro select:focus {
  border-color: var(--ailc-border-focus);
  box-shadow: 0 0 0 3px rgba(63, 164, 255, 0.1);
  transform: translateY(-1px);
}

#ailc-intro input::placeholder {
  color: #9ca3af;
  font-style: italic;
}

#ailc-intro button {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--ailc-color) 0%, var(--ailc-color-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(21, 102, 206, 0.3);
  position: relative;
  overflow: hidden;
}

#ailc-intro button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

#ailc-intro button:hover::before {
  left: 100%;
}

#ailc-intro button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(21, 102, 206, 0.4);
}

#ailc-intro button:active {
  transform: translateY(0);
}

#ailc-typing {
  display: none;
  margin: 0 0 12px 8px;
  color: var(--ailc-typing-color);
  font-size: 1.02rem;
  align-items: center;
  animation: ailc-typing-pulse 2s ease-in-out infinite;
  font-weight: 500;
  letter-spacing: .03em;
  padding: 8px 12px;
  background: rgba(58, 123, 213, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

@keyframes ailc-typing-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

.dots span {
  display: inline-block;
  animation: ailc-blink 1.4s infinite;
  margin: 0 1px;
}

.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }

@keyframes ailc-blink {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Tablet and small desktop screens */
@media (max-width: 768px) {
  /* Desktop-style layout for tablets when expanded */
  #ailc-widget:not(.minimized) {
    width: 360px;
    max-width: 90vw;
    bottom: 20px;
    right: 20px;
  }

  #ailc-widget:not(.minimized) #ailc-body {
    height: 380px;
  }

  #ailc-widget:not(.minimized) #ailc-header {
    padding: 16px 18px;
    font-size: 1.1rem;
  }

  .ailc-bubble {
    font-size: 1rem;
    padding: 10px 14px;
    max-width: 80%;
  }

  .ailc-avatar {
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
  }

  #ailc-messages {
    padding: 16px 12px 6px 12px;
  }

  #ailc-disclaimer {
    padding: 12px 14px;
    font-size: 0.9rem;
  }

  #ailc-input input {
    font-size: 1.05rem;
    padding: 12px 16px;
  }

  #ailc-input button {
    padding: 12px 20px;
    font-size: 1rem;
    min-width: 60px;
  }
}

/* Enhanced mobile phones - responsive design */
@media (max-width: 480px) {
  /* Circular icon adjustments for small screens */
  #ailc-widget.minimized {
    width: 60px !important;
    height: 60px !important;
    bottom: 20px;
    right: 20px;
  }
  
  #ailc-widget.minimized #ailc-header {
    width: 60px;
    height: 60px;
  }
  
  #ailc-widget.minimized #ailc-header::before {
    font-size: 28px;
  }

  /* Full-screen mode optimizations for small screens */
  #ailc-widget:not(.minimized) .ailc-bubble {
    font-size: 1rem;
    padding: 12px 16px;
    max-width: 85%;
    touch-action: manipulation;
    line-height: 1.5;
  }

  #ailc-widget:not(.minimized) .ailc-avatar {
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
    touch-action: manipulation;
  }

  #ailc-widget:not(.minimized) #ailc-messages {
    padding: 16px 14px 8px 14px;
    scroll-padding-top: 20px;
  }

  #ailc-widget:not(.minimized) #ailc-input {
    padding: 16px 14px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    gap: 12px;
    border-top: 2px solid var(--ailc-border-light);
  }

  #ailc-widget:not(.minimized) #ailc-input input {
    font-size: 16px; /* Prevent iOS zoom */
    padding: 14px 18px;
    min-height: 48px; /* Better touch target */
    border-radius: 16px;
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    border: 2px solid var(--ailc-border-light);
    transition: all 0.3s ease;
  }

  #ailc-widget:not(.minimized) #ailc-input input:focus {
    border-color: var(--ailc-border-focus);
    box-shadow: 0 0 0 3px rgba(63, 164, 255, 0.15);
    transform: translateY(-1px);
  }

  #ailc-widget:not(.minimized) #ailc-input button {
    padding: 14px 24px;
    font-size: 1.05rem;
    min-width: 80px;
    min-height: 48px; /* Better touch target */
    touch-action: manipulation;
    border-radius: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
  }

  #ailc-widget:not(.minimized) #ailc-input button:active {
    transform: scale(0.95);
  }

  /* Enhanced intro form for mobile */
  #ailc-widget:not(.minimized) #ailc-intro {
    padding: 24px 16px;
    margin: 12px;
    gap: 18px;
    flex: 1;
    justify-content: center;
    background: linear-gradient(135deg, var(--ailc-bg-light) 0%, #f0f4ff 100%);
  }

  #ailc-widget:not(.minimized) #ailc-intro input,
  #ailc-widget:not(.minimized) #ailc-intro select {
    padding: 16px 18px;
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 48px;
    margin-bottom: 12px;
    border-radius: 14px;
    border: 2px solid var(--ailc-border-light);
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    transition: all 0.3s ease;
  }

  #ailc-widget:not(.minimized) #ailc-intro select {
    background-position: right 16px center;
    background-size: 18px;
    padding-right: 48px;
  }

  #ailc-widget:not(.minimized) #ailc-intro button {
    padding: 16px 32px;
    font-size: 1.1rem;
    min-height: 48px;
    align-self: stretch;
    margin-top: 8px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--ailc-color) 0%, var(--ailc-color-dark) 100%);
    border: none;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
  }

  /* Enhanced header for mobile */
  #ailc-widget:not(.minimized) #ailc-header {
    padding: 18px 20px;
    padding-top: calc(18px + env(safe-area-inset-top));
    font-size: 1.2rem;
  }

  /* Improve disclaimer visibility */
  #ailc-widget:not(.minimized) #ailc-disclaimer {
    padding: 16px 18px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    font-size: 0.9rem;
    line-height: 1.4;
    background: rgba(248, 250, 252, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
}

/* Small mobile devices - optimized styles */
@media (max-width: 320px) {
  #ailc-widget.minimized {
    width: 56px !important;
    height: 56px !important;
    bottom: 16px;
    right: 16px;
  }
  
  #ailc-widget.minimized #ailc-header {
    width: 56px;
    height: 56px;
  }
  
  #ailc-widget.minimized #ailc-header::before {
    font-size: 24px;
  }

  #ailc-widget:not(.minimized) #ailc-body {
    height: calc(100vh - 55px);
  }

  #ailc-widget:not(.minimized) #ailc-header {
    padding: 14px 16px;
    font-size: 1rem;
  }

  #ailc-widget:not(.minimized) .ailc-bubble {
    font-size: 0.95rem;
    padding: 9px 12px;
    max-width: 90%;
  }

  #ailc-widget:not(.minimized) .ailc-avatar {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }

  #ailc-widget:not(.minimized) #ailc-messages {
    padding: 12px 10px 6px 10px;
  }

  #ailc-widget:not(.minimized) #ailc-disclaimer {
    padding: 10px 12px;
    font-size: 0.8rem;
  }

  #ailc-widget:not(.minimized) #ailc-input input {
    font-size: 16px;
    padding: 12px 14px;
    min-height: 44px;
  }

  #ailc-widget:not(.minimized) #ailc-input button {
    padding: 12px 18px;
    font-size: 1rem;
    min-width: 70px;
    min-height: 44px;
  }

  #ailc-widget:not(.minimized) #ailc-intro {
    padding: 16px 12px;
    margin: 8px;
    flex: 1;
    justify-content: center;
  }

  #ailc-widget:not(.minimized) #ailc-intro input,
  #ailc-widget:not(.minimized) #ailc-intro select {
    padding: 12px 14px;
    font-size: 16px;
    min-height: 44px;
    margin-bottom: 10px;
  }

  #ailc-widget:not(.minimized) #ailc-intro select {
    background-position: right 12px center;
    padding-right: 40px;
  }

  #ailc-widget:not(.minimized) #ailc-intro button {
    padding: 12px 20px;
    font-size: 1rem;
    min-height: 44px;
  }
}

/* iPhone SE and similar small devices */
@media (max-width: 375px) and (max-height: 667px) {
  #ailc-widget {
    width: 100vw;
    bottom: 0;
    right: 0;
    border-radius: 0;
    max-height: 100vh;
  }

  #ailc-body {
    height: calc(100vh - 60px);
    border-radius: 0;
  }

  #ailc-header {
    padding: 16px 18px;
    font-size: 1rem;
  }

  .ailc-bubble {
    font-size: 0.95rem;
    padding: 10px 12px;
    max-width: 88%;
  }

  #ailc-input input {
    font-size: 1rem;
    padding: 12px 16px;
    min-height: 46px;
  }

  #ailc-input button {
    padding: 12px 20px;
    min-height: 46px;
  }

  #ailc-intro input,
  #ailc-intro select {
    padding: 12px 16px;
    min-height: 46px;
  }

  #ailc-intro button {
    padding: 12px 24px;
    min-height: 46px;
  }
}

/* Large screens and desktops */
@media (min-width: 1200px) {
  #ailc-widget {
    width: 380px;
    bottom: 40px;
    right: 40px;
  }

  #ailc-body {
    height: 450px;
  }

  #ailc-header {
    padding: 20px 24px;
    font-size: 1.2rem;
  }

  .ailc-bubble {
    font-size: 1.05rem;
    padding: 12px 18px;
  }

  #ailc-input input {
    font-size: 1.1rem;
    padding: 12px 18px;
  }

  #ailc-input button {
    padding: 12px 24px;
    font-size: 1.05rem;
  }
}

/* Enhanced Landscape orientation for mobile */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 768px) {
  #ailc-widget.minimized {
    width: 56px !important;
    height: 56px !important;
    bottom: 16px;
    right: 16px;
  }
  
  #ailc-widget.minimized #ailc-header {
    width: 56px;
    height: 56px;
  }
  
  #ailc-widget.minimized #ailc-header::before {
    font-size: 24px;
  }
  
  #ailc-widget:not(.minimized) {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
  }

  #ailc-widget:not(.minimized) #ailc-body {
    height: calc(100vh - 60px) !important;
  }

  #ailc-widget:not(.minimized) #ailc-header {
    padding: 12px 20px;
    font-size: 1.1rem;
  }

  #ailc-widget:not(.minimized) .ailc-bubble {
    font-size: 0.95rem;
    padding: 8px 14px;
    max-width: 75%;
  }

  #ailc-widget:not(.minimized) .ailc-avatar {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }

  #ailc-widget:not(.minimized) #ailc-messages {
    padding: 12px 16px 6px 16px;
  }

  #ailc-widget:not(.minimized) #ailc-input {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  #ailc-widget:not(.minimized) #ailc-input input {
    font-size: 0.95rem;
    padding: 12px 16px;
    min-height: 44px;
  }

  #ailc-widget:not(.minimized) #ailc-input button {
    padding: 12px 20px;
    font-size: 0.95rem;
    min-height: 44px;
  }
}

/* Device-specific optimizations */
/* iPhone SE and similar small devices */
@media (max-width: 375px) and (max-height: 667px) {
  #ailc-widget.minimized {
    width: 58px !important;
    height: 58px !important;
    bottom: 18px;
    right: 18px;
  }
  
  #ailc-widget.minimized #ailc-header::before {
    font-size: 26px;
  }

  #ailc-widget:not(.minimized) #ailc-header {
    padding: 16px 18px;
    padding-top: calc(16px + env(safe-area-inset-top));
    font-size: 1.1rem;
  }

  #ailc-widget:not(.minimized) .ailc-bubble {
    font-size: 0.95rem;
    padding: 10px 14px;
    max-width: 88%;
  }

  #ailc-widget:not(.minimized) #ailc-input input {
    font-size: 16px;
    padding: 14px 16px;
    min-height: 46px;
  }

  #ailc-widget:not(.minimized) #ailc-input button {
    padding: 14px 20px;
    min-height: 46px;
  }

  #ailc-widget:not(.minimized) #ailc-intro input,
  #ailc-widget:not(.minimized) #ailc-intro select {
    padding: 14px 16px;
    min-height: 46px;
  }

  #ailc-widget:not(.minimized) #ailc-intro button {
    padding: 14px 24px;
    min-height: 46px;
  }
}

/* Larger mobile devices (iPhone Plus, Android phablets) */
@media (min-width: 414px) and (max-width: 768px) {
  #ailc-widget.minimized {
    width: 68px !important;
    height: 68px !important;
    bottom: 28px;
    right: 28px;
  }
  
  #ailc-widget.minimized #ailc-header {
    width: 68px;
    height: 68px;
  }
  
  #ailc-widget.minimized #ailc-header::before {
    font-size: 34px;
  }

  #ailc-widget:not(.minimized) #ailc-header {
    padding: 20px 24px;
    padding-top: calc(20px + env(safe-area-inset-top));
    font-size: 1.25rem;
  }

  #ailc-widget:not(.minimized) .ailc-bubble {
    font-size: 1.05rem;
    padding: 12px 16px;
  }

  #ailc-widget:not(.minimized) #ailc-messages {
    padding: 20px 18px 10px 18px;
  }

  #ailc-widget:not(.minimized) #ailc-input {
    padding: 20px 18px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  #ailc-widget:not(.minimized) #ailc-input input {
    padding: 16px 20px;
    min-height: 50px;
  }

  #ailc-widget:not(.minimized) #ailc-input button {
    padding: 16px 28px;
    min-height: 50px;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #ailc-widget {
    box-shadow: 0 8px 32px 0 rgba(60,60,100,0.16), 0 1.5px 8px 0 rgba(0,0,0,0.08);
  }

  .ailc-bubble {
    box-shadow: 0 3px 12px 0 rgba(80,120,200,0.08);
  }

  .ailc-avatar {
    box-shadow: 0 2px 8px 0 rgba(40,80,160,0.08);
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #ailc-widget {
    animation: none;
  }

  .ailc-chat-message {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .ailc-bubble {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* Global minimize rule */
#ailc-widget.minimized #ailc-body { 
  display: none !important; 
}

/* Mobile-only button visibility rules for minimized state */
@media (max-width: 768px) {
  #ailc-widget.minimized #ailc-toggle,
  #ailc-widget.minimized #ailc-end {
    display: none !important;
    visibility: hidden !important;
  }
}

/* Desktop: Show buttons when minimized for easy access */
@media (min-width: 769px) {
  #ailc-widget.minimized #ailc-toggle,
  #ailc-widget.minimized #ailc-end {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Adjust header layout for desktop minimized state */
  #ailc-widget.minimized #ailc-header {
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
  }
  
  /* Ensure buttons are properly styled in minimized desktop state */
  #ailc-widget.minimized #ailc-toggle::before {
    content: "–";
    font-size: 1rem;
  }
  
  #ailc-widget.minimized #ailc-end {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 50%;
    /* inherit default size */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* Desktop toggle button styling */

/* Enhanced Mobile circular icon with improved design */
@media (max-width: 768px) {
  #ailc-widget.minimized {
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    bottom: 24px;
    right: 24px;
    box-shadow: 
      0 8px 32px rgba(21, 102, 206, 0.4), 
      0 4px 16px rgba(21, 102, 206, 0.2),
      0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    animation: ailc-pulse-enhanced 3s ease-in-out infinite;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
  }
  
  /* Add a subtle gradient overlay */
  #ailc-widget.minimized::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%, rgba(255,255,255,0.05) 100%);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
  }
  
  #ailc-widget.minimized:hover {
    transform: scale(1.15) rotate(8deg);
    box-shadow: 
      0 16px 40px rgba(21, 102, 206, 0.5), 
      0 8px 24px rgba(21, 102, 206, 0.3),
      0 4px 12px rgba(0, 0, 0, 0.15) !important;
    animation: ailc-bounce-enhanced 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-color: rgba(255, 255, 255, 0.4);
  }
  
  #ailc-widget.minimized:active {
    transform: scale(0.85) rotate(-3deg);
    animation: none;
    box-shadow: 
      0 4px 16px rgba(21, 102, 206, 0.6),
      0 2px 8px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.1s ease;
  }
  
  #ailc-widget.minimized #ailc-header {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--ailc-color) 0%, var(--ailc-color-dark) 70%, #0a3a7a 100%);
    position: relative;
    overflow: hidden;
    z-index: 2;
  }
  
  #ailc-widget.minimized #ailc-header::before {
    font-size: 32px;
    margin: 0;
    z-index: 3;
    position: relative;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  }
  
  /* Enhanced animated background gradient */
  #ailc-widget.minimized #ailc-header::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
      transparent, 
      rgba(255,255,255,0.3), 
      transparent,
      rgba(255,255,255,0.1),
      transparent
    );
    animation: ailc-rotate 6s linear infinite;
    z-index: 1;
  }
  
  #ailc-widget.minimized #ailc-title {
    display: none;
  }
  
  /* Enhanced Full-screen mobile mode when expanded */
  #ailc-widget:not(.minimized) {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    z-index: 999999 !important;
    animation: ailc-mobile-expand 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    box-shadow: none !important;
  }
  
  #ailc-widget:not(.minimized) #ailc-body {
    height: calc(100vh - 70px) !important;
    height: calc(100vh - 70px - env(safe-area-inset-top)) !important;
    max-height: none !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    background: var(--ailc-bg-light);
  }
  
  #ailc-widget:not(.minimized) #ailc-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px 8px 16px;
    overscroll-behavior: contain;
  }
  
  #ailc-widget:not(.minimized) #ailc-header {
    border-radius: 0 !important;
    padding: 20px 24px;
    padding-top: calc(20px + env(safe-area-inset-top));
    font-size: 1.3rem;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  #ailc-widget:not(.minimized) #ailc-input {
    padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    background: rgba(248, 250, 252, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--ailc-border-light);
  }
  
  #ailc-widget:not(.minimized) #ailc-toggle {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
  }
}

/* Enhanced Animations */
@keyframes ailc-mobile-expand {
  from {
    transform: scale(0.1);
    border-radius: 50%;
    opacity: 0.8;
  }
  30% {
    transform: scale(0.6);
    border-radius: 35%;
    opacity: 0.9;
  }
  70% {
    transform: scale(0.9);
    border-radius: 15%;
    opacity: 0.95;
  }
  to {
    transform: scale(1);
    border-radius: 0;
    opacity: 1;
  }
}

@keyframes ailc-pulse-enhanced {
  0%, 100% {
    box-shadow: 
      0 8px 32px rgba(21, 102, 206, 0.4), 
      0 4px 16px rgba(21, 102, 206, 0.2),
      0 2px 8px rgba(0, 0, 0, 0.1), 
      0 0 0 0 rgba(21, 102, 206, 0.6);
  }
  50% {
    box-shadow: 
      0 8px 32px rgba(21, 102, 206, 0.4), 
      0 4px 16px rgba(21, 102, 206, 0.2),
      0 2px 8px rgba(0, 0, 0, 0.1), 
      0 0 0 18px rgba(21, 102, 206, 0);
  }
}

@keyframes ailc-bounce-enhanced {
  0% { transform: scale(1.15) rotate(8deg); }
  20% { transform: scale(1.3) rotate(-5deg); }
  40% { transform: scale(1.2) rotate(3deg); }
  60% { transform: scale(1.18) rotate(-1deg); }
  80% { transform: scale(1.16) rotate(1deg); }
  100% { transform: scale(1.15) rotate(8deg); }
}

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

@keyframes ailc-bounce {
  0% { transform: scale(1.1) rotate(5deg); }
  30% { transform: scale(1.25) rotate(-3deg); }
  60% { transform: scale(1.15) rotate(2deg); }
  100% { transform: scale(1.1) rotate(5deg); }
}

@keyframes ailc-pulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(21, 102, 206, 0.3), 0 0 0 0 rgba(21, 102, 206, 0.4);
  }
  50% {
    box-shadow: 0 4px 20px rgba(21, 102, 206, 0.3), 0 0 0 10px rgba(21, 102, 206, 0);
  }
}

/* Enhanced Standard minimize controls */
#ailc-toggle {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  border-radius: 50%;
  font-weight: bold;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#ailc-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Desktop toggle button styling */
@media (min-width: 769px) {
  #ailc-toggle::before {
    content: "–";
    font-weight: bold;
    font-size: 1.2rem;
  }
}

/* Mobile-specific toggle button handling - High specificity */
@media (max-width: 768px) {
  /* Show and style toggle button only when expanded on mobile */
  #ailc-widget:not(.minimized) #ailc-toggle {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Set minimize icon for toggle button on mobile when expanded */
  #ailc-widget:not(.minimized) #ailc-toggle::before {
    content: "–" !important;
    font-size: 1.8rem !important;
    font-weight: 300 !important;
  }
  
  /* Ensure end button is also visible when expanded */
  #ailc-widget:not(.minimized) #ailc-end {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* Color styles now consistent with general rule */
  }
}

#ailc-end {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  border-radius: 50%;
  font-weight: bold;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#ailc-end::before {
  content: "";
}

#ailc-end:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#ailc-end.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Enhanced mobile UX improvements */
@media (max-width: 768px) {
  /* Prevent text selection on mobile for better touch experience */
  #ailc-widget.minimized {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Better scrolling performance on mobile */
  #ailc-widget:not(.minimized) #ailc-messages {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-behavior: smooth;
  }
  
  /* Improve touch targets throughout the widget */
  #ailc-widget:not(.minimized) button,
  #ailc-widget:not(.minimized) .ailc-avatar,
  #ailc-widget:not(.minimized) .ailc-bubble {
    touch-action: manipulation;
  }
  
  /* Enhance loading states on mobile */
  #ailc-widget:not(.minimized) #ailc-input button:disabled {
    pointer-events: none;
    opacity: 0.7;
  }
  /* End button styles now consistent with general rule */
  
  /* Improve typing indicator visibility on mobile */
  #ailc-widget:not(.minimized) #ailc-typing {
    margin: 0 16px 16px 16px;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(58, 123, 213, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: ailc-typing-pulse-mobile 2s ease-in-out infinite;
  }
  
  /* Safe area handling for notched devices */
  #ailc-widget:not(.minimized) {
    padding-top: env(safe-area-inset-top);
  }
  
  #ailc-widget:not(.minimized) #ailc-body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* Improve bubble interaction on mobile */
  #ailc-widget:not(.minimized) .ailc-bubble:active {
    transform: scale(0.98);
    opacity: 0.8;
  }
  
  /* Enhanced focus states for better accessibility */
  #ailc-widget:not(.minimized) input:focus,
  #ailc-widget:not(.minimized) select:focus,
  #ailc-widget:not(.minimized) button:focus {
    outline: 2px solid var(--ailc-border-focus);
    outline-offset: 2px;
  }
}

@keyframes ailc-typing-pulse-mobile {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}
/* Remove duplicate toggle styles - handled above */

/* Dark theme kaldırıldı - artık sadece aydınlık tema kullanılıyor */

.copied { opacity:0.6 !important; }

#ailc-intro select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

#ailc-intro select:hover {
  border-color: var(--ailc-color);
}

#ailc-disclaimer {
  padding: 8px 14px;
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
  border-top: 1px solid var(--ailc-border-light);
  background: var(--ailc-bg-light);
  line-height: 1.4;
  flex-shrink: 0;
}

#ailc-disclaimer a {
  color: var(--ailc-color);
  text-decoration: none;
  font-weight: 500;
}

#ailc-disclaimer a:hover {
  text-decoration: underline;
}

/* ----------------------------------------------------------------------------
   Fix: Ensure <select> text in the widget is fully visible even when other
   themes/plugins apply aggressive/global styles (overflow, text-overflow,
   font-size, etc.). Maximum specificity + !important + fallback properties.
   ---------------------------------------------------------------------------- */
div#ailc-widget select,
div#ailc-widget div#ailc-intro select,
div#ailc-widget:not(.minimized) div#ailc-intro select,
div#ailc-widget div#ailc-input select,
#ailc-widget select[class],
#ailc-widget #ailc-intro select[class] {
  /* Force dimensions and layout */
  width: 100% !important;
  min-width: 120px !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 44px !important;
  box-sizing: border-box !important;
  
  /* Typography that prevents truncation */
  padding: 12px 40px 12px 16px !important;
  font-size: 1rem !important;
  font-family: 'Inter', Arial, sans-serif !important;
  line-height: 1.4 !important;
  font-weight: normal !important;
  color: #333 !important;
  
  /* Background and borders */
  background: #fff !important;
  background-color: #fff !important;
  border: 2px solid var(--ailc-border-light) !important;
  border-radius: 12px !important;
  
  /* Reset appearance completely */
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  
  /* Anti-truncation properties */
  text-overflow: clip !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-indent: 0 !important;
  
  /* Display and positioning */
  display: block !important;
  position: relative !important;
  z-index: 1 !important;
  
  /* Transitions and effects */
  transition: all 0.3s ease !important;
  outline: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
  
  /* Custom dropdown arrow via background-image */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 16px !important;
  
  /* Cursor */
  cursor: pointer !important;
}

/* Force option styling */
div#ailc-widget select option,
#ailc-widget #ailc-intro select option {
  white-space: normal !important;
  padding: 8px 12px !important;
  color: #333 !important;
  background: #fff !important;
}

/* Focus states */
div#ailc-widget select:focus,
div#ailc-widget #ailc-intro select:focus {
  border-color: var(--ailc-border-focus) !important;
  box-shadow: 0 0 0 3px rgba(63, 164, 255, 0.1) !important;
  transform: translateY(-1px) !important;
}

/* Mobile-specific overrides */
@media (max-width: 768px) {
  div#ailc-widget:not(.minimized) div#ailc-intro select,
  div#ailc-widget select {
    font-size: 16px !important; /* Prevent iOS zoom */
    min-height: 48px !important;
    padding: 14px 40px 14px 18px !important;
  }
}

/* Remove the decorative arrow pseudo-element as we're using background-image */
#ailc-widget #ailc-intro::after {
  display: none !important;
}

