/* Premium Styling for KranWerk Voice Console with integrated Superuser Login */
* { box-sizing: border-box; }

:root {
  --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --color-primary: #0f2742;
  --color-primary-light: #1e3a5f;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-error: #dc2626;
  --color-error-light: #fee2e2;
  --color-bg-main: #f8fafc;
  --color-text-dark: #0f172a;
  --color-text-muted: #64748b;
  --color-border: #cbd5e1;
}

body {
  font-family: var(--font-primary);
  margin: 0;
  color: var(--color-text-dark);
  background: var(--color-bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header Styling */
header {
  background: var(--color-primary);
  color: #fff;
  padding: 16px 24px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.app-version {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: #94a3b8;
  margin-left: 8px;
  vertical-align: middle;
}

.login-header .app-version {
  display: block;
  margin: 8px 0 0;
  color: #64748b;
}

.subtitle {
  color: #94a3b8;
  font-size: 13px;
  margin-top: 6px;
  display: inline-block;
  font-weight: 500;
}

.user-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-email-display {
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#logout-btn {
  background: transparent;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #fff;
  color: #fff;
}

/* Premium Login Page Styling */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #020617 0%, #0f172a 100%);
  padding: 20px;
}

/* Glassmorphism card animation */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.login-card {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5);
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 32px;
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(37, 99, 235, 0.3);
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  margin: 0 auto 16px;
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.2);
}

.login-card h1 {
  font-family: var(--font-display);
  color: #f8fafc;
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: #94a3b8;
  font-size: 14px;
  margin: 0;
  font-weight: 500;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.login-field label {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
}

.login-field input {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  padding: 12px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}

.login-field input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  background: rgba(30, 41, 59, 0.8);
}

.login-error-alert {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #fca5a5;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  line-height: 1.4;
}

#login-btn {
  background: var(--color-accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s ease;
}

#login-btn:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 0 15px rgba(37, 99, 235, 0.4);
}

#login-btn:active {
  transform: scale(0.98);
}

#login-btn:disabled {
  background: #475569;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

/* Console Section and Control Layout */
.tab { padding: 24px 20px; max-width: 800px; margin: 0 auto; }
.cost-panel[hidden] { display: none; }
.cost-panel > .subtitle { color: var(--color-text-muted); }
.cost-range { display: flex; gap: 8px; margin: 16px 0; }
.cost-range button { padding: 8px 14px; border: 1px solid var(--color-border); border-radius: 7px; background: #fff; color: var(--color-primary); cursor: pointer; }
.cost-range button.selected { background: #163e68; border-color: #163e68; color: #fff; }
.cost-engine { margin-top: -8px; }
.cost-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 18px 0; }
.cost-summary article { background: #fff; border: 1px solid var(--color-border, #d5dbe3); border-radius: 10px; padding: 14px; display: grid; gap: 8px; }
.cost-summary article span, .cost-note { color: var(--color-text-muted); font-size: 12px; }
.cost-summary strong { font-size: 20px; }
.cost-header { font-weight: 700; }
.cost-row { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--color-border, #d5dbe3); font-size: 13px; }
.cost-note { margin-top: 18px; }
header nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
header nav button { margin: 0; }
#cost-nav-btn { border: 1px solid rgba(255,255,255,.4); border-radius: 7px; padding: 8px 12px; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; }

.field { display: grid; gap: 6px; margin-bottom: 12px; color: var(--color-text-muted); font-size: 13px; font-weight: 600; }
.field input {
  width: 100%; max-width: 320px; padding: 10px 12px;
  border: 1px solid var(--color-border); border-radius: 8px; font: inherit; color: var(--color-text-dark);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); outline: none;
}

.controls { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
#start-btn, #stop-btn {
  border: 0; padding: 11px 20px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: all 0.2s ease;
}
#start-btn { background: var(--color-success); color: #fff; }
#start-btn:hover:not(:disabled) { background: #15803d; transform: translateY(-1px); }
#start-btn:disabled { background: #bbf7d0; color: #166534; cursor: default; }

#stop-btn { background: var(--color-error); color: #fff; }
#stop-btn:hover:not(:disabled) { background: #b91c1c; transform: translateY(-1px); }
#stop-btn:disabled { background: #fca5a5; color: #991b1b; cursor: default; }

.status { color: var(--color-text-muted); font-size: 13px; font-weight: 500; }

.mic { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; margin-left: auto; }
.mic .bar { width: 4px; height: 3px; background: var(--color-border); border-radius: 2px; transition: height .08s, background .08s; }

#live {
  border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px;
  min-height: 340px; background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02), 0 1px 2px rgba(0,0,0,0.04);
}
.bubble { max-width: 80%; padding: 10px 14px; margin: 8px 0; border-radius: 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.bubble.agent { background: #eff6ff; color: #1e3a8a; border-bottom-left-radius: 4px; }
.bubble.caller { background: #f1f5f9; color: #334155; margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.interim { opacity: .55; font-style: italic; }
.system-note { text-align: center; color: var(--color-text-muted); font-size: 12px; margin: 10px 0; font-weight: 500; }
.test-transcript { margin-top: 18px; padding: 16px; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface, #fff); }
.test-transcript h2 { margin: 0; font-size: 18px; }
.test-transcript-lines { display: flex; flex-direction: column; gap: 8px; }
.test-transcript-line { padding: 10px 12px; border-radius: 10px; background: #f1f5f9; white-space: pre-wrap; line-height: 1.5; }
.test-transcript-line.agent { background: #eff6ff; }
.test-transcript-line.interrupted::after { content: " · unterbrochen"; color: var(--color-text-muted); font-size: 12px; }
.meta { margin-top: 10px; color: var(--color-text-muted); font-size: 12px; font-weight: 500; }

/* Latency stats panel */
.stats {
  max-width: 800px; margin: 0 auto 24px; padding: 0 20px;
}
.stats h2 { font-size: 15px; margin: 4px 0 10px; color: var(--color-primary); font-family: var(--font-display); font-weight: 700; }
.stats h3 { font-size: 13px; margin: 16px 0 8px; color: var(--color-text-muted); font-weight: 600; }
.stats-turns { color: var(--color-text-muted); font-weight: 500; font-size: 12px; }
.stats-group {
  border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; background: #ffffff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.stats-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 14px; font-size: 13px; color: #475569;
  border-top: 1px solid #f1f5f9;
}
.stats-row:first-child { border-top: 0; }
.stats-row span:last-child {
  font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--color-text-dark); font-weight: 500;
}
.stats-row.stats-gap { background: #eff6ff; font-weight: 600; border-bottom: 1px solid #bfdbfe; }
.stats-row.stats-gap span:last-child { color: #1e40af; font-weight: 700; }

/* Continuous per-turn response-delay log */
.resp-log {
  border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; background: #ffffff;
  max-height: 240px; overflow-y: auto; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.resp-row {
  display: flex; justify-content: space-between; padding: 8px 14px; font-size: 13px;
  color: #475569; border-top: 1px solid #f1f5f9;
}
.resp-row:first-child { border-top: 0; }
.resp-row span:last-child {
  font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--color-text-dark); font-weight: 600;
}

/* Transcription Toggle checkbox */
.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.checkbox-field input {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  margin: 0;
  accent-color: var(--color-accent);
}

/* Console speaker team */
#speaker-team-panel { margin-top: 20px; padding: 18px; border: 1px solid #ccd6e0; border-radius: 10px; }
#speaker-team-panel[hidden], #speaker-team-options[hidden] { display: none; }
#speaker-team-panel legend { font-weight: 600; }
#speaker-team-panel p { font-size: 13px; line-height: 1.5; }
#speaker-mode, #speaker-search { max-width: 100%; padding: 8px; margin: 8px 0; }
#speaker-team-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 8px; max-height: 280px; overflow-y: auto; margin-top: 12px; }
#speaker-team-list label { display: flex; align-items: start; gap: 8px; padding: 10px; border: 1px solid #d5dce4; border-radius: 8px; font-size: 13px; }
#speaker-team-list label:has(input:checked) { border-color: #ef970d; background: #fff5e5; }
#speaker-team-list input { accent-color: #ef970d; }
#speaker-team-list label[hidden] { display: none; }
