/* ============================================
   CHATBOT CSS - Add this to your portfolio CSS
   ============================================ */

/* ===== FLOATING ACTION BUTTON ===== */
#ai-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #00f0ff 0%, #0099ff 100%);
  border: none;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0, 240, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

#ai-fab:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 32px rgba(0, 240, 255, 0.5);
}

#ai-fab:active {
  transform: translateY(-2px) scale(1.02);
}

#ai-fab.hide {
  transform: scale(0);
  opacity: 0;
}

/* ===== CHATBOT WINDOW ===== */
#ai-chatbot {
  position: fixed;
  bottom: 110px;
  right: 30px;
  width: 380px;
  height: 540px;
  background: rgba(15, 15, 15, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 20px;
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 
              0 0 40px rgba(0, 240, 255, 0.15);
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#ai-chatbot.show {
  display: flex;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== HEADER ===== */
#ai-header {
  padding: 20px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.1) 0%, rgba(0, 153, 255, 0.05) 100%);
  border-bottom: 1px solid rgba(0, 240, 255, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#ai-header-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #00f0ff;
  font-weight: 600;
  font-size: 16px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #00ff88;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7);
  }
  50% {
    opacity: 0.7;
    box-shadow: 0 0 0 6px rgba(0, 255, 136, 0);
  }
}

#ai-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  color: #888;
  font-size: 20px;
  font-weight: 300;
}

#ai-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #00f0ff;
  transform: rotate(90deg);
}

/* ===== MESSAGES CONTAINER ===== */
#ai-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#ai-messages::-webkit-scrollbar {
  width: 6px;
}

#ai-messages::-webkit-scrollbar-track {
  background: transparent;
}

#ai-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.2);
  border-radius: 3px;
}

#ai-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.3);
}

/* Firefox scrollbar */
#ai-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.2) transparent;
}

/* ===== WELCOME MESSAGE ===== */
.welcome-msg {
  text-align: center;
  color: #666;
  font-size: 14px;
  padding: 40px 20px;
  animation: fadeIn 0.6s ease;
}

.welcome-msg .icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.welcome-msg h3 {
  color: #00f0ff;
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
}

.welcome-msg > p {
  margin-bottom: 24px;
  color: #888;
}

/* ===== ANIMATED ROTATING QUESTIONS ===== */
.animated-question-box {
  margin-top: 20px;
  padding: 16px 20px;
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 12px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.question-label {
  color: #00f0ff;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rotating-text-container {
  position: relative;
  height: 24px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rotating-text {
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  position: absolute;
  opacity: 0;
  transform: translateY(10px);
  animation: rotateText 16s infinite;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
}

.rotating-text:nth-child(1) {
  animation-delay: 0s;
}

.rotating-text:nth-child(2) {
  animation-delay: 4s;
}

.rotating-text:nth-child(3) {
  animation-delay: 8s;
}

.rotating-text:nth-child(4) {
  animation-delay: 12s;
}

@keyframes rotateText {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  6.25% {
    opacity: 1;
    transform: translateY(0);
  }
  25% {
    opacity: 1;
    transform: translateY(0);
  }
  31.25% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MESSAGE BUBBLES ===== */
.message {
  display: flex;
  gap: 10px;
  animation: messageSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  animation-fill-mode: forwards;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-msg {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.user-msg .message-avatar {
  background: linear-gradient(135deg, #00f0ff 0%, #0099ff 100%);
}

.ai-msg .message-avatar {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.2);
}

.message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}

.user-msg .message-content {
  background: linear-gradient(135deg, #00f0ff 0%, #0099ff 100%);
  color: #000;
  border-radius: 16px 16px 4px 16px;
  font-weight: 500;
}

.ai-msg .message-content {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e0e0e0;
  border-radius: 16px 16px 16px 4px;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #00f0ff;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ===== INPUT BOX ===== */
#ai-input-box {
  display: flex;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.3);
  gap: 10px;
}

#ai-input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: none;
  font-size: 14px;
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

#ai-input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

#ai-input::placeholder {
  color: #666;
}

#ai-send {
  padding: 12px 20px;
  background: linear-gradient(135deg, #00f0ff 0%, #0099ff 100%);
  color: #000;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 240, 255, 0.2);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

#ai-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 240, 255, 0.3);
}

#ai-send:active {
  transform: translateY(0);
}

#ai-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ===== IMPROVED RESPONSIVE DESIGN ===== */

/* Small devices (landscape phones, less than 768px) */
@media (max-width: 767.98px) {
  #ai-chatbot {
    width: calc(100vw - 40px);
    max-width: 400px;
    height: 560px;
    right: 20px;
    bottom: 100px;
  }

  #ai-fab {
    width: 56px;
    height: 56px;
    font-size: 24px;
    right: 20px;
    bottom: 20px;
  }

  .welcome-msg {
    padding: 30px 15px;
  }

  .welcome-msg .icon {
    font-size: 48px;
  }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
  #ai-chatbot {
    width: calc(100vw - 30px);
    height: 500px;
    right: 15px;
    bottom: 90px;
    border-radius: 16px;
  }

  #ai-fab {
    width: 52px;
    height: 52px;
    font-size: 22px;
    right: 15px;
    bottom: 15px;
  }

  #ai-header {
    padding: 15px;
  }

  #ai-header-text {
    font-size: 14px;
  }

  #ai-messages {
    padding: 15px;
  }

  .message-content {
    max-width: 85%;
    padding: 10px 14px;
    font-size: 13px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  #ai-input-box {
    padding: 12px;
  }

  #ai-input {
    padding: 10px 14px;
    font-size: 13px;
  }

  #ai-send {
    padding: 10px 16px;
    font-size: 13px;
  }

  .animated-question-box {
    padding: 12px 15px;
  }

  .rotating-text {
    font-size: 12px;
  }

  .question-label {
    font-size: 11px;
  }
}

/* Small devices (landscape mode) */
@media (max-height: 600px) and (orientation: landscape) {
  #ai-chatbot {
    height: 85vh;
    bottom: 80px;
  }

  #ai-messages {
    padding: 12px;
  }

  .welcome-msg {
    padding: 20px 15px;
  }

  .animated-question-box {
    min-height: 50px;
    margin-top: 15px;
    padding: 10px 15px;
  }

  .rotating-text-container {
    height: 22px;
  }
}

/* Tablet devices */
@media (min-width: 768px) and (max-width: 1024px) {
  #ai-chatbot {
    width: 360px;
    height: 520px;
  }
}

/* Large screens */
@media (min-width: 1400px) {
  #ai-chatbot {
    width: 420px;
    height: 600px;
    bottom: 130px;
    right: 40px;
  }

  #ai-fab {
    width: 72px;
    height: 72px;
    font-size: 32px;
    bottom: 40px;
    right: 40px;
  }

  .message-content {
    font-size: 15px;
    padding: 14px 18px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  #ai-send:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(0, 240, 255, 0.2);
  }

  #ai-send:active {
    transform: scale(0.95);
  }

  #ai-fab:hover {
    transform: none;
    box-shadow: 0 8px 24px rgba(0, 240, 255, 0.3);
  }

  #ai-fab:active {
    transform: scale(0.95);
  }

  #ai-close:hover {
    background: none;
    color: #888;
  }

  #ai-close:active {
    background: rgba(255, 255, 255, 0.08);
    color: #00f0ff;
    transform: rotate(90deg);
  }
}

/* Dark mode support (if system prefers dark) */
@media (prefers-color-scheme: dark) {
  #ai-chatbot {
    background: rgba(10, 10, 10, 0.98);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  #ai-chatbot {
    border: 2px solid #00f0ff;
  }

  .message-content {
    border: 1px solid currentColor;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  #ai-chatbot,
  #ai-fab,
  .message,
  .typing-dot,
  .status-dot,
  .rotating-text,
  #ai-close,
  #ai-send {
    animation: none !important;
    transition: none !important;
  }

  .rotating-text {
    opacity: 1;
    position: static;
    animation: none;
    display: block;
    margin: 5px 0;
  }

  .rotating-text-container {
    height: auto;
    flex-direction: column;
  }
}

/* Print styles */
@media print {
  #ai-fab,
  #ai-chatbot {
    display: none !important;
  }
}

/* Safe area support for notched devices */
@supports (padding: max(0px)) {
  @media (max-width: 575.98px) {
    #ai-chatbot {
      bottom: max(90px, env(safe-area-inset-bottom));
      right: max(15px, env(safe-area-inset-right));
      left: max(15px, env(safe-area-inset-left));
      width: calc(100% - max(30px, env(safe-area-inset-left) + env(safe-area-inset-right)));
    }

    #ai-fab {
      bottom: max(15px, env(safe-area-inset-bottom));
      right: max(15px, env(safe-area-inset-right));
    }
  }
}