/* ═══════════════════════════════════════════════════════════════
   AIMWELL CORTEX — Conversational Intelligence Layer
   Enterprise-grade decision interface
   ═══════════════════════════════════════════════════════════════ */

/* ═══ PANEL SHELL ═══ */
.cortex {
  background: linear-gradient(135deg, #060E1A 0%, #0B1D33 50%, #0F2440 100%);
  border-bottom: 1px solid rgba(0,168,204,0.12);
  position: relative;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s;
}

.cortex::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 600px 300px at 20% 50%, rgba(0,168,204,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 400px 200px at 80% 30%, rgba(212,175,55,0.03) 0%, transparent 70%);
  pointer-events: none;
}

.cortex--collapsed {
  max-height: 52px !important;
}

.cortex__inner {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ═══ HEADER BAR ═══ */
.cortex__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  user-select: none;
}

.cortex__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.cortex__logo {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00A8CC;
  box-shadow: 0 0 8px rgba(0,168,204,0.6), 0 0 20px rgba(0,168,204,0.2);
  animation: cortexPulse 3s ease-in-out infinite;
}

.cortex__logo--gold {
  background: #D4AF37;
  box-shadow: 0 0 8px rgba(212,175,55,0.6), 0 0 20px rgba(212,175,55,0.2);
  animation: cortexPulseGold 3s ease-in-out infinite;
}

.cortex__logo--learning {
  animation: cortexLearn 1.5s ease-in-out infinite;
}

@keyframes cortexPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(0,168,204,0.6), 0 0 20px rgba(0,168,204,0.2); }
  50% { opacity: 0.7; box-shadow: 0 0 4px rgba(0,168,204,0.3), 0 0 12px rgba(0,168,204,0.1); }
}

@keyframes cortexPulseGold {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(212,175,55,0.6), 0 0 20px rgba(212,175,55,0.2); }
  50% { opacity: 0.7; box-shadow: 0 0 4px rgba(212,175,55,0.3), 0 0 12px rgba(212,175,55,0.1); }
}

@keyframes cortexLearn {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.cortex__name {
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(255,255,255,0.5);
}

.cortex__name span {
  color: #00A8CC;
}

.cortex__name--enterprise span {
  color: #D4AF37;
}

.cortex__status {
  font-size: 0.62rem;
  font-weight: 500;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.04em;
}

.cortex__toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cortex__toggle-label {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.cortex__toggle-icon {
  width: 16px;
  height: 16px;
  stroke: rgba(255,255,255,0.3);
  fill: none;
  stroke-width: 2;
  transition: transform 0.3s;
}

.cortex--collapsed .cortex__toggle-icon {
  transform: rotate(180deg);
}

/* ═══ BODY ═══ */
.cortex__body {
  padding: 1.25rem 0 1.5rem;
  transition: opacity 0.3s;
}

.cortex--collapsed .cortex__body {
  display: none;
}

/* ═══ BRIEFING STRIP ═══ */
.cortex__briefing {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 6px;
  margin-bottom: 1.25rem;
}

.cortex__briefing-icon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00A8CC;
  flex-shrink: 0;
}

.cortex__briefing-icon--alert {
  background: #DC2626;
  animation: cortexPulseAlert 1.5s ease-in-out infinite;
}

@keyframes cortexPulseAlert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(220,38,38,0); }
}

.cortex__briefing-text {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.5;
  flex: 1;
}

.cortex__briefing-text strong {
  color: #fff;
  font-weight: 600;
}

/* ═══ INSIGHT CARDS ═══ */
.cortex__insights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.cortex__insight {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 1rem;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.cortex__insight:hover {
  border-color: rgba(0,168,204,0.2);
  background: rgba(0,168,204,0.03);
}

.cortex__insight--alert {
  border-color: rgba(220,38,38,0.2);
}

.cortex__insight--alert:hover {
  border-color: rgba(220,38,38,0.35);
  background: rgba(220,38,38,0.03);
}

.cortex__insight-tag {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
}

.cortex__insight-tag--open { color: #059669; }
.cortex__insight-tag--blind { color: #D97706; }
.cortex__insight-tag--unknown { color: #DC2626; }
.cortex__insight-tag--entity { color: #3B82F6; }

.cortex__insight-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.cortex__insight-reason {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.35);
  line-height: 1.5;
}

.cortex__insight-confidence {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 2px;
  margin-top: 0.5rem;
}

.cortex__insight-confidence--high { background: rgba(5,150,105,0.15); color: #059669; }
.cortex__insight-confidence--medium { background: rgba(217,119,6,0.15); color: #D97706; }
.cortex__insight-confidence--low { background: rgba(220,38,38,0.15); color: #DC2626; }

/* ═══ PROMPT AREA ═══ */
.cortex__prompt {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.cortex__prompt-question {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.cortex__prompt-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cortex__prompt-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.15s;
}

.cortex__prompt-btn:hover {
  border-color: rgba(0,168,204,0.4);
  background: rgba(0,168,204,0.08);
  color: #00A8CC;
}

.cortex__prompt-btn--primary {
  border-color: rgba(0,168,204,0.3);
  background: rgba(0,168,204,0.08);
  color: #00A8CC;
}

.cortex__prompt-btn--primary:hover {
  background: rgba(0,168,204,0.15);
}

/* ═══ QUICK ACTIONS ═══ */
.cortex__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cortex__action {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.06);
  background: transparent;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: all 0.15s;
}

.cortex__action:hover {
  border-color: rgba(0,168,204,0.3);
  color: #00A8CC;
  background: rgba(0,168,204,0.05);
}

/* ═══ ONBOARDING ═══ */
.cortex__onboard {
  padding: 0.5rem 0;
}

.cortex__onboard-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.cortex__onboard-step {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.06);
  border-radius: 1px;
  overflow: hidden;
}

.cortex__onboard-step--done {
  background: #00A8CC;
}

.cortex__onboard-step--active {
  background: rgba(0,168,204,0.2);
  position: relative;
}

.cortex__onboard-step--active::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 50%;
  background: #00A8CC;
  border-radius: 1px;
}

.cortex__onboard-counter {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
}

.cortex__onboard-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 1.5rem;
  animation: cortexCardIn 0.3s ease;
}

@keyframes cortexCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.cortex__onboard-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #00A8CC;
  margin-bottom: 0.6rem;
}

.cortex__onboard-question {
  font-family: 'DM Serif Display', serif;
  font-size: 1.15rem;
  color: #fff;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.cortex__onboard-desc {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.4);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.cortex__onboard-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.cortex__onboard-option {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.65rem 1rem;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.cortex__onboard-option:hover {
  border-color: rgba(0,168,204,0.3);
  background: rgba(0,168,204,0.06);
  color: #fff;
}

.cortex__onboard-option.selected {
  border-color: #00A8CC;
  background: rgba(0,168,204,0.1);
  color: #00A8CC;
}

.cortex__onboard-input {
  font-family: 'Inter', sans-serif;
  width: 100%;
  font-size: 0.82rem;
  padding: 0.65rem 1rem;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}

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

.cortex__onboard-input:focus {
  border-color: rgba(0,168,204,0.4);
}

.cortex__onboard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.cortex__onboard-skip {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.25);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.cortex__onboard-skip:hover {
  color: rgba(255,255,255,0.4);
}

.cortex__onboard-next {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 4px;
  border: none;
  background: #00A8CC;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.cortex__onboard-next:hover {
  background: #008FAD;
}

.cortex__onboard-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ═══ CHAT THREAD (expandable) ═══ */
.cortex__thread {
  margin-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.04);
  padding-top: 1rem;
}

.cortex__thread-toggle {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.25);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cortex__thread-toggle:hover {
  color: rgba(255,255,255,0.4);
}

.cortex__messages {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.cortex__msg {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  animation: cortexMsgIn 0.25s ease;
}

@keyframes cortexMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.cortex__msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.cortex__msg-avatar--system {
  background: rgba(0,168,204,0.15);
  color: #00A8CC;
}

.cortex__msg-avatar--user {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
}

.cortex__msg-content {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
}

.cortex__msg-content strong {
  color: rgba(255,255,255,0.85);
}

.cortex__msg-time {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.15);
  margin-top: 0.15rem;
}

/* Chat input */
.cortex__input-row {
  display: flex;
  gap: 0.5rem;
}

.cortex__input {
  font-family: 'Inter', sans-serif;
  flex: 1;
  font-size: 0.78rem;
  padding: 0.6rem 1rem;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.cortex__input::placeholder {
  color: rgba(255,255,255,0.15);
}

.cortex__input:focus {
  border-color: rgba(0,168,204,0.3);
}

.cortex__send {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0 1rem;
  border-radius: 5px;
  border: none;
  background: rgba(0,168,204,0.15);
  color: #00A8CC;
  cursor: pointer;
  transition: background 0.2s;
}

.cortex__send:hover {
  background: rgba(0,168,204,0.25);
}

/* ═══ SUMMARY CARD (post-onboard) ═══ */
.cortex__summary {
  background: rgba(5,150,105,0.05);
  border: 1px solid rgba(5,150,105,0.15);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  animation: cortexCardIn 0.4s ease;
}

.cortex__summary-title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #059669;
  margin-bottom: 0.5rem;
}

.cortex__summary-text {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 900px) {
  .cortex__inner { padding: 0 1rem; }
  .cortex__insights { grid-template-columns: 1fr; }
  .cortex__onboard-options { grid-template-columns: 1fr; }
}
