/* css/style.css - cleaned, unified palette with carbon fiber outer backdrop */
:root {
  --bg: #ffffff;
  --fg: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --focus: #2563eb;
  --error: #dc2626;
  --warn: #d97706;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: #1a1a1a;
  background-image:
    linear-gradient(45deg, #222 25%, transparent 25%),
    linear-gradient(-45deg, #222 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #222 75%),
    linear-gradient(-45deg, transparent 75%, #222 75%);
  background-size: 10px 10px;
}

header {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

h1 { margin: 0; font-size: 1.4rem; }

nav ul { display: flex; gap: .5rem; list-style: none; padding: 0; margin: .5rem 0; }
nav button {
  background: #f4f4f4; border: 1px solid #ccc;
  padding: .4rem .8rem; border-radius: .4rem;
  cursor: pointer; font-size: inherit;
}
nav button[aria-current="true"] {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

main {
  max-width: 900px;
  margin: 0 auto 1.5rem auto;
  padding: 1rem 1.25rem 1.5rem 1.25rem;
  background: var(--bg);
  border-radius: 0 0 .5rem .5rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

section { margin: 1rem 0; }

label { display: block; font-weight: 600; margin: .4rem 0 .2rem; }
input, select, textarea {
  width: 100%; padding: .5rem; border: 1px solid #cbd5e1;
  border-radius: .4rem; font-family: inherit;
}

button {
  padding: .5rem .8rem; border: 1px solid #999;
  background: #fff; border-radius: .4rem; cursor: pointer; font-size: inherit;
}

button:focus, input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--focus); outline-offset: 1px;
}

.actions { display: flex; gap: .5rem; margin-top: .5rem; }

#settingsPanel fieldset { border: 1px solid #cbd5e1; padding: .8rem; border-radius: .4rem; }
#status { margin-top: .5rem; color: var(--muted); min-height: 1.5rem; }

/* loading spinner */
.loading {
  display: inline-block; width: 1rem; height: 1rem;
  border: 2px solid var(--muted); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* error / warning states */
.error-state { color: var(--error); font-weight: 600; }
.warn-state { color: var(--warn); }

/* Turn card - current implementation */
.turn-card {
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fff;
}
.turn-card.stale { opacity: 0.5; }

.turn-heading {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

/* User line */
.turn-user { display: flex; flex-direction: column; }
.label-user {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
}
.turn-user p { color: var(--fg); }

/* Model line */
.turn-model { display: flex; flex-direction: column; }
.label-model {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.8rem;
}
.turn-model p { color: var(--fg); }

/* Inline metrics — single line, always visible */
.metrics-inline {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Expand button */
.metrics-expand {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  margin-left: 6px;
}
.metrics-detail {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px dashed #cbd5e1;
  margin-top: 4px;
}

/* Toolbar */
.turn-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.btn-edit, .btn-resend, .btn-delete {
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.btn-delete:hover { color: var(--error); }
.btn-edit:hover { color: var(--accent); }
.btn-resend:hover { color: #059669; }

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

/* Code block styling */
.ai-code-block {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: .4rem;
  padding: .75rem 1rem;
  overflow-x: auto;
  white-space: pre;
  margin: .5rem 0;
}

.codeCopy, .codeDownload {
  position: absolute;
  top: -2rem;
  right: 0;
  font-size: 0.7rem;
  padding: 2px 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  border-radius: .25rem;
}

.codeDownload {
  top: -3.5rem;
}

.codeCopy.copied {
  color: #059669;
  border-color: #059669;
}
