/* Admin dashboard styles — builds on the token classes in globals.css. */

.admin-shell {
  display: flex;
  min-height: 100vh;
  background: var(--surface-low);
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
}

.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--on-surface-variant);
  font-weight: 600;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 26px;
  margin: 0;
}

.page-head .page-sub {
  margin: 4px 0 0;
  color: var(--on-surface-variant);
  font-size: 14px;
}

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

/* ---------- Grids ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

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

.section {
  margin-bottom: 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
}

.card h2,
.card h3 {
  font-size: 16px;
}

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: #fff;
  border: 1px solid var(--surface-highest);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.filter-bar .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

.filter-bar .field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-variant);
}

.filter-bar .input,
.filter-bar select.input {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 14px;
}

.filter-bar .check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  min-height: 38px;
  color: var(--on-surface);
}

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  flex-wrap: wrap;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 4px 12px;
}

.lang-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 4px 2px;
  cursor: pointer;
}

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

.topic-row .input {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 14px;
}

.btn-small {
  min-height: 34px;
  padding: 4px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-danger {
  background: transparent;
  color: var(--error);
  border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
  background: #ffe1e1;
}

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-container) 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--surface-highest);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 34px 30px;
}

.login-brand {
  margin-bottom: 22px;
}

.login-brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 12px;
}

.login-card .field-block {
  margin-bottom: 14px;
}

/* ---------- Knowledge workspace ---------- */

.dropzone {
  border: 2px dashed var(--outline-variant);
  border-radius: var(--radius);
  background: #fff;
  padding: 30px 20px;
  text-align: center;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.dropzone.drag {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.dropzone strong {
  color: var(--on-surface);
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
}

.upload-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  flex: 1;
  max-width: 220px;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-high);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--secondary);
  transition: width 150ms ease;
}

.file-type-badge {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-container);
  color: var(--on-surface-variant);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  vertical-align: middle;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-highest);
  transition: background-color 120ms ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform 120ms ease;
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(16px);
}

/* ---------- Test-the-agent panel ---------- */

.test-panel {
  display: flex;
  flex-direction: column;
  height: 480px;
}

.test-panel .messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
  background: var(--surface-low);
  border-radius: 10px;
  margin-bottom: 12px;
}

.test-panel .composer {
  display: flex;
  gap: 8px;
}

.test-note {
  font-size: 12px;
  color: var(--on-surface-variant);
  background: var(--secondary-soft);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 10px;
}

.source-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.source-list li {
  padding: 4px 8px;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--surface-highest);
  border-radius: 8px;
  color: var(--on-surface-variant);
}

.source-list .src-file {
  font-weight: 700;
  color: var(--on-surface);
}

/* ---------- QR panel ---------- */

.qr-box {
  text-align: center;
}

.qr-box img {
  width: 200px;
  height: 200px;
  border: 1px solid var(--surface-highest);
  border-radius: 12px;
  background: #fff;
}

.qr-url {
  font-size: 12px;
  color: var(--on-surface-variant);
  word-break: break-all;
  margin: 8px 0 12px;
}

/* ---------- Lead detail ---------- */

.detail-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

.kv dt {
  color: var(--on-surface-variant);
  font-weight: 600;
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.transcript {
  max-height: 560px;
  overflow-y: auto;
  padding: 4px;
}

.consent-box {
  background: #dcf1de;
  color: #1c5e26;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
}

.consent-box.no {
  background: #ffe1e1;
  color: var(--error);
}

/* ---------- Tables ---------- */

.row-link {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.row-link:hover {
  text-decoration: underline;
  color: var(--primary);
}

.cell-clip {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  font-size: 13px;
  color: var(--on-surface-variant);
}

.empty-state {
  padding: 36px 16px;
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 14px;
}

.form-error {
  background: #ffe1e1;
  color: var(--error);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 14px;
}

.form-ok {
  background: #dcf1de;
  color: #1c5e26;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 14px;
}

/* ---------- Chart cards ---------- */

.chart-card svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .admin-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: 0;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 12px;
  }

  .sidebar-brand {
    padding: 4px 8px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-footer {
    border-top: none;
    padding: 4px 8px;
  }

  .admin-main {
    padding: 18px 14px 40px;
  }

  .two-col,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

