/* ── Reset & Base ─────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: #111;
  background: #fafafa;
  line-height: 1.5;
}

a {
  color: #1D9E75;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 100vh;
  background: #fff;
  border-right: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px 20px;
}

.sidebar-logo {
  font-size: 16px;
  font-weight: 600;
  color: #111;
}

.sidebar-subtitle {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: #555;
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.15s;
}

.nav-link:hover {
  background: #f5f5f5;
  text-decoration: none;
  color: #111;
}

.nav-link.active {
  background: #f0f0f0;
  font-weight: 500;
  color: #111;
}

.sidebar-footer {
  padding: 16px 20px;
}

.sidebar-separator {
  height: 1px;
  background: #e5e5e5;
  margin-bottom: 16px;
}

.bot-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: #1D9E75;
}

.status-dot.offline {
  background: #ccc;
}

.main-content {
  margin-left: 200px;
  padding: 32px 40px;
  min-height: 100vh;
}

/* ── Page Header ─────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 500;
  color: #111;
}

.page-subtitle {
  font-size: 13px;
  color: #888;
  margin-top: 4px;
}

.back-link {
  font-size: 13px;
  color: #888;
  display: inline-block;
  margin-bottom: 8px;
}

.back-link:hover {
  color: #111;
  text-decoration: none;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.agent-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.agent-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.agent-name {
  font-size: 15px;
  font-weight: 500;
  color: #111;
}

.agent-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.agent-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.meta-label {
  color: #888;
}

.meta-value {
  color: #555;
  font-weight: 500;
}

.agent-card-footer {
  display: flex;
  justify-content: flex-end;
}

.agent-card-new {
  border-style: dashed;
  border-color: #ddd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #888;
  text-decoration: none;
  min-height: 180px;
  transition: border-color 0.15s, color 0.15s;
}

.agent-card-new:hover {
  border-color: #1D9E75;
  color: #1D9E75;
  text-decoration: none;
}

.new-agent-icon {
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.new-agent-text {
  font-size: 13px;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-active {
  background: #e8f5ef;
  color: #1D9E75;
}

.badge-inactive {
  background: #f5f5f5;
  color: #888;
}

.badge-pending {
  background: #fff8e1;
  color: #b08800;
}

.badge-good {
  background: #e8f5ef;
  color: #1D9E75;
}

.badge-bad {
  background: #fce8e8;
  color: #c0392b;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.btn-primary {
  background: #1D9E75;
  color: #fff;
  border-color: #1D9E75;
}

.btn-primary:hover {
  background: #178a65;
}

.btn-secondary {
  background: #fff;
  color: #555;
  border-color: #ddd;
}

.btn-secondary:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.btn-danger {
  background: #fff;
  color: #c0392b;
  border-color: #e5c5c5;
}

.btn-danger:hover {
  background: #fdf2f2;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-good {
  background: #e8f5ef;
  color: #1D9E75;
  border-color: #c3e6d5;
}

.btn-bad {
  background: #fce8e8;
  color: #c0392b;
  border-color: #f0c5c5;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 720px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: #111;
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #1D9E75;
}

.form-group input[type="range"] {
  width: 100%;
  accent-color: #1D9E75;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.form-group-inline label {
  text-transform: none;
  white-space: nowrap;
}

.form-group-inline select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  outline: none;
}

.form-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
}

.filters-bar {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── Toggle ──────────────────────────────────────────────────────────────── */

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.toggle input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: #ddd;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: #1D9E75;
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 13px;
  color: #555;
  font-weight: 400;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 400;
  font-family: inherit;
  color: #888;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.tab:hover {
  color: #555;
}

.tab.active {
  color: #111;
  font-weight: 500;
  border-bottom-color: #1D9E75;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Prompt ───────────────────────────────────────────────────────────────── */

.prompt-textarea {
  width: 100%;
  min-height: 300px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  resize: vertical;
  background: #fff;
  color: #111;
  outline: none;
}

.prompt-textarea:focus {
  border-color: #1D9E75;
}

/* ── History ──────────────────────────────────────────────────────────────── */

.history-item {
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
}

.history-date {
  font-size: 12px;
  color: #888;
}

.history-actions {
  display: flex;
  gap: 6px;
}

.history-content {
  padding: 12px 14px;
  background: #f9f9f9;
  border-top: 1px solid #e5e5e5;
}

.history-content pre {
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #555;
  line-height: 1.5;
  margin: 0;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e5e5;
}

.data-table td {
  padding: 10px 14px;
  font-size: 13px;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}

.data-table tr:hover td {
  background: #fafafa;
}

.data-table tr.clickable {
  cursor: pointer;
}

/* ── Call Detail (accordion) ─────────────────────────────────────────────── */

.call-detail {
  padding: 16px;
  background: #fafafa;
  border-bottom: 1px solid #e5e5e5;
}

.call-detail td {
  padding: 0;
}

.transcript {
  margin-bottom: 16px;
}

.transcript-line {
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.5;
}

.transcript-line.user {
  background: #f0f0f0;
  color: #555;
}

.transcript-line.bot {
  background: #fff;
  border: 1px solid #e5e5e5;
  color: #111;
}

.call-review {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.call-review textarea {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 40px;
  outline: none;
}

.call-review textarea:focus {
  border-color: #1D9E75;
}

/* ── Tools ────────────────────────────────────────────────────────────────── */

.tool-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 10px;
}

.tool-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tool-name {
  font-size: 14px;
  font-weight: 500;
  color: #111;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.tool-desc {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

.tool-url {
  font-size: 11px;
  color: #aaa;
  margin-top: 4px;
  font-family: monospace;
  word-break: break-all;
}

.webhook-result {
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 12px;
  margin-top: 12px;
  font-family: monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.param-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.param-row input,
.param-row select {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.param-row input:focus,
.param-row select:focus {
  border-color: #1D9E75;
}

.param-row .param-name { flex: 1; }
.param-row .param-desc { flex: 2; }
.param-row .param-type { width: 100px; }

.param-row label {
  font-size: 12px;
  color: #555;
  display: flex;
  align-items: center;
  gap: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.param-remove {
  background: none;
  border: none;
  color: #ccc;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

.param-remove:hover {
  color: #c0392b;
}

/* ── Providers ───────────────────────────────────────────────────────────── */

.provider-section {
  margin-bottom: 32px;
}

.provider-section-title {
  font-size: 13px;
  font-weight: 500;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.provider-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 8px;
}

.provider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.provider-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.provider-name {
  font-size: 14px;
  font-weight: 500;
  color: #111;
}

.provider-key-mask {
  font-size: 12px;
  color: #aaa;
  font-family: monospace;
}

.key-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
}

.key-dot.has-key {
  background: #1D9E75;
}

.key-dot.no-key {
  background: #ddd;
}

.provider-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.provider-edit-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.provider-edit-form input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
  max-width: 400px;
}

.provider-edit-form input:focus {
  border-color: #1D9E75;
}

/* ── Sections ────────────────────────────────────────────────────────────── */

.section-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 24px 0;
}

.section-title {
  font-size: 15px;
  font-weight: 500;
  color: #111;
  margin-bottom: 16px;
}

/* ── Settings ────────────────────────────────────────────────────────────── */

.system-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.info-label {
  color: #888;
  width: 120px;
  flex-shrink: 0;
}

.info-value {
  color: #333;
}

/* ── Voice Config ────────────────────────────────────────────────────────── */

.voice-form {
  max-width: 480px;
}

.voice-form .form-group {
  margin-bottom: 16px;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 13px;
  color: #333;
  animation: toastIn 0.2s ease-out;
  min-width: 200px;
}

.toast.success {
  border-left: 3px solid #1D9E75;
}

.toast.error {
  border-left: 3px solid #c0392b;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ── Audio Player ────────────────────────────────────────────────────────── */

audio {
  width: 100%;
  max-width: 400px;
  margin: 8px 0;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #aaa;
  font-size: 13px;
}

/* ── Login ────────────────────────────────────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f5f5f5;
}

.login-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
}

.login-header {
  margin-bottom: 24px;
}

.login-error {
  background: #fce8e8;
  color: #c0392b;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.login-btn {
  width: 100%;
  margin-top: 24px;
  padding: 10px;
}

/* ── Logout ───────────────────────────────────────────────────────────────── */

.logout-link {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: #aaa;
  text-decoration: none;
}

.logout-link:hover {
  color: #c0392b;
  text-decoration: none;
}

/* ── Key Reveal ──────────────────────────────────────────────────────────── */

.key-reveal-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 11px;
  cursor: pointer;
  padding: 0 4px;
  font-family: inherit;
}

.key-reveal-btn:hover {
  color: #1D9E75;
}
