/* ═══════════════════════════════════════════════════════════
   GAP ANALYSIS AGENT — Background Process Feed Styles
   Clean SaaS aesthetic, not terminal/matrix.
   ═══════════════════════════════════════════════════════════ */

/* ── Toggle Button (top-left) — matches .ext-btn dimensions ── */
#gapToggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 710;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 7px 12px;
  background: rgba(14, 60, 100, .92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  cursor: pointer;
  transition: all .25s;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  font-family: 'DM Sans', sans-serif;
  color: #fff;
}
#gapToggle:hover {
  border-color: rgba(25,165,208,.4);
  box-shadow: 0 6px 28px rgba(0,0,0,.4);
  transform: translateY(-1px);
}

.gap-toggle-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.gap-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(25,165,208,.1);
  border: 1px solid rgba(25,165,208,.25);
  border-radius: 16px;
  color: #19a5d0;
  font-size: 12px;
  font-weight: 600;
}

.gap-toggle-badge {
  min-width: 16px;
  height: 16px;
  padding: 0 1px 0 0;
  border-radius: 8px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  text-align: center;
  animation: gapBadgePop .3s cubic-bezier(.4,0,.2,1);
}

#gapToggle.gap-flash {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,.2), 0 4px 20px rgba(0,0,0,.3);
}

@keyframes gapBadgePop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}


/* ── Panel ── */
#gapPanel {
  position: fixed;
  top: 58px;
  left: 12px;
  z-index: 708;
  width: 420px;
  max-height: 0;
  overflow: hidden;
  /* No background on the container — its rounded corners + overflow:hidden
     still clip children, but no white fill paints behind the gradient header
     (which was causing a thin white halo at the top corners). The body below
     paints its own white. */
  border-radius: 14px;
  box-shadow: 0 12px 50px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.06);
  transition: max-height .4s cubic-bezier(.4,0,.2,1), opacity .3s ease;
  opacity: 0;
  display: flex;
  flex-direction: column;
}

#gapPanel.open {
  max-height: calc(100vh - 74px);
  opacity: 1;
}


/* ── Panel Header ── */
.gap-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-radius: 14px 14px 0 0;
}

.gap-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gap-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.gap-header-title {
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.gap-header-sub {
  font-size: 10px;
  color: rgba(255,255,255,.45);
  margin-top: 1px;
}

.gap-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gap-pulse {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  color: #4ade80;
  letter-spacing: .03em;
}

.gap-pulse span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  animation: gapPulse 2s ease-in-out infinite;
}

@keyframes gapPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74,222,128,.4); }
  50% { opacity: .6; box-shadow: 0 0 0 4px rgba(74,222,128,0); }
}

.gap-close-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.6);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.gap-close-btn:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}


/* ── Panel Body (scroll area) ── */
.gap-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 460px;
  scroll-behavior: smooth;
}

.gap-body::-webkit-scrollbar { width: 4px; }
.gap-body::-webkit-scrollbar-track { background: transparent; }
.gap-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.gap-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}

.gap-empty i {
  font-size: 24px;
  opacity: .4;
  animation: gapSpin 4s linear infinite;
}

@keyframes gapSpin {
  to { transform: rotate(360deg); }
}


/* ── Log Entry ── */
.gap-log-entry {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 0 0 16px;
  position: relative;
}

.gap-log-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 28px;
}

.gap-log-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  z-index: 1;
}

/* Colored icon backgrounds per type */
.gap-type-gap .gap-log-icon {
  background: #fffbeb;
  border-color: #fde68a;
}
.gap-type-alert .gap-log-icon {
  background: #fef2f2;
  border-color: #fecaca;
}
.gap-type-complete .gap-log-icon {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.gap-type-scan .gap-log-icon {
  background: #f8fafc;
  border-color: #e2e8f0;
}
.gap-type-order .gap-log-icon {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.gap-log-line {
  width: 1.5px;
  flex: 1;
  min-height: 8px;
  background: #e2e8f0;
  margin-top: 4px;
}

.gap-log-entry:last-child .gap-log-line {
  display: none;
}

.gap-log-body {
  flex: 1;
  min-width: 0;
  padding-top: 3px;
}

.gap-log-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.gap-log-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 1px 7px;
  border-radius: 4px;
}

.gap-label-scan     { background: #f1f5f9; color: #64748b; }
.gap-label-order    { background: #dbeafe; color: #1d4ed8; }
.gap-label-gap      { background: #fef3c7; color: #92400e; }
.gap-label-alert    { background: #fee2e2; color: #991b1b; }
.gap-label-complete { background: #d1fae5; color: #065f46; }

.gap-log-time {
  font-size: 10px;
  color: #94a3b8;
}

.gap-log-text {
  font-size: 12.5px;
  line-height: 1.55;
  color: #334155;
}


/* ── Hero Entry (highlighted) ── */
.gap-log-entry.gap-hero .gap-log-body {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: -3px;
}

.gap-log-entry.gap-hero .gap-log-icon {
  background: #f59e0b;
  border-color: #f59e0b;
}

.gap-log-entry.gap-hero .gap-log-icon i {
  color: #fff !important;
}


/* ── "Investigate in Chat" button ── */
.gap-log-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 14px;
  background: #0ea5e9;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}

.gap-log-btn:hover {
  background: #0284c7;
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(14,165,233,.3);
}

.gap-log-btn i {
  font-size: 10px;
}


/* ═══════════════════════════════════════════════════════════
   EXTENSION PANEL — TAB BAR
   Appears between the header and messages area when a second
   tab is created by the Gap Agent.
   ═══════════════════════════════════════════════════════════ */

.ep-tab-bar {
  display: flex;
  gap: 0;
  padding: 0 12px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  overflow-x: auto;
  align-items: center;
}

.ep-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  position: relative;
}

.ep-tab .ep-tab-text {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ep-tab:hover {
  color: #475569;
  background: rgba(0,0,0,.02);
}

.ep-tab.active {
  color: #0f172a;
  border-bottom-color: #0ea5e9;
}

.ep-tab i {
  font-size: 11px;
  flex-shrink: 0;
}

.ep-tab .ep-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  animation: gapBadgePop .3s ease;
  flex-shrink: 0;
}

/* Gap tab — amber accent when active */
.ep-tab[data-tab="gap"].active {
  border-bottom-color: #f59e0b;
  color: #92400e;
}

.ep-tab[data-tab="gap"] i {
  color: #f59e0b;
}

/* + button */
.ep-tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 4px;
  border-radius: 6px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}

.ep-tab-add:hover {
  border-color: #0ea5e9;
  color: #0ea5e9;
  background: #f0f9ff;
}

/* Gap chat initial summary card */
.gap-chat-summary {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 8px;
}

.gap-chat-summary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.gap-chat-summary-header i {
  color: #f59e0b;
  font-size: 14px;
}

.gap-chat-summary-header strong {
  font-size: 14px;
  color: #78350f;
}

.gap-chat-customer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 8px;
  margin-bottom: 10px;
}

.gap-chat-customer-field {
  font-size: 11px;
}

.gap-chat-customer-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #92400e;
  opacity: .7;
}

.gap-chat-customer-value {
  font-weight: 500;
  color: #78350f;
  margin-top: 1px;
}

.gap-chat-analysis {
  font-size: 12.5px;
  line-height: 1.6;
  color: #451a03;
  white-space: pre-wrap;
}

.gap-chat-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.gap-chat-prompt {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px;
  color: #78350f;
  line-height: 1.4;
  transition: all .2s;
  text-align: left;
}

.gap-chat-prompt:hover {
  border-color: #f59e0b;
  background: #fef3c7;
  transform: translateY(-1px);
}