﻿/* ============================================================
   Bernave — Context Bar & Modal
   ============================================================ */

/* ── TOP BAR ── */
#ai-context-bar {
  position: sticky;
  top: 0;
  z-index: 150;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  border-bottom: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 2px 16px rgba(67,56,202,.35);
}
.aicb-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  max-width: 100%;
}
.aicb-avatar {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: .15s;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.2);
}
.aicb-avatar:hover { background: rgba(255,255,255,.25); transform: scale(1.08); }
.aicb-brand {
  font-size: 12px; font-weight: 800; color: #fff;
  white-space: nowrap; flex-shrink: 0;
}
.aicb-brand span { color: #a5b4fc; font-weight: 400; font-size: 10px; margin-left: 4px; }
.aicb-sep { color: rgba(255,255,255,.25); font-size: 14px; flex-shrink: 0; }
.aicb-ctx-wrap {
  flex: 1; display: flex; align-items: center; gap: 8px;
  min-width: 0; overflow: hidden;
}
.aicb-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #6b7280; transition: .3s;
}
.aicb-dot.ready { background: #34d399; box-shadow: 0 0 6px #34d399; }
.aicb-dot.pulse {
  background: #fbbf24;
  animation: aicbPulse 1.4s infinite;
}
@keyframes aicbPulse {
  0%,100% { opacity: 1; } 50% { opacity: .4; }
}
.aicb-ctx-text {
  font-size: 11px; color: rgba(255,255,255,.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.aicb-ctx-text strong { color: #fff; }
.aicb-model-badge {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: #c7d2fe;
  font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
  white-space: nowrap; flex-shrink: 0;
  letter-spacing: .04em;
}
.aicb-btn {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.1);
  color: #fff; font-size: 11px; font-weight: 700;
  cursor: pointer; transition: .15s; white-space: nowrap;
  font-family: inherit; flex-shrink: 0;
}
.aicb-btn:hover { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.5); }
.aicb-btn.primary {
  background: #fb6340; border-color: #fb6340;
}
.aicb-btn.primary:hover { background: #e5562f; }

/* ── CONTEXT MODAL ── */
#ai-context-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 600;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
#ai-context-modal.open { display: flex; }
.aicm-box {
  background: #fff;
  border-radius: 22px;
  width: 100%; max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.aicm-head {
  background: linear-gradient(135deg, #1e1b4b, #4338ca);
  padding: 20px 24px;
  display: flex; align-items: center; gap: 14px;
  border-radius: 22px 22px 0 0;
}
.aicm-head-avatar {
  width: 46px; height: 46px;
  background: rgba(255,255,255,.15);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,.25);
}
.aicm-head-title { color: #fff; font-weight: 800; font-size: 16px; margin: 0; }
.aicm-head-sub { color: rgba(255,255,255,.65); font-size: 12px; margin-top: 2px; }
.aicm-close {
  margin-left: auto;
  background: rgba(255,255,255,.15); border: none; border-radius: 10px;
  width: 32px; height: 32px; cursor: pointer; color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.aicm-close:hover { background: rgba(255,255,255,.28); }
.aicm-body { padding: 20px 24px 24px; }

/* Chat bubble */
.aicm-bubble {
  background: #f0f0ff;
  border: 1px solid #ddd6fe;
  border-radius: 6px 16px 16px 16px;
  padding: 12px 16px;
  font-size: 12px; color: #3730a3; line-height: 1.6;
  margin-bottom: 18px;
  display: flex; gap: 10px; align-items: flex-start;
}
.aicm-bubble-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }

/* Fields */
.aicm-label {
  display: block; font-size: 11px; font-weight: 700; color: #344767;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; margin-top: 14px;
}
.aicm-label:first-child { margin-top: 0; }
.aicm-inp {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid #e2e8f0; border-radius: 9px;
  font-size: 13px; color: #344767; font-family: inherit;
  outline: none; box-sizing: border-box; transition: .15s;
}
.aicm-inp:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.08); }
.aicm-ta {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid #e2e8f0; border-radius: 9px;
  font-size: 12px; color: #344767; font-family: inherit;
  resize: vertical; min-height: 90px; box-sizing: border-box; outline: none;
  line-height: 1.6;
}
.aicm-ta:focus { border-color: #6366f1; }
.aicm-sel {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid #e2e8f0; border-radius: 9px;
  font-size: 13px; color: #344767; font-family: inherit;
  background: #fff; box-sizing: border-box; cursor: pointer;
}
.aicm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.aicm-grid .full { grid-column: 1 / -1; }

/* Analyze button */
.aicm-analyze-btn {
  margin-top: 8px; width: 100%;
  padding: 9px 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 9px;
  font-size: 12px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; transition: .15s;
}
.aicm-analyze-btn:hover { opacity: .88; }
.aicm-analyze-btn.loading { opacity: .6; pointer-events: none; }

/* API Key section */
.aicm-api-section {
  margin-top: 18px;
  background: #fafafa;
  border: 1.5px solid #e8e0ff;
  border-radius: 12px;
  padding: 14px 16px;
}
.aicm-api-title {
  font-size: 11px; font-weight: 800; color: #6366f1;
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.aicm-api-row { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.aicm-api-inp {
  flex: 1; padding: 8px 12px;
  border: 1.5px solid #ddd6fe; border-radius: 8px;
  font-size: 12px; color: #344767; font-family: inherit; outline: none;
  background: #fff;
}
.aicm-api-inp:focus { border-color: #6366f1; }
.aicm-api-toggle {
  padding: 7px 10px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  background: #fff; cursor: pointer; color: #8392ab; font-size: 12px;
}
.aicm-api-note {
  font-size: 10px; color: #8392ab; margin-top: 6px; line-height: 1.5;
}
.aicm-api-note a { color: #6366f1; }
.aicm-api-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; margin-top: 6px;
}

/* Status flash */
.aicm-extract-result {
  display: none; margin-top: 10px;
  background: #ecfdf5; border: 1px solid #bbf7d0;
  border-radius: 8px; padding: 10px 14px;
  font-size: 11px; color: #166534;
}

/* Footer */
.aicm-footer {
  display: flex; gap: 10px; margin-top: 20px;
  padding-top: 16px; border-top: 1.5px solid #f0f0f0;
}
.aicm-save-btn {
  flex: 1; padding: 11px;
  background: linear-gradient(135deg, #fb6340, #ffa94d);
  color: #fff; border: none; border-radius: 10px;
  font-weight: 800; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.aicm-save-btn:hover { opacity: .9; }
.aicm-cancel-btn {
  padding: 11px 20px;
  background: #f8fafc; border: 1.5px solid #e2e8f0;
  border-radius: 10px; color: #344767; font-size: 13px;
  cursor: pointer; font-family: inherit;
}

/* AI thinking dots */
.ai-thinking-dots {
  display: inline-flex; gap: 3px; align-items: center;
}
.ai-thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: #fff;
  animation: thinkDot 1.2s infinite;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: .2s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes thinkDot { 0%,80%,100%{opacity:.3;transform:scale(.8)} 40%{opacity:1;transform:scale(1.1)} }

/* Flash fill animation */
@keyframes ctxFill { 0%{background:#e0e7ff} 100%{background:transparent} }
.ctx-filled { animation: ctxFill .8s ease-out; }

