/* Gravity Font Family */
@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-Book.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-Book-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-Light-Italic.ttf') format('truetype');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-Bold-Italic.ttf') format('truetype');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-UltraLight.ttf') format('truetype');
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Gravity';
  src: url('/static/fonts/Gravity-UltraLight-Italic.ttf') format('truetype');
  font-weight: 200;
  font-style: italic;
  font-display: swap;
}

:root{
  --bg: #ffffff;
  --text: #212121;
  --muted: #8A8B8A;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --border: #e6e9ef;
  --shadow: 0 10px 28px rgba(10, 22, 50, .06);
  --radius: 10px;

  /* Primary color palette - Updated to light blue */
  --primary: #6CBEDA;
  --primary-hover: #5aadca;
  --primary-ring: 108 190 218;

  --accent: #DD4730;
  --danger: #DD4730;
  --danger-hover: #c23d28;
  --danger-ring: 221 71 48;
}

/* Utility class for hiding elements - use instead of inline style="display:none" */
.hidden {
  display: none !important;
}

/* Force light theme values even if user prefers dark */
@media (prefers-color-scheme: dark) {
  :root{
    --bg: #ffffff;
    --text: #212121;
    --muted: #8A8B8A;
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --border: #e6e9ef;
    --shadow: 0 10px 28px rgba(10, 22, 50, .06);

    --primary: #6CBEDA;
    --primary-hover: #5aadca;
    --primary-ring: 108 190 218;

    --accent: #DD4730;
    --danger: #DD4730;
    --danger-hover: #c23d28;
    --danger-ring: 221 71 48;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body{
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Gravity', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 90px; /* space for fixed footer */
}

/* Ensure content (conversation + feedback) is not hidden behind the fixed footer */
.app {
    /* Increase if the footer height changes; this padding keeps bottom content visible */
    padding-bottom: 88px;
}

/* Desktop / default: title (first child) left, logo (second child) right */
.app-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;   /* pushes first child left, second right */
  padding: 16px 16px 0;
}

/* Logo wrapper on the right (desktop) */
.app-header__logo-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 0;
  gap: 12px;
}

/* Title styling for header (desktop) */
.title{
  font-family: 'Gravity', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: #6CBEDA;
  font-size: 2rem;
  font-weight: 700;
  margin: 0;                        /* no extra vertical margin inside header row */
  letter-spacing: normal;
}

/* Logo size */
.app-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}
.app-logo--customer {
  height: 55px;
}
.customer-logo-link {
  display: inline-flex;
  align-items: center;
}

/* Credits/Token Balance Display */
.credits-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
}
.credits-display__label {
  color: var(--muted);
}
.credits-display__value {
  color: var(--text);
  font-weight: 700;
  min-width: 40px;
  text-align: right;
}
.credits-display--low .credits-display__value {
  color: #e67e22;
}
.credits-display--critical .credits-display__value {
  color: var(--danger);
  animation: pulse-critical 1s ease-in-out infinite;
}
@keyframes pulse-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* On very small screens, stack logo above title and center them */
@media (max-width: 480px) {
  .app-header {
    flex-direction: column-reverse;  /* stack, but visually: logo ABOVE title */
    align-items: center;
    text-align: center;
    padding-top: 20px;
  }

  .app-header__logo-row {
    justify-content: center;
    margin-bottom: 4px;              /* tight vertical gap between logo and title */
  }

  .app-logo {
    height: 24px;
  }
  .app-logo--customer {
    height: 30px;
  }
}

/* Mobile-specific fine-tuning */
@media (max-width: 600px) {
  .app-header {
    padding-top: 20px;
  }

  .app-header__logo-row {
    margin-bottom: 3px;
  }
}

/* Header Bar */
header {
  background-color: #6CBEDA;
  padding: 1rem 2rem;
}
header nav a {
  color: #ffffff;
  margin: 0 1rem;
  text-decoration: none;
  font-weight: 500;
}
header nav a:hover {
  text-decoration: underline;
  color: #e8f4f8;
}

/* Headings */
h1, h2, h3{
  font-family: 'Gravity', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: #6CBEDA;
  margin: 1.5rem 0 1rem;
  font-weight: 700;
  letter-spacing: normal;
  line-height: 1.2;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }

/* Paragraphs */
p {
  margin: 1rem 0;
  color: #8A8B8A;
}

/* Links */
a{
  color: #6CBEDA;
  text-decoration: none;
  border-bottom: none;
}
a:hover{
  color: #5aadca;
  text-decoration: underline;
}

/* Lists */
ul {
  margin: 1rem 0 1rem 1.5rem;
}
ul li {
  margin-bottom: 0.5rem;
  color: #8A8B8A;
}

/* Content Wrapper */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
}

.controls{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* New scenario description box */
.scenario-desc{
  flex: 1 1 100%;
  font-size: .85rem;
  line-height: 1.3;
  background: var(--surface-2);
  border: 1px solid color-mix(in oklab, var(--border), transparent 5%);
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  min-height: 40px;
  display: flex;
  align-items: flex-start;
  font-family: 'Gravity', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  white-space: pre-wrap;
}

/* NEW: scenario timer pill */
.scenario-timer{
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--primary), transparent 25%);
  background: color-mix(in oklab, var(--primary), white 80%);
  color: var(--primary);
  font-family: 'Roboto Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: .92rem;
  font-weight: 600;
}
.scenario-timer--disabled{
  background: color-mix(in oklab, var(--border), white 75%);
  border-color: color-mix(in oklab, var(--border), transparent 10%);
  color: var(--muted);
  opacity: .75;
  pointer-events: none;
  cursor: default;
}
.scenario-timer--disabled .scenario-timer__label,
.scenario-timer--disabled .scenario-timer__value{
  color: inherit;
}
.scenario-timer__label{
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}
.scenario-timer__value{
  font-size: 1rem;
}

/* Buttons */
.btn{
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform .06s ease, background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
  box-shadow: 0 2px 8px rgba(10, 22, 50, .05);
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }
.btn:focus-visible{
  outline: 2px solid rgba(var(--primary-ring), .25);
  outline-offset: 2px;
}
.btn[disabled]{ opacity: .55; cursor: not-allowed; transform: none; }

/* Primary: #6CBEDA with white text */
.btn--primary{
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(108, 190, 218, .22);
}
.btn--primary:hover{ background: var(--primary-hover); }

/* Outlined: white with #6CBEDA text and outline */
.btn--ghost{
  background: #ffffff;
  color: var(--primary);
  border-color: var(--primary);
}
.btn--ghost:hover{
  background: #e0f2f9;
  border-color: var(--primary-hover);
}

/* Keep danger button as-is */
.btn--danger{
  background: var(--danger);
  border-color: color-mix(in oklab, var(--danger), black 10%);
  color: #fff;
  box-shadow: 0 10px 20px rgba(230, 69, 69, .18);
}
.btn--danger:hover{ background: var(--danger-hover); }

/* Small button variant */
.btn--sm{
  padding: 6px 10px;
  font-size: 0.8rem;
}

/* User menu in header */
.user-menu{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
}
.user-menu__email{
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .user-menu{
    padding: 3px 8px;
    font-size: 0.75rem;
  }
  .user-menu__email{
    max-width: 120px;
  }
}

/* Panels and section headers */
.panel{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(10,22,50,.06);
  padding: 16px;
}

.panel__title{
  /* Reset to a compact sans label with gold accent */
  font-family: 'Gravity', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
  font-size: 12px;
  color: color-mix(in oklab, var(--text), transparent 45%);
  padding-left: 12px;
  border-left: 4px solid var(--primary);
  margin: 0 0 12px;
}

.log{
  min-height: 160px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid color-mix(in oklab, var(--border), transparent 5%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.4;
}

.log p{
  margin: 0 0 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: color-mix(in oklab, var(--surface), transparent 8%);
  border: 1px solid color-mix(in oklab, var(--border), transparent 10%);
  word-break: break-word;
  white-space: pre-wrap;
}

.log p:last-child{ margin-bottom: 0; }

.log::-webkit-scrollbar{
  width: 10px;
  height: 10px;
}
.log::-webkit-scrollbar-thumb{
  background: color-mix(in oklab, var(--muted), transparent 25%);
  border-radius: 999px;
  border: 2px solid var(--surface-2);
}
.log::-webkit-scrollbar-track{
  background: transparent;
}

/* Minimal chat-bubble styling (moved from index.html) */
.chat {
  max-width: 900px;
  margin: 1rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.bubble {
  display: inline-block;
  max-width: 80%;
  padding: .625rem .875rem;
  border-radius: 14px;
  line-height: 1.4;
  font-family: 'Gravity', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  box-shadow: 0 1px 1px rgba(0,0,0,.05);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bubble__label {
  font-size: .72rem;
  font-weight: 600;
  opacity: .7;
  margin-bottom: .25rem;
}
.bubble__text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}
/* Barrister (assistant) on the left, dark bubble */
.bubble--assistant {
  align-self: flex-start;
  background: #0f172a;
  color: white;
  border-bottom-left-radius: 4px;
}
/* Expert witness (user) on the right, light bubble */
.bubble--user {
  align-self: flex-end;
  background: #f1f5f9;
  color: #0f172a;
  border-bottom-right-radius: 4px;
}
.bubble--typing {
  opacity: .9;
}

/* Fixed footer session controls */
.session-controls-footer{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 18px rgba(10,22,50,.10);
  backdrop-filter: blur(6px);
  min-height: 72px;
}

.session-controls-footer .btn{
  min-width: 140px;
}

/* Mobile tweaks */
@media (max-width: 560px){
  .session-controls-footer{
    flex-wrap: wrap;
    justify-content: stretch;
  }
  .session-controls-footer .btn{
    flex: 1 1 auto;
    min-width: 0;
  }
}

/* Small screens */
@media (max-width: 520px){
  .controls { padding: 12px; }
  .btn { flex: 1 1 auto; }
}

/* Feedback score styles */
.feedback-score {
  font-weight: 600;
}
.feedback-score--na {
  font-style: italic;
  font-weight: normal;
}

