/* ============================================================================
   FLOATING CHATBOT WIDGET - MOBILE RESPONSIVE
   ============================================================================ */

:root {
  --chatbot-primary: #667eea;
  --chatbot-primary-dark: #5568d3;
  --chatbot-secondary: #764ba2;
  --chatbot-success: #28a745;
  --chatbot-danger: #dc3545;
  --chatbot-light: #f8f9fa;
  --chatbot-dark: #212529;
  --chatbot-shadow: 0 10px 40px rgba(102, 126, 234, 0.2);
}

/* ============================================================================
   FLOATING BUTTON
   ============================================================================ */
.chatbot-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chatbot-toggle:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 15px 50px rgba(102, 126, 234, 0.4);
}

.chatbot-toggle:active {
  transform: scale(0.95);
}

.chatbot-toggle.active {
  background: linear-gradient(135deg, var(--chatbot-danger) 0%, #c82333 100%);
}

.chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--chatbot-danger);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============================================================================
   CHAT PANEL
   ============================================================================ */
.chatbot-panel {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 400px;
  max-width: calc(100vw - 60px);
  height: 600px;
  max-height: calc(100vh - 150px);
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow: hidden;
}

.chatbot-panel.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ============================================================================
   HEADER
   ============================================================================ */
.chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 20px 20px 0 0;
}

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chatbot-header-content i {
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.chatbot-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.chatbot-status {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
}

.chatbot-minimize {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chatbot-minimize:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* ============================================================================
   MESSAGES AREA
   ============================================================================ */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  border-radius: 3px;
}

.chatbot-message {
  display: flex;
  margin-bottom: 12px;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-message {
  justify-content: flex-end;
}

.bot-message {
  justify-content: flex-start;
}

.message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 14px;
}

.user-message .message-content {
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  color: white;
  border-bottom-right-radius: 4px;
}

.bot-message .message-content {
  background: white;
  color: var(--chatbot-dark);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-content p {
  margin: 0 0 8px 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* ============================================================================
   TICKET CREATED MESSAGE (Special styling)
   ============================================================================ */
.ticket-created-message {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 16px rgba(40, 167, 69, 0.3);
}

.ticket-number {
  font-size: 18px;
  font-weight: 700;
  margin: 8px 0;
  color: white;
}

.ticket-link {
  display: inline-block;
  background: white;
  color: #28a745;
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  margin-top: 8px;
  transition: all 0.2s;
}

.ticket-link:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateX(4px);
}

/* ============================================================================
   CONFIRMATION BUTTONS (In-Chat)
   ============================================================================ */
.solution-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.solution-buttons button {
  flex: 1;
  min-width: 120px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.btn-success-chat {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
}

.btn-success-chat:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-warning-chat {
  background: #ffc107;
  color: #212529;
}

.btn-warning-chat:hover {
  background: #e0a800;
  transform: translateY(-2px);
}

/* ============================================================================
   TYPING INDICATOR
   ============================================================================ */
.chatbot-typing {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  max-width: fit-content;
}

.chatbot-typing.active {
  display: flex;
}

.chatbot-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  animation: typing 1.4s infinite;
}

.chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ============================================================================
   INPUT AREA
   ============================================================================ */
.chatbot-input-area {
  padding: 16px;
  background: white;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0 0 20px 20px;
}

.chatbot-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chatbot-form input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.chatbot-form input:focus {
  border-color: var(--chatbot-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-form button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.chatbot-form button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chatbot-form button:active {
  transform: scale(0.95);
}

/* ============================================================================
   RTL SUPPORT
   ============================================================================ */
html[dir="rtl"] .chatbot-widget,
html[lang="ar"] .chatbot-widget {
  right: auto;
  left: 30px;
}

html[dir="rtl"] .chatbot-panel,
html[lang="ar"] .chatbot-panel {
  right: auto;
  left: 30px;
}

html[dir="rtl"] .user-message,
html[lang="ar"] .user-message {
  justify-content: flex-start;
}

html[dir="rtl"] .bot-message,
html[lang="ar"] .bot-message {
  justify-content: flex-end;
}

html[dir="rtl"] .user-message .message-content,
html[lang="ar"] .user-message .message-content {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

html[dir="rtl"] .bot-message .message-content,
html[lang="ar"] .bot-message .message-content {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

/* ============================================================================
   MOBILE RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
  .chatbot-widget {
    bottom: 20px;
    right: 20px;
  }
  
  .chatbot-toggle {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
  
  .chatbot-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 60px);
    max-height: calc(100vh - 60px);
    border-radius: 20px 20px 0 0;
  }
  
  .chatbot-panel.active {
    bottom: 0;
  }
  
  html[dir="rtl"] .chatbot-widget,
  html[lang="ar"] .chatbot-widget {
    left: 20px;
    right: auto;
  }
  
  html[dir="rtl"] .chatbot-panel,
  html[lang="ar"] .chatbot-panel {
    left: 0;
    right: 0;
  }
}

@media (max-width: 480px) {
  .chatbot-header h3 {
    font-size: 16px;
  }
  
  .message-content {
    font-size: 13px;
    max-width: 85%;
  }
  
  .solution-buttons button {
    min-width: 100px;
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* Clickable links in chatbot */
.chatbot-link {
    color: #0066cc !important;
    text-decoration: underline;
    font-weight: 500;
    transition: all 0.2s ease;
    word-break: break-all;
}

.chatbot-link:hover {
    color: #004499 !important;
    background-color: rgba(0, 102, 204, 0.1);
    text-decoration: none;
}

.chatbot-link:visited {
    color: #551A8B !important;
}

/* Better spacing for paragraphs with links */
.message-content p {
    margin: 6px 0;
    line-height: 1.5;
}