/* ===================================
   CESC CHATBOT — DESIGN TOKENS (P1 aligned)
   Primary:    #0056B3
   Accent:     #00A3FF
   Dark navy:  #0D2B5E  (header)
   Background: #F0F4FA
   Surface:    #FFFFFF
   Text:       #1A1A2E
   =================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body { overflow-x: hidden; }

/* ===================================
   CHAT BUBBLE — 56dp touch target, 16dp margin
   #0056B3 on white = 5.9:1  ✓ WCAG AA
   =================================== */
.chat-bubble {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #0056B3;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 86, 179, 0.35);
  overflow: hidden;
  z-index: 9999;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}

.chat-bubble.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.chat-bubble:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 86, 179, 0.45);
  animation: pulseHighlight 2s infinite;
}

@keyframes pulseHighlight {
  0%   { box-shadow: 0 0 0 0   rgba(0, 86, 179, 0.6); }
  70%  { box-shadow: 0 0 0 12px rgba(0, 86, 179, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(0, 86, 179, 0);    }
}

.chat-bubble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ===================================
   CHATBOT CONTAINER
   =================================== */
.chatbot {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 400px;
  height: 600px;
  background: #FFFFFF;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0);
  transform-origin: bottom right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9998;
}

.chatbot.active { transform: scale(1); }

/* ===================================
   CHAT HEADER
   P1: flat solid #0D2B5E, height 56dp
   single CESC logo + bot name + controls
   =================================== */
.chat-header {
  height: 56px;                  /* spec: 56dp */
  background: #0D2B5E;           /* spec: flat solid, no gradient */
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* Single CESC logo */
.header-logo {
  height: 32px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-logo img {
  height: 32px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  display: block;
}

/* Bot name + status */
.header-bot-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.header-bot-name {
  font-size: 15px;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 1.2;
  white-space: nowrap;
}

.header-bot-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.2;
  white-space: nowrap;
}

/* Header action buttons — white on dark, 44×44dp touch target */
.header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.header-btn {
  width: 44px;                   /* ≥ 44dp touch target */
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 400;
  color: #FFFFFF;                /* white on #0D2B5E — high contrast */
  transition: background-color 0.2s ease;
  flex-shrink: 0;
  user-select: none;
}

.header-btn:hover  { background-color: rgba(255, 255, 255, 0.12); }
.header-btn:active { background-color: rgba(255, 255, 255, 0.22); }

/* ===================================
   CHAT BODY
   P1 token: background #F0F4FA
   8dp gap between messages
   =================================== */
.chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;                      /* 8dp same-sender gap */
  background: #F0F4FA;           /* spec token */
}

.chat-body::-webkit-scrollbar       { width: 6px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: #C8D6E8; border-radius: 10px; }
.chat-body::-webkit-scrollbar-thumb:hover { background: #A8BDD8; }

/* ===================================
   MESSAGES
   =================================== */
.message {
  display: flex;
  width: 100%;
  animation: messageSlideIn 0.3s ease;
}

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

.message.bot  { justify-content: flex-start; }
.message.user { justify-content: flex-end;   }

/* Base bubble */
.message-content {
  display: inline-block;
  max-width: 75%;
  min-width: 60px;
  padding: 12px 16px;            /* spec: 12px 16px */
  border-radius: 12px;           /* spec: 12px */
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}

/* ── Bot bubble: white card ──
   P1: text #1A1A2E on #FFFFFF = 19:1  ✓ WCAG AAA */
.message.bot .message-content {
  background: #FFFFFF;
  color: #1A1A2E;                /* spec: #1A1A2E — 19:1 contrast */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-bottom-left-radius: 4px;
}

/* ── User bubble ──
   P1 token: #0056B3 */
.message.user .message-content {
  background: #0056B3;           /* spec token: primary */
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 86, 179, 0.2);
}

/* ===================================
   TYPING INDICATOR
   P1: accent #00A3FF dots, 600ms ease-in-out
   aria-label="Aastha is typing" on wrapper (JS)
   =================================== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px !important;
  min-width: 68px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00A3FF;           /* spec: accent colour */
  animation: dotPulse 600ms ease-in-out infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0ms;   }
.typing-dot:nth-child(2) { animation-delay: 150ms;  }
.typing-dot:nth-child(3) { animation-delay: 300ms;  }

@keyframes dotPulse {
  0%, 100% { transform: scale(1);   opacity: 0.5; }
  50%       { transform: scale(1.5); opacity: 1;   }
}

/* Visible "Aastha is typing" label next to the dots */
.typing-label {
  font-size: 12px;
  color: #7A8FA6;
  margin-left: 4px;
  font-style: italic;
  white-space: nowrap;
}

/* ===================================
   CHAT FOOTER — column layout
   Attachment slot above, input row below
   =================================== */
.chat-footer {
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border-top: 1px solid #DCE6F5;
  flex-shrink: 0;
}

/* ── Attachment Preview Slot ── */
.attachment-preview-slot {
  padding: 10px 14px 4px 14px;
  animation: slideDown 0.2s ease;
}

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

.attachment-preview-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #EDF4FF;
  border: 1px solid #B3CFEE;
  border-radius: 8px;
  padding: 8px 10px;
  max-width: 100%;
  overflow: hidden;
}

.attach-preview-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(0, 86, 179, 0.15);
}

.attach-preview-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: #D6E8FF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #0056B3;                /* P1 token */
  font-size: 18px;
}

.attach-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attach-preview-name {
  font-size: 13px;
  font-weight: 600;
  color: #1A1A2E;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-preview-ext {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #0056B3;           /* P1 token */
  color: #FFFFFF;
  border-radius: 4px;
  padding: 1px 6px;
  width: fit-content;
}

.attach-preview-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  color: #5A6A7E;
  font-size: 14px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
  min-width: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-preview-dismiss:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1A1A2E;
}

/* ── Input Row — always full-width ── */
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px 12px;
  min-height: 68px;
}

/* Attach icon — P1: 44×44dp touch target, #0056B3 colour
   #0056B3 on #FFFFFF = 5.9:1  ✓ WCAG AA non-text */
.attach-icon {
  width: 44px;                   /* 44dp touch target */
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  color: #0056B3;                /* P1 token — meets 3:1 non-text contrast */
  font-size: 20px;
  transition: background-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.attach-icon:hover  { background-color: #EDF4FF; }
.attach-icon:active { transform: scale(0.95); }

/* Input wrapper */
.input-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
}

.chat-footer input[type="text"] {
  width: 100%;
  padding: 10px 16px;
  border-radius: 20px;
  border: 1.5px solid #C8D6E8;
  outline: none;
  font-size: 14px;
  background: #F0F4FA;           /* P1 token: background */
  color: #1A1A2E;
  transition: all 0.2s ease;
}

.chat-footer input[type="text"]:focus {
  border-color: #0056B3;         /* P1 token */
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.chat-footer input[type="text"]::placeholder { color: #7A8FA6; }

/* ===================================
   BUTTONS — Send & Audio
   P1: 44×44dp touch target, #0056B3
   #0056B3 on white = 5.9:1  ✓ WCAG AA
   =================================== */
.send-btn,
.audio-btn {
  width: 44px;                   /* 44dp touch target */
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: none;
  background-color: #0056B3;     /* P1 token */
  color: #FFFFFF;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 86, 179, 0.3);
  flex-shrink: 0;
}

.send-btn i,
.audio-btn i { font-size: 17px; }

.send-btn:hover,
.audio-btn:hover {
  background-color: #003D8A;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 86, 179, 0.4);
}

.send-btn:active,
.audio-btn:active { transform: scale(0.95); }

.send-btn.active,
.audio-btn.active { display: flex !important; }

.audio-btn.hidden,
.send-btn.hidden  { display: none !important; }

/* ===================================
   RECORDING UI
   =================================== */
.recording-ui {
  flex: 1;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #FFF3E0;
  border-radius: 20px;
  border: 1px solid #FFB74D;
  cursor: pointer;
}

.recording-ui.active { display: flex; }

.recording-animation {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recording-dot {
  width: 8px;
  height: 8px;
  background: #F44336;
  border-radius: 50%;
  animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
  0%, 100% { opacity: 1;   transform: scale(1);   }
  50%       { opacity: 0.5; transform: scale(1.2); }
}

.recording-timer {
  font-size: 13px;
  font-weight: 600;
  color: #F44336;
  min-width: 35px;
}

.recording-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 30px;
}

.recording-waveform span {
  width: 3px;
  background: #FFB74D;
  border-radius: 2px;
  animation: waveform 1.2s ease-in-out infinite;
}

.recording-waveform span:nth-child(1)  { animation-delay: 0s;   height: 12px; }
.recording-waveform span:nth-child(2)  { animation-delay: 0.1s; height: 18px; }
.recording-waveform span:nth-child(3)  { animation-delay: 0.2s; height: 24px; }
.recording-waveform span:nth-child(4)  { animation-delay: 0.3s; height: 18px; }
.recording-waveform span:nth-child(5)  { animation-delay: 0.4s; height: 12px; }
.recording-waveform span:nth-child(6)  { animation-delay: 0.5s; height: 18px; }
.recording-waveform span:nth-child(7)  { animation-delay: 0.6s; height: 24px; }
.recording-waveform span:nth-child(8)  { animation-delay: 0.7s; height: 18px; }
.recording-waveform span:nth-child(9)  { animation-delay: 0.8s; height: 12px; }
.recording-waveform span:nth-child(10) { animation-delay: 0.9s; height: 18px; }

@keyframes waveform {
  0%, 100% { height: 12px; }
  50%       { height: 28px; }
}

.cancel-recording {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #F44336;
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.cancel-recording:hover  { background: #D32F2F; transform: scale(1.05); }
.cancel-recording:active { transform: scale(0.95); }

/* ===================================
   POST-SEND ATTACHMENT BUBBLE
   WhatsApp-style chip/card
   =================================== */
.attachment-bubble {
  padding: 0 !important;
  overflow: hidden;
  min-width: 180px;
  max-width: 240px !important;
}

.sent-attachment-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
}

.sent-attach-thumb-img {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  display: block;
  border-radius: 12px 12px 0 0;
}

.sent-attach-icon-banner {
  width: 100%;
  padding: 16px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.9);
}

.sent-attach-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.12);
}

.sent-attach-name {
  font-size: 12px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sent-attach-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sent-attach-caption {
  padding: 6px 12px 10px;
  font-size: 13px;
  color: #FFFFFF;
  line-height: 1.4;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
  .chatbot { width: 380px; height: 580px; }
}

/* Mobile — Full Screen */
@media (max-width: 768px) {
  .chatbot {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    max-height: 100vh;
  }

  .chat-header { height: 56px; padding: 0 12px; }
  .header-logo img { height: 28px; max-width: 90px; }
  .header-bot-name { font-size: 14px; }
  .header-bot-status { display: none; }

  .chat-body { padding: 12px; }

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

  .chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  .chat-footer input[type="text"] { font-size: 13px; }
}

/* Small Mobile */
@media (max-width: 480px) {
  .chat-header { padding: 0 10px; }
  .header-logo img { height: 24px; max-width: 75px; }
  .header-btn { width: 40px; height: 40px; font-size: 16px; }

  .message-content {
    font-size: 13px;
    padding: 9px 12px;
  }

  .chat-footer input[type="text"] {
    font-size: 13px;
    padding: 9px 14px;
  }
}

/* Large Desktop */
@media (min-width: 1440px) {
  .chatbot     { width: 420px; height: 640px; }
  .chat-header { height: 60px; padding: 0 20px; }
  .header-logo img { height: 36px; }
  .header-bot-name { font-size: 16px; }
}
