/* Consulting Factory - Transcend AI Partners Brand Styling */

/* CSS Variables - Brand Colors */
:root {
  /* Primary */
  --deep-teal: #234E52;
  --charcoal: #2D3748;
  --coral: #ED8936;

  /* Supporting */
  --warm-white: #FFFAF0;
  --slate-gray: #718096;
  --forest-green: #38A169;
  --amber: #D69E2E;
  --crimson: #E53E3E;
  --ocean-blue: #2B6CB0;

  /* UI Tints */
  --info-tint: #EBF8FF;
  --success-tint: #F0FFF4;
  --warning-tint: #FFFAF0;
  --error-tint: #FFF5F5;

  /* Typography */
  --font-heading: 'Merriweather', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--charcoal);
  background: var(--warm-white);
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--deep-teal);
  margin: 0;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; font-family: var(--font-body); font-weight: 600; }
h4 { font-size: 1.125rem; font-family: var(--font-body); font-weight: 600; }

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--deep-teal);
  color: white;
}

.btn-primary:hover {
  background: #1a3a3d;
}

.btn-ghost {
  background: transparent;
  color: var(--charcoal);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Back button */
.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--charcoal);
  transition: background 0.2s;
  cursor: pointer;
  background: none;
  border: none;
}

.back-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: var(--charcoal);
  color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  animation: toast-in 0.3s ease;
}

.toast-hide {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--slate-gray);
}

.loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--warm-white);
  border-top-color: var(--deep-teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error state */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}

.error-page h1 {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.error-page p {
  color: var(--slate-gray);
  margin-bottom: 2rem;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: var(--slate-gray);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Utility classes */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Mobile-first responsive design */
@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .btn {
    padding: 0.625rem 0.875rem;
  }
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--deep-teal);
  outline-offset: 2px;
}

/* Selection styling */
::selection {
  background: rgba(35, 78, 82, 0.2);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--warm-white);
}

::-webkit-scrollbar-thumb {
  background: var(--slate-gray);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--charcoal);
}

/* ============================================================
   Rich Agent Terminal
   ============================================================ */
.agent-terminal-container {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.agent-terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--charcoal);
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
}

.terminal-header--running .terminal-step-info { color: var(--amber); }
.terminal-header--complete .terminal-step-info { color: var(--forest-green); }
.terminal-header--error .terminal-step-info { color: var(--crimson); }

.terminal-elapsed {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

.terminal-metrics-bar {
  display: flex;
  gap: 1rem;
  padding: 0.375rem 1rem;
  background: #232340;
  flex-wrap: wrap;
}

.terminal-metric {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
}

.terminal-metric-value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--forest-green);
}

.terminal-metric-label {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.agent-terminal-output {
  background: #1a1a2e;
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.85);
}

/* Terminal output scrollbar (dark) */
.agent-terminal-output::-webkit-scrollbar-track { background: #1a1a2e; }
.agent-terminal-output::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.agent-terminal-output::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Terminal line types */
.terminal-line {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1px 0;
}

.line-stage { color: var(--ocean-blue); font-weight: 600; margin-top: 0.25rem; }
.line-step-start { color: #e2e8f0; margin-top: 0.5rem; border-left: 3px solid var(--ocean-blue); padding-left: 0.75rem; }
.line-step-num { color: var(--ocean-blue); font-weight: 700; }
.line-step-name { color: #e2e8f0; font-weight: 600; }
.line-step-desc { color: rgba(255,255,255,0.5); font-weight: 400; }
.line-step-end { color: var(--forest-green); font-size: 0.75rem; padding-left: 1rem; }
.line-metric { padding-left: 1rem; }
.line-metric-label { color: rgba(255,255,255,0.5); }
.line-metric-value { color: var(--forest-green); font-weight: 600; }
.line-tool { color: rgba(255,255,255,0.5); padding-left: 1rem; }
.line-tool-icon { color: var(--amber); font-weight: 700; }
.line-tool-summary { color: rgba(255,255,255,0.6); }
.line-progress { color: rgba(255,255,255,0.7); }
.line-qa { color: #b794f4; font-weight: 500; }
.line-log { color: rgba(255,255,255,0.6); }
.line-warning { color: var(--amber); }
.line-complete { color: var(--forest-green); font-weight: 600; margin-top: 0.25rem; }
.line-error { color: var(--crimson); font-weight: 500; }
.line-status { color: var(--amber); }


/* ============================================================
   Chat Panel
   ============================================================ */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: white;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.chat-msg {
  max-width: 85%;
  animation: msg-in 0.15s ease;
}

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

.chat-msg--user {
  align-self: flex-end;
}

.chat-msg--agent {
  align-self: flex-start;
}

.chat-msg--system {
  align-self: center;
  font-size: 0.75rem;
  color: var(--slate-gray);
  padding: 0.25rem 0.75rem;
  background: rgba(0,0,0,0.03);
  border-radius: 999px;
}

.chat-bubble {
  padding: 0.5rem 0.875rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg--user .chat-bubble {
  background: var(--deep-teal);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg--agent .chat-bubble {
  background: #f1f5f9;
  color: var(--charcoal);
  border-bottom-left-radius: 4px;
}

/* Action cards */
.chat-action-card {
  background: white;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  padding: 0.875rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.action-card-summary {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}

.action-card-params {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.param-tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: var(--info-tint);
  color: var(--ocean-blue);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.action-card-buttons {
  display: flex;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.375rem 1rem;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.action-btn--confirm {
  background: var(--deep-teal);
  color: white;
}

.action-btn--confirm:hover { background: #1a3a3d; }

.action-btn--cancel {
  background: rgba(0,0,0,0.05);
  color: var(--slate-gray);
}

.action-btn--cancel:hover { background: rgba(0,0,0,0.1); }

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-card--resolved {
  opacity: 0.6;
}

/* Data result cards */
.data-result-text {
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
}

.data-result-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8125rem;
}

.data-result-item {
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.data-result-item:last-child { border-bottom: none; }

.data-result-date {
  color: var(--slate-gray);
  font-size: 0.75rem;
}

.data-result-detail {
  color: var(--slate-gray);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

/* Chat input */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid rgba(0,0,0,0.08);
  background: #fafafa;
}

.chat-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px;
  background: white;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.15s;
}

.chat-input:focus {
  border-color: var(--deep-teal);
  box-shadow: 0 0 0 2px rgba(35,78,82,0.1);
}

.chat-input:disabled {
  opacity: 0.5;
}

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--deep-teal);
  color: white;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.chat-send-btn:hover { background: #1a3a3d; }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Download link in chat */
.aw-download-link {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  background: var(--deep-teal);
  color: white !important;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-top: 0.25rem;
  text-decoration: none;
}

.aw-download-link:hover { background: #1a3a3d; }


/* ============================================================
   Audit Workflows Page -- Two-Panel Layout
   ============================================================ */
.aw-page {
  padding: 0.75rem;
  height: calc(100vh - 80px); /* subtract header */
  display: flex;
  flex-direction: column;
}

.aw-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 0.25rem;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.aw-tab {
  padding: 0.5rem 1rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--slate-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.aw-tab:hover:not(:disabled) { color: var(--charcoal); }
.aw-tab--active { color: var(--deep-teal); border-bottom-color: var(--deep-teal); }
.aw-tab--disabled { opacity: 0.4; cursor: not-allowed; }

/* Desktop: side-by-side panels */
.aw-panels {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

.aw-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.aw-panel--chat {
  flex: 0 0 38%;
  max-width: 38%;
}

.aw-panel--terminal {
  flex: 1;
}

/* Mobile toggle bar (hidden on desktop) */
.aw-mobile-toggle {
  display: none;
  gap: 0.25rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

.aw-mobile-btn {
  flex: 1;
  padding: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid rgba(0,0,0,0.1);
  background: white;
  color: var(--slate-gray);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.aw-mobile-btn--active {
  background: var(--deep-teal);
  color: white;
  border-color: var(--deep-teal);
}

/* Results section (below terminal) */
.aw-results {
  margin-top: 0.75rem;
  background: white;
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.aw-results-header {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--charcoal);
  margin-bottom: 0.75rem;
}

.aw-results-stats {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.aw-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.aw-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--deep-teal);
}

.aw-stat-label {
  font-size: 0.6875rem;
  color: var(--slate-gray);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.aw-release-status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.aw-status--ready { background: var(--success-tint); color: var(--forest-green); }
.aw-status--warning { background: var(--warning-tint); color: var(--amber); }
.aw-status--empty { background: rgba(0,0,0,0.04); color: var(--slate-gray); }

.aw-results-note {
  font-size: 0.8125rem;
  color: var(--slate-gray);
}

/* ============================================================
   Responsive: Tablet (stacked)
   ============================================================ */
@media (max-width: 1024px) {
  .aw-panels {
    flex-direction: column;
  }

  .aw-panel--chat {
    flex: none;
    max-width: 100%;
    max-height: 45vh;
  }

  .aw-panel--terminal {
    flex: 1;
  }
}

/* ============================================================
   Responsive: Mobile (tabbed)
   ============================================================ */
@media (max-width: 640px) {
  .aw-page {
    padding: 0.5rem;
  }

  .aw-mobile-toggle {
    display: flex;
  }

  .aw-panels {
    flex: 1;
  }

  .aw-panel--chat,
  .aw-panel--terminal {
    flex: none;
    max-width: 100%;
    height: 100%;
  }

  /* On mobile, only show the active panel */
  .aw-panel--terminal {
    display: none;
  }

  .aw-panel--chat {
    display: flex;
  }

  .aw-panel--visible {
    display: flex !important;
  }

  .aw-panel:not(.aw-panel--visible) {
    display: none !important;
  }

  /* Chat panel starts as visible on mobile */
  .aw-panel--chat.aw-panel--visible ~ .aw-panel--terminal:not(.aw-panel--visible) {
    display: none;
  }
}

/* Badge (shared) */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge--relevant {
  background: var(--success-tint);
  color: var(--forest-green);
}

.badge--not-relevant {
  background: rgba(0, 0, 0, 0.04);
  color: var(--slate-gray);
}

/* Print styles */
@media print {
  .app-header,
  .btn,
  .toast,
  .aw-mobile-toggle {
    display: none !important;
  }

  body {
    background: white;
  }
}
