/* src/components/ChatInterface/InputBar.css */

/* ── Input Bar Container ─────────────────────────────────────────────────── */
.input-bar-container {
  padding: 12px 16px 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 100;
  background: white !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  border-radius: 28px !important; /* Slightly smaller but definite radius */
  margin-bottom: 8px !important;
  width: calc(100% - 24px) !important;
  max-width: 950px !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04) !important;
  margin-top: auto !important;
  position: relative;
}

.input-bar-main {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
  max-width: 100%; /* Fully responsive width */
  padding: 0 10px; /* Slight side padding */
  position: relative;
  margin: 0 auto;
}

/* ── Input Field Wrap ────────────────────────────────────────────────────── */
.input-field-wrap {
  flex: 1;
  background: white;
  border: 1.5px solid rgba(0, 0, 0, 0.05);
  border-radius: 28px;
  padding: 4px 20px; /* Reduced vertical padding since textarea has its own */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  min-height: 56px;
  height: auto; /* Allow growth */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.input-field-wrap:focus-within {
  border-color: var(--primary-accent);
  box-shadow: 0 8px 30px rgba(255, 96, 160, 0.15);
  transform: translateY(-2px);
}

/* ── Textarea ────────────────────────────────────────────────────────────── */
.input-field-wrap textarea {
  flex: 1;
  padding: 12px 0;
  border: none;
  font-size: 1rem;
  font-family: 'Outfit', 'Inter', sans-serif;
  resize: none;
  min-height: 24px;
  max-height: 120px; /* Limit to approx 4-5 lines */
  background: transparent;
  color: #1e293b;
  line-height: 1.5;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE and Edge */
}

.input-field-wrap textarea::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}

.input-field-wrap textarea:focus {
  outline: none;
}

.input-field-wrap textarea::placeholder {
  color: #94a3b8;
}

/* ── Actions Row ─────────────────────────────────────────────────────────── */
.input-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-bottom: 8px;
}

/* ── Base Icon Button ────────────────────────────────────────────────────── */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; /* Match button width */
  height: 44px; /* Match button height */
}

/* ── Plus Button ─────────────────────────────────────────────────────────── */
.plus-btn {
  background: white !important;
  color: #1e293b !important;
  border: 1.5px solid #cbd5e1 !important;
  position: relative;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.plus-btn.active {
  background: #475569 !important;
  color: white !important;
  border-color: #475569 !important;
  transform: rotate(0deg) !important; /* Image doesn't rotate, it swaps icons */
}

.plus-btn.listening {
  background: rgba(255, 96, 160, 0.1) !important;
  color: var(--primary-accent) !important;
  border-color: var(--primary-accent) !important;
  animation: listeningPulse 1.5s infinite;
}

@keyframes listeningPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 96, 160, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(255, 96, 160, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 96, 160, 0); }
}

.plus-btn-label {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.plus-btn-label::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
}

.plus-btn:hover .plus-btn-label {
  opacity: 1;
  bottom: calc(100% + 10px);
}

.plus-btn.active .plus-btn-label {
  display: none;
}

/* ── Send Button ─────────────────────────────────────────────────────────── */
.send-button {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.send-button:not(:disabled) {
  background: var(--primary-accent);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 96, 160, 0.35);
}

.send-button:hover:not(:disabled) {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 96, 160, 0.45);
}

.send-button:active:not(:disabled) {
  transform: scale(0.95);
}

/* ── Attachment Menu ─────────────────────────────────────────────────────── */
.attachment-menu {
  position: absolute;
  bottom: calc(100% + 15px);
  left: -50px; /* Offset to center relative to a small button */
  right: -50px;
  margin: 0 auto;
  width: fit-content;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  z-index: 150;
  animation: menu-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.menu-item .icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #f1f5f9;
  color: #475569;
  border: none;
  transition: all 0.2s ease;
}

.menu-item .icon-btn.mic-btn {
  background: #475569;
  color: white;
}

.menu-item .icon-btn.conv-btn {
  background: white;
  border: 2px solid #e2e8f0;
  color: #475569;
}

.menu-item .icon-btn:hover {
  transform: scale(1.05);
}

@keyframes menu-pop {
  0% { opacity: 0; transform: translateY(15px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ── Conversation Mode Bar ───────────────────────────────────────────────── */
.conv-mode-bar {
  background: white;
  margin: 0 16px 20px;
  margin-top: auto;
  padding: 8px 10px 8px 18px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  border: 1.5px solid rgba(0, 0, 0, 0.04);
  animation: barAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-height: 64px;
  width: calc(100% - 32px);
  box-sizing: border-box;
  position: relative;
  z-index: 100;
}

@keyframes barAppear {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.conversation-status {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.conv-state {
  display: flex;
  align-items: center;
  gap: 12px;
}

.conv-icon-ring {
  width: 40px;
  height: 40px;
  background: #f8fafc;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  position: relative;
  transition: all 0.3s ease;
}

.listening-state .conv-icon-ring {
  color: var(--primary-accent);
  background: rgba(255, 96, 160, 0.08);
}

.thinking-state .conv-icon-ring {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.thinking-state .conv-icon-ring svg {
  animation: spin 3s linear infinite;
}

.speaking-state .conv-icon-ring {
  color: var(--primary-accent);
  background: rgba(255, 96, 160, 0.08);
}

/* Pulsing effect for recording */
.listening-state .conv-icon-ring::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--primary-accent);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.conv-label {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  letter-spacing: -0.01em;
}

.conv-dots {
  display: flex;
  gap: 4px;
  padding-top: 4px;
}

.conv-dots span {
  width: 5px;
  height: 5px;
  background: #cbd5e1;
  border-radius: 50%;
  animation: dots-jump 1.4s infinite ease-in-out;
}

.listening-state .conv-dots span {
  background: var(--primary-accent);
}

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

@keyframes dots-jump {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.conv-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}

.conv-wave span {
  width: 3px;
  background: var(--primary-accent);
  border-radius: 10px;
  animation: wave-bounce 1s infinite ease-in-out;
}

@keyframes wave-bounce {
  0%, 100% { height: 4px; opacity: 0.4; }
  50% { height: 18px; opacity: 1; }
}

.conv-wave span:nth-child(1) { animation-delay: 0.1s; }
.conv-wave span:nth-child(2) { animation-delay: 0.2s; }
.conv-wave span:nth-child(3) { animation-delay: 0.3s; }
.conv-wave span:nth-child(4) { animation-delay: 0.4s; }
.conv-wave span:nth-child(5) { animation-delay: 0.5s; }

.stop-conversation-btn {
  background: #475569;
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: 100px;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(71, 85, 105, 0.2);
}

.stop-conversation-btn:hover {
  background: #334155;
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(71, 85, 105, 0.3);
}

.stop-conversation-btn:active {
  transform: scale(0.96);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .input-bar-container {
    padding: 8px 12px !important;
    width: calc(100% - 16px) !important;
    border-radius: 20px !important;
    margin-bottom: 6px !important;
  }

  .conv-mode-bar {
    width: calc(100% - 24px);
    margin: 0 12px 12px;
    padding: 8px 8px 8px 14px;
    min-height: 58px;
  }
  
  .conv-label { font-size: 0.9rem; }
  .stop-conversation-btn { padding: 8px 16px; font-size: 0.85rem; }

  .input-bar-main {
    max-width: 100%;
    gap: 8px;
  }
  
  .input-field-wrap {
    min-height: 52px;
    padding: 4px 14px;
    border-radius: 24px;
  }
  
  .icon-btn, .send-button {
    width: 42px;
    height: 42px;
  }

  .input-field-wrap textarea {
    font-size: 16px;
    min-height: 34px;
    line-height: 1.4;
    padding: 12px 0 10px;
    box-sizing: border-box;
  }
}
