/* BananaTools Unified AI Workspace & Shared Architecture CSS (V3.3)
   Shared responsive design for Homepage and Answer Workspace.
   Compatible with Light and Dark modes, Desktop, Tablet, and Mobile.
*/

:root {
  --bt-primary-green: #177b58;
  --bt-primary-hover: #126346;
  --bt-primary-glow: rgba(23, 123, 88, 0.2);
  --bt-focus-ring: rgba(23, 123, 88, 0.3);
  --bt-amber: #d97706;
  --bt-red: #dc2626;
  --bt-chip-bg: #f1f5f9;
  --bt-chip-border: #cbd5e1;
  --bt-chip-text: #1e293b;
  --bt-chip-thumb-bg: #e2e8f0;
}

/* Light mode defaults */
.banana-home-ai-card,
#bt-answer-v3 {
  --bt-card-bg: #ffffff;
  --bt-card-border: #dbe3ec;
  --bt-card-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --bt-text-main: #0f172a;
  --bt-text-muted: #64748b;
  --bt-text-hint: #475569;
  --bt-input-bg: #f8fafc;
  --bt-input-border: #cbd5e1;
  --bt-input-focus-border: #177b58;
  --bt-menu-bg: #ffffff;
  --bt-menu-border: #cbd5e1;
  --bt-menu-hover: #f1f5f9;
  --bt-chip-bg: #f1f5f9;
  --bt-chip-border: #cbd5e1;
  --bt-chip-text: #1e293b;
  --bt-mic-bg: #ecfdf5;
  --bt-mic-text: #065f46;
  --bt-mic-border: #a7f3d0;
  --bt-secondary-btn-bg: #f8fafc;
  --bt-secondary-btn-text: #334155;
  --bt-secondary-btn-border: #cbd5e1;
  --bt-status-color: #047857;
  --bt-error-color: #b91c1c;
}

/* Dark mode overrides */
html[data-banana-theme="dark"] .banana-home-ai-card,
html[data-banana-theme="dark"] #bt-answer-v3,
#bt-answer-v3.bt-v31-theme-dark {
  --bt-card-bg: #141f2e;
  --bt-card-border: #2e3e54;
  --bt-card-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --bt-text-main: #f1f5f9;
  --bt-text-muted: #94a3b8;
  --bt-text-hint: #cbd5e1;
  --bt-input-bg: #0b131e;
  --bt-input-border: #3b4e68;
  --bt-input-focus-border: #34d399;
  --bt-menu-bg: #1a283b;
  --bt-menu-border: #384b66;
  --bt-menu-hover: #26384f;
  --bt-chip-bg: #1e2d40;
  --bt-chip-border: #3b4f69;
  --bt-chip-text: #f1f5f9;
  --bt-mic-bg: #064e3b;
  --bt-mic-text: #6ee7b7;
  --bt-mic-border: #047857;
  --bt-secondary-btn-bg: #1e293b;
  --bt-secondary-btn-text: #e2e8f0;
  --bt-secondary-btn-border: #334155;
  --bt-status-color: #34d399;
  --bt-error-color: #f87171;
}

/* ==========================================================================
   HOMEPAGE COMPACT "ASK BANANA AI" CARD
   ========================================================================== */
.banana-home-ai-card {
  background: var(--bt-card-bg);
  border: 1px solid var(--bt-card-border);
  border-radius: 18px;
  box-shadow: var(--bt-card-shadow);
  padding: clamp(16px, 2.5vw, 24px);
  margin: 0 0 24px;
  color: var(--bt-text-main);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.banana-home-ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.banana-home-ai-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.banana-home-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(23, 123, 88, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.banana-home-ai-title h2 {
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 750;
  margin: 0;
  color: var(--bt-text-main);
  letter-spacing: -0.02em;
}

.banana-home-ai-link {
  font-size: 13px;
  font-weight: 650;
  color: #10b981;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s, transform 0.15s;
}

.banana-home-ai-link:hover {
  text-decoration: underline;
  transform: translateX(2px);
}

.banana-home-ai-subtitle {
  font-size: 13.5px;
  color: var(--bt-text-muted);
  margin: 0 0 14px;
  line-height: 1.45;
}

.banana-home-ai-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.banana-home-ai-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 78px;
  padding: 12px 14px;
  border: 1.5px solid var(--bt-input-border);
  border-radius: 12px;
  background: var(--bt-input-bg);
  color: var(--bt-text-main);
  font: 500 15px/1.5 system-ui, -apple-system, sans-serif;
  resize: vertical;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.banana-home-ai-input:focus {
  border-color: var(--bt-input-focus-border);
  box-shadow: 0 0 0 3px var(--bt-focus-ring);
}

.banana-home-ai-input::placeholder {
  color: var(--bt-text-muted);
}

.banana-home-ai-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.banana-home-ai-left-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.banana-home-ai-right-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.banana-home-ai-status {
  font-size: 13px;
  min-height: 18px;
  color: var(--bt-status-color);
  margin-top: 2px;
  line-height: 1.4;
  word-break: break-word;
}

.banana-home-ai-status.bt-error {
  color: var(--bt-error-color);
  font-weight: 600;
}

/* ==========================================================================
   ATTACHMENT SYSTEM (+ BUTTON & MENU & CHIPS)
   ========================================================================== */
.bt-attach-container {
  position: relative;
  display: inline-block;
}

.bt-attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--bt-secondary-btn-border);
  background: var(--bt-secondary-btn-bg);
  color: var(--bt-secondary-btn-text);
  font: 600 13.5px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
  white-space: nowrap;
}

.bt-attach-btn:hover {
  filter: brightness(0.96);
  border-color: #94a3b8;
}

.bt-plus-icon {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

/* Popup Menu */
.bt-attach-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  min-width: 260px;
  background: var(--bt-menu-bg);
  border: 1px solid var(--bt-menu-border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: bt-menu-fade-in 0.15s ease-out;
}

.bt-attach-menu[hidden] {
  display: none !important;
}

@keyframes bt-menu-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.bt-attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--bt-text-main);
  text-align: left;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.15s;
}

.bt-attach-item:hover,
.bt-attach-item:focus-visible {
  background: var(--bt-menu-hover);
  outline: none;
}

.bt-attach-icon {
  font-size: 20px;
  flex: 0 0 24px;
  text-align: center;
}

.bt-attach-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bt-attach-text strong {
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.2;
}

.bt-attach-text small {
  font-size: 11.5px;
  color: var(--bt-text-muted);
  line-height: 1.25;
}

/* ==========================================================================
   ATTACHMENT CHIPS TRAY
   ========================================================================== */
.bt-chip-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  margin-bottom: 4px;
}

.bt-chip-tray[hidden] {
  display: none !important;
}

.bt-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bt-chip-bg);
  border: 1px solid var(--bt-chip-border);
  color: var(--bt-chip-text);
  border-radius: 999px;
  padding: 4px 10px 4px 6px;
  font-size: 12.5px;
  font-weight: 550;
  max-width: 260px;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

.bt-chip-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: #cbd5e1;
  flex: 0 0 26px;
}

.bt-chip-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  flex: 0 0 26px;
  text-transform: uppercase;
}

.bt-chip-pdf {
  background: #dc2626;
}

.bt-chip-word {
  background: #2563eb;
}

.bt-chip-txt {
  background: #4b5563;
}

.bt-chip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.bt-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  line-height: 1.2;
}

.bt-chip-size {
  font-size: 10.5px;
  color: var(--bt-text-muted);
  line-height: 1.1;
}

.bt-chip-status {
  font-size: 11px;
  font-weight: 600;
  color: #10b981;
}

.bt-chip-remove {
  border: 0;
  background: transparent;
  color: var(--bt-text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  margin-left: 2px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.bt-chip-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* ==========================================================================
   BUTTONS: MIC, ASK/SEND, ETC.
   ========================================================================== */
.bt-mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--bt-mic-border);
  background: var(--bt-mic-bg);
  color: var(--bt-mic-text);
  font: 600 13.5px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.bt-mic-btn.bt-listening {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25);
  animation: bt-pulse 1.2s ease-in-out infinite alternate;
}

.bt-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 18px;
  border-radius: 10px;
  border: 1px solid var(--bt-primary-green);
  background: var(--bt-primary-green);
  color: #ffffff;
  font: 700 14px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, filter 0.15s;
  white-space: nowrap;
}

.bt-send-btn:hover {
  background: var(--bt-primary-hover);
  filter: brightness(0.98);
}

.bt-send-btn:active {
  transform: scale(0.98);
}

.bt-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   WORKSPACE V3 ENHANCEMENTS (TOP QUESTION + STREAMING RESULT DIRECTLY BELOW)
   ========================================================================== */
#bt-answer-v3 .bt-card {
  position: relative;
}

#bt-answer-v3 .bt-attach-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .banana-home-ai-card {
    padding: 14px;
    border-radius: 14px;
    margin-bottom: 18px;
  }
  .banana-home-ai-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .banana-home-ai-left-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .banana-home-ai-right-actions {
    width: 100%;
    margin-left: 0;
  }
  .bt-attach-btn,
  .bt-mic-btn,
  .bt-send-btn {
    width: 100%;
    min-height: 42px;
  }
  .bt-attach-menu {
    left: 0;
    right: 0;
    width: auto;
    min-width: 0;
  }
}
