/* ═══════════════════════════════════════════════════
   APPEXi — Enterprise Intelligence Assistant Styles
   Release 18.1 — Foundation
   ═══════════════════════════════════════════════════ */

/* ── Panel Container ─────────────────────────────── */

.appexi-panel {
  width: 400px;
  max-width: 92vw;
  max-height: 75vh;
  background: rgba(10, 14, 28, 0.94);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(99, 102, 241, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: appexi-panel-enter 0.25s ease-out;
}

.appexi-panel.hidden {
  display: none !important;
}

/* ── Header ───────────────────────────────────────── */

.appexi-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 8px;
}

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

.appexi-header-icon {
  font-size: 20px;
  line-height: 1;
}

.appexi-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.appexi-header-subtitle {
  font-size: 10px;
  color: rgba(129, 140, 248, 0.5);
  font-weight: 500;
  line-height: 1.2;
}

.appexi-header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Tone Selector ────────────────────────────────── */

.appexi-tone-select {
  padding: 4px 24px 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6' fill='none'%3E%3Cpath d='M1 1l3 3 3-3' stroke='rgba(255,255,255,0.3)' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: all 0.15s;
}

.appexi-tone-select:hover {
  border-color: rgba(99, 102, 241, 0.3);
  color: rgba(255, 255, 255, 0.7);
}

.appexi-tone-select:focus {
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

.appexi-tone-select option {
  background: #0a0e1c;
  color: #fff;
}

/* ── Header Buttons ───────────────────────────────── */

.appexi-header-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.appexi-header-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* ── Messages ─────────────────────────────────────── */

.appexi-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: 360px;
}

.appexi-messages::-webkit-scrollbar {
  width: 4px;
}

.appexi-messages::-webkit-scrollbar-track {
  background: transparent;
}

.appexi-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

/* ── Message Wrappers ─────────────────────────────── */

.appexi-message-wrapper {
  animation: appexi-fade-in 0.2s ease-out;
}

.appexi-user-message-wrapper {
  display: flex;
  justify-content: flex-end;
}

.appexi-assistant-message-wrapper {
  display: flex;
  flex-direction: column;
}

/* ── Messages ─────────────────────────────────────── */

.appexi-message {
  max-width: 88%;
}

.appexi-user-message {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 12px 12px 4px 12px;
  padding: 10px 14px;
}

.appexi-assistant-message {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.08);
  border-radius: 12px 12px 12px 4px;
  padding: 12px 16px;
}

.appexi-message-content {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.6;
}

.appexi-message-content p {
  margin: 0 0 8px;
}

.appexi-message-content p:last-child {
  margin-bottom: 0;
}

.appexi-message-content strong {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

.appexi-message-content h4 {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 6px;
}

.appexi-message-content ul {
  margin: 4px 0;
  padding-left: 16px;
  list-style: none;
}

.appexi-message-content li {
  margin-bottom: 3px;
  position: relative;
}

.appexi-message-content li::before {
  content: "•";
  position: absolute;
  left: -12px;
  color: rgba(99, 102, 241, 0.4);
}

/* ── Evidence Badges ──────────────────────────────── */

.appexi-evidence-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.appexi-evidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
}

.appexi-evidence-live_company_data {
  background: rgba(16, 185, 129, 0.1);
  color: rgba(16, 185, 129, 0.8);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.appexi-evidence-enterprise_knowledge {
  background: rgba(59, 130, 246, 0.1);
  color: rgba(96, 165, 250, 0.8);
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.appexi-evidence-external_intelligence {
  background: rgba(168, 85, 247, 0.1);
  color: rgba(192, 132, 252, 0.8);
  border: 1px solid rgba(168, 85, 247, 0.15);
}

.appexi-evidence-user_input {
  background: rgba(234, 179, 8, 0.1);
  color: rgba(250, 204, 21, 0.8);
  border: 1px solid rgba(234, 179, 8, 0.15);
}

.appexi-evidence-inference {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Confidence Score ─────────────────────────────── */

.appexi-confidence {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.appexi-confidence-icon {
  font-size: 11px;
  flex-shrink: 0;
}

.appexi-confidence-label {
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.appexi-confidence-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  max-width: 80px;
}

.appexi-confidence-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.appexi-confidence-score {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}

/* ── Explainability Panel ─────────────────────────── */

.appexi-explain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 0;
  flex-shrink: 0;
}

.appexi-explain-toggle {
  background: none;
  border: none;
  color: rgba(129, 140, 248, 0.4);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}

.appexi-explain-toggle:hover {
  color: rgba(129, 140, 248, 0.7);
}

.appexi-tone-indicator {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.2);
  font-weight: 500;
}

.appexi-explain-panel {
  margin: 0 16px 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  animation: appexi-fade-in 0.2s ease-out;
}

.appexi-explain-panel.hidden {
  display: none !important;
}

.appexi-explain-section {
  margin-bottom: 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.5;
}

.appexi-explain-section:last-child {
  margin-bottom: 0;
}

.appexi-explain-section strong {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.appexi-explain-section ul {
  margin: 0;
  padding-left: 14px;
  list-style: none;
}

.appexi-explain-section li {
  margin-bottom: 3px;
  position: relative;
  color: rgba(255, 255, 255, 0.35);
}

.appexi-explain-section li::before {
  content: "–";
  position: absolute;
  left: -12px;
  color: rgba(255, 255, 255, 0.15);
}

.appexi-explain-section p {
  margin: 0;
  color: rgba(255, 255, 255, 0.35);
}

.appexi-evidence-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.appexi-explain-missing {
  border-left: 2px solid rgba(234, 179, 8, 0.3);
  padding-left: 10px;
}

.appexi-explain-limitations {
  border-left: 2px solid rgba(239, 68, 68, 0.3);
  padding-left: 10px;
}

/* ── Suggestions ──────────────────────────────────── */

.appexi-suggestions {
  padding: 6px 16px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

.appexi-suggestions-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.appexi-suggestion-btn {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.12);
  background: rgba(99, 102, 241, 0.04);
  color: rgba(129, 140, 248, 0.5);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appexi-suggestion-btn:hover {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.08);
  color: #818cf8;
}

.appexi-suggestion-btn:active {
  transform: scale(0.97);
}

/* ── Input Area ───────────────────────────────────── */

.appexi-input-area {
  padding: 8px 16px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.appexi-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.appexi-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.15s;
  resize: none;
  line-height: 1.5;
}

.appexi-input:focus {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.appexi-input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.appexi-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  font-size: 13px;
}

.appexi-send-btn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

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

/* ── Floating Action Button ───────────────────────── */

.appexi-fab {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.appexi-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.appexi-fab:active {
  transform: scale(0.96);
}

.appexi-fab-icon {
  font-size: 24px;
  line-height: 1;
}

.appexi-fab.hidden {
  display: none !important;
}

/* ── Conversation History Panel ───────────────────── */

.appexi-history-panel {
  max-height: 180px;
  overflow-y: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  animation: appexi-fade-in 0.15s ease-out;
}

.appexi-history-panel.hidden {
  display: none !important;
}

.appexi-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.appexi-history-clear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  transition: color 0.15s;
}

.appexi-history-clear:hover {
  color: rgba(239, 68, 68, 0.6);
}

.appexi-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.appexi-history-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.6);
}

.appexi-history-item i {
  font-size: 10px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.appexi-history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appexi-history-empty {
  padding: 12px 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.2);
  text-align: center;
}

/* ── Typing Indicator ─────────────────────────────── */

.appexi-typing {
  display: flex;
  gap: 10px;
  align-items: center;
  animation: appexi-fade-in 0.15s ease-out;
  padding: 4px 0;
}

.appexi-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  animation: appexi-dot 1.2s ease-in-out infinite;
}

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

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

/* ── Animations ───────────────────────────────────── */

@keyframes appexi-panel-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes appexi-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── AI Futuristic Theme Overrides ────────────────── */

body.theme-ai-futuristic .appexi-panel {
  background: rgba(5, 8, 22, 0.94) !important;
  border-color: rgba(79, 124, 255, 0.15) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(79, 124, 255, 0.08) !important;
}

body.theme-ai-futuristic .appexi-fab {
  background: linear-gradient(135deg, #4F7CFF, #7C5CFF) !important;
  box-shadow: 0 4px 20px rgba(79, 124, 255, 0.35) !important;
}

body.theme-ai-futuristic .appexi-fab:hover {
  box-shadow: 0 8px 30px rgba(79, 124, 255, 0.5) !important;
}

body.theme-ai-futuristic .appexi-input:focus {
  border-color: rgba(79, 124, 255, 0.4) !important;
  box-shadow: 0 0 15px rgba(79, 124, 255, 0.08) !important;
}

body.theme-ai-futuristic .appexi-evidence-enterprise_knowledge {
  background: rgba(79, 124, 255, 0.1) !important;
  color: rgba(110, 168, 254, 0.9) !important;
  border-color: rgba(79, 124, 255, 0.2) !important;
}

/* ── Reduced Motion ───────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .appexi-panel { animation: none !important; }
  .appexi-typing span { animation: none !important; opacity: 0.5 !important; }
}

/* ── Mobile Responsive ────────────────────────────── */

@media (max-width: 480px) {
  .appexi-panel {
    width: calc(100vw - 24px);
    max-height: 80vh;
    bottom: 80px;
    right: 12px;
    border-radius: 16px;
  }

  .appexi-header-title {
    font-size: 14px;
  }

  .appexi-tone-select {
    font-size: 10px;
    padding: 3px 20px 3px 6px;
  }

  .appexi-fab {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .appexi-fab-icon {
    font-size: 20px;
  }
}
