/**
 * CallAgentAI Widget Styles
 * Version: 1.2.1
 */

/* Widget Button */
.ai-call-widget-button {
  position: fixed;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.ai-call-widget-button:hover {
  transform: scale(1.08);
}

/* Tooltip */
.ai-call-widget-tooltip {
  position: absolute;
  right: 80px;
  background: #1a1a2e;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateX(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.ai-call-widget-tooltip::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid #1a1a2e;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.ai-call-widget-button:hover .ai-call-widget-tooltip {
  opacity: 1;
  transform: translateX(0);
}

.ai-call-widget-bottom-left .ai-call-widget-tooltip,
.ai-call-widget-top-left .ai-call-widget-tooltip {
  right: auto;
  left: 80px;
  transform: translateX(-10px);
}

.ai-call-widget-bottom-left .ai-call-widget-tooltip::after,
.ai-call-widget-top-left .ai-call-widget-tooltip::after {
  right: auto;
  left: -8px;
  border-left: none;
  border-right: 8px solid #1a1a2e;
}

.ai-call-widget-bottom-left:hover .ai-call-widget-tooltip,
.ai-call-widget-top-left:hover .ai-call-widget-tooltip {
  transform: translateX(0);
}

.ai-call-widget-bottom-right {
  bottom: 20px;
  right: 20px;
}

.ai-call-widget-bottom-left {
  bottom: 20px;
  left: 20px;
}

.ai-call-widget-top-right {
  top: 20px;
  right: 20px;
}

.ai-call-widget-top-left {
  top: 20px;
  left: 20px;
}

/* Widget Modal */
.ai-call-widget-modal {
  position: fixed;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 100px);
  background: #1a1a2e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1000000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  min-height: 0; /* Allow flex items to shrink */
}

.ai-call-widget-modal.ai-call-widget-bottom-right {
  bottom: 90px;
  right: 20px;
}

.ai-call-widget-modal.ai-call-widget-bottom-left {
  bottom: 90px;
  left: 20px;
}

.ai-call-widget-modal.ai-call-widget-top-right {
  top: 90px;
  right: 20px;
}

.ai-call-widget-modal.ai-call-widget-top-left {
  top: 90px;
  left: 20px;
}

/* Header */
.ai-call-widget-header {
  background: linear-gradient(135deg, #2c2c3e 0%, #1a1a2e 100%);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-call-widget-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

.ai-call-widget-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.ai-call-widget-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Body */
.ai-call-widget-body {
  flex: 1 1 auto;
  min-height: 0; /* Critical: allows body to shrink and enable scrolling in children */
  overflow: hidden;
  position: relative;
  display: flex; /* Make body a flex container */
  flex-direction: column; /* Stack children vertically */
}

/* Mode Select Screen */
.ai-call-widget-mode-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 30px 20px 20px;
  text-align: center;
}

.ai-call-widget-logo {
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.ai-call-widget-mode-select h2 {
  color: #ffffff;
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 10px 0;
}

.ai-call-widget-subtitle {
  color: #ffffff;
  font-size: 17px;
  font-weight: 500;
  margin: 0 0 35px 0;
  letter-spacing: 0.3px;
}

.ai-call-widget-buttons {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  justify-content: center;
}

/* Single button layout - centered and larger */
.ai-call-widget-buttons.single-button {
  justify-content: center;
}

.ai-call-widget-buttons.single-button .ai-call-widget-btn {
  width: 180px;
  height: 140px;
  font-size: 20px;
}

.ai-call-widget-buttons.single-button .ai-call-widget-btn svg {
  width: 48px;
  height: 48px;
}

.ai-call-widget-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 140px;
  height: 120px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.ai-call-widget-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.ai-call-widget-btn svg {
  width: 40px;
  height: 40px;
}

.ai-call-widget-btn-chat {
  background: #2196F3;
  color: white;
}

.ai-call-widget-btn-call {
  background: #E57373;
  color: white;
}

.ai-call-widget-footer {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 400;
}

/* Chat Interface */
.ai-call-widget-chat {
  display: none;
  flex-direction: column;
  flex: 1 1 auto; /* Take available space */
  min-height: 0; /* Allow flex shrinking */
  width: 100%; /* Full width */
  position: absolute; /* Position within parent */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.ai-call-widget-messages {
  flex: 1 1 auto;
  min-height: 0; /* Critical: allows flex item to shrink below content size */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  background: #16161f;
  scroll-behavior: smooth; /* Smooth scrolling */
}

.ai-call-widget-message-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
  animation: slideIn 0.3s ease;
}

.ai-call-widget-message-wrapper-user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.ai-call-widget-message-wrapper-assistant {
  flex-direction: row;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-call-widget-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
}

.ai-call-widget-message {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 70%;
  word-wrap: break-word;
  line-height: 1.4;
}

.ai-call-widget-message-user {
  background: #2196F3;
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-call-widget-message-assistant {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.ai-call-widget-typing {
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.ai-call-widget-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: typing 1.4s infinite;
}

.ai-call-widget-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-call-widget-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Chat Footer Container */
.ai-call-widget-chat-footer {
  flex-shrink: 0; /* Prevent footer from shrinking */
  background: #1a1a2e;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
}

.ai-call-widget-input {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 10px;
  height: 46px;
}

.ai-call-widget-input input,
.ai-call-widget-input button {
  height: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border: none !important;
  outline: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.ai-call-widget-input input {
  flex: 1;
  padding: 0 16px !important;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a2e;
  font-size: 15px;
  line-height: 46px;
}

.ai-call-widget-input input::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

.ai-call-widget-input input:focus {
  outline: none !important;
  background: #ffffff;
  border: none !important;
  box-shadow: none !important;
}

.ai-call-widget-input button {
  padding: 0 24px !important;
  background: #2196F3;
  color: white;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  line-height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-call-widget-input button:hover {
  background: #1976D2;
}

/* Call Interface */
.ai-call-widget-call {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 40px 20px 20px;
  background: #16161f;
}

.ai-call-widget-call-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  justify-content: center;
}

.ai-call-widget-avatar-large {
  width: 120px;
  height: 120px;
  margin-bottom: 20px;
  border-radius: 50%;
  overflow: hidden;
}

#ai-call-status-text {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.ai-call-timer {
  color: rgba(255, 255, 255, 0.7);
  font-size: 16px;
  margin-bottom: 30px;
  font-variant-numeric: tabular-nums;
}

.ai-call-widget-indicators {
  display: flex;
  gap: 50px;
  margin-top: 20px;
}

.ai-call-widget-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0.4;
  transition: opacity 0.3s ease;
}

.ai-call-widget-indicator.active {
  opacity: 1;
}

.ai-call-indicator-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
}

.ai-call-widget-indicator.active .ai-call-indicator-circle {
  animation: pulseRing 1.5s ease-out infinite;
}

@keyframes pulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(229, 115, 115, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(229, 115, 115, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(229, 115, 115, 0);
  }
}

.ai-call-widget-indicator span {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}

.ai-call-widget-actions {
  width: 100%;
  max-width: 320px;
}

.ai-call-widget-btn-end {
  width: 100%;
  padding: 16px 24px;
  background: #E57373;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ai-call-widget-btn-end:hover {
  background: #EF5350;
  transform: translateY(-2px);
}

/* Back Button */
.ai-call-widget-back {
  padding: 10px 16px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s ease;
  margin-top: 16px;
  align-self: center;
}

.ai-call-widget-back:hover {
  color: rgba(255, 255, 255, 1);
}

/* Chat Back Button - More Prominent */
.ai-call-widget-back-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0;
}

.ai-call-widget-back-chat:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: translateY(-1px);
}

.ai-call-widget-back-chat svg {
  flex-shrink: 0;
}

/* Scrollbar Styles */
.ai-call-widget-messages::-webkit-scrollbar {
  width: 10px;
}

.ai-call-widget-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  margin: 4px 0;
}

.ai-call-widget-messages::-webkit-scrollbar-thumb {
  background: rgba(100, 181, 246, 0.6);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.ai-call-widget-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 181, 246, 0.8);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.ai-call-widget-messages::-webkit-scrollbar-thumb:active {
  background: rgba(33, 150, 243, 0.9);
}

/* For Firefox */
.ai-call-widget-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 181, 246, 0.6) rgba(255, 255, 255, 0.08);
}

/* Session Limit Notification Overlay */
.ai-call-widget-session-notification {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(22, 22, 31, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.3s ease;
}

.ai-call-widget-notification-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 20px;
  max-width: 300px;
}

.ai-call-widget-notification-icon {
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
}

.ai-call-widget-notification-title {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px 0;
}

.ai-call-widget-notification-message {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 24px 0;
}

.ai-call-widget-notification-btn {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.ai-call-widget-notification-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.ai-call-widget-notification-btn:active {
  transform: translateY(0);
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .ai-call-widget-modal {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
  }

  .ai-call-widget-buttons {
    flex-direction: row;
    gap: 16px;
  }

  .ai-call-widget-btn {
    width: 120px;
    height: 100px;
  }

  .ai-call-widget-buttons.single-button .ai-call-widget-btn {
    width: 160px;
    height: 120px;
  }
}
