@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Kavoon&display=swap');

/* =======================================================
  Svju UI - mobile-first, airy, and task-focused
   ======================================================= */

.font-brand {
  font-family: 'Kavoon', cursive;
}

/* ---------- Reset / base ---------- */

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

:root {
  --bg: #f4f7fb;
  --page-bg:
    radial-gradient(120% 120% at 12% 14%, rgba(14, 165, 233, 0.10), transparent 45%),
    radial-gradient(100% 100% at 88% 0%, rgba(249, 115, 22, 0.08), transparent 50%),
    #f4f7fb;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.94);
  --surface-alt: #f8fafc;
  --muted: #5f6b7a;
  --faint: #e5e7eb;
  --text: #0f172a;
  --primary: #0E132D;
  --primary-strong: #1c244b;
  --accent: #f97316;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-card: 0 10px 26px rgba(15, 23, 42, 0.06);
  --shadow-strong: 0 16px 45px rgba(15, 23, 42, 0.12);
  --max-width: 1200px;
}

[data-theme="dark"] {
  --bg: #0a0a0f;
  --page-bg: radial-gradient(140% 120% at 10% 10%, rgba(56,189,248,0.14), transparent 40%), #05050a;
  --surface: #0f111a;
  --surface-soft: rgba(15, 17, 26, 0.95);
  --surface-alt: #151826;
  --muted: #d8dce7;
  --faint: #202435;
  --text: #f5f7ff;
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --accent: #fb923c;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f87171;
  --shadow-card: 0 10px 26px rgba(0, 0, 0, 0.5);
  --shadow-strong: 0 16px 45px rgba(0, 0, 0, 0.7);
}

a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: var(--primary-strong);
}

:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.45);
  outline-offset: 2px;
  border-radius: 10px;
}

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

.skip-link {
  position: absolute;
  left: 16px;
  top: 14px;
  background: var(--primary);
  color: var(--surface);
  padding: 9px 12px;
  border-radius: 10px;
  z-index: 9999;
  transform: translateY(-120%);
  transition: transform 0.14s ease;
}
.skip-link:focus {
  transform: translateY(0);
}
@media (max-width: 640px) {
  .skip-link {
    display: none;
  }
}

/* ---------- Layout shell ---------- */

.page-shell {
  min-height: 100vh;
  position: relative;
}

.container {
  width: min(var(--max-width), calc(100% - 32px));
  margin: 0 auto;
  padding: 0 4px 0px;
}

.page-content {
  padding-top: 10px;
}

.page-hero {
  background: linear-gradient(140deg, rgba(14,165,233,0.08), rgba(249,115,22,0.06));
  border: 1px solid var(--faint);
  border-radius: 20px;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-card);
  margin: 8px 0 22px;
}

.page-hero h1 {
  margin: 6px 0 4px;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.02em;
}

.page-hero p {
  margin: 0;
  color: var(--muted);
}

[data-theme="dark"] .page-hero {
  background: linear-gradient(140deg, rgba(56,189,248,0.14), rgba(251,146,60,0.10));
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-strong);
  margin: 0;
}

.muted {
  color: var(--muted);
}

.full,
.full-btn {
  width: 100%;
}

.status {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.content-grid-2-col {
  grid-template-columns: repeat(2, 1fr);
}

.content-grid-single-col {
  grid-template-columns: 1fr;
}

#editModal {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  width: 100%;
  max-width: 600px;
  position: relative; /* for z-index stacking if needed */
  z-index: 5001;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
}
.checkbox-label input {
  width: auto;
  margin-top: 0;
}
fieldset {
  border: 1px solid var(--faint);
  border-radius: 12px;
  padding: 8px 12px 12px;
}
legend {
  font-size: 13px;
  font-weight: 600;
  padding: 0 6px;
}

.auth-shell {
  padding-top: 40px;
  padding-bottom: 40px;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
  background: var(--surface-soft);
  backdrop-filter: blur(12px);
  border: 1px solid var(--faint);
}

.auth-card h1 {
  font-size: 32px;
  font-weight: 800;
  margin: 12px 0 8px;
  text-align: center;
  background: linear-gradient(135deg, var(--primary-strong), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-card .eyebrow {
  text-align: center;
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.hero-card {
  background: linear-gradient(145deg, rgba(14,165,233,0.14), rgba(249,115,22,0.12));
  border-color: rgba(14, 165, 233, 0.2);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 8px;
}

.feature-list li {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(14, 165, 233, 0.15);
}

.survey-questions {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.question-row {
  border: 1px solid var(--faint);
  border-radius: 12px;
  padding: 10px;
  background: var(--surface-alt);
}
.options-row {
  margin-top: 8px;
}

.survey-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tab-bar {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 12px;
}
.tab-btn {
  border: 1px solid var(--faint);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.tab-btn.active {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(14, 165, 233, 0.4);
}
.tab-section.hidden {
  display: none;
}

/* ---------- Top navigation ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 12px 0;
}

.topnav-surface {
  background: var(--surface-soft);
  border: 1px solid var(--faint);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
}

.topnav-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 10px 14px;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topnav-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.topnav-links a {
  padding: 9px 13px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.topnav-links a:hover {
  color: var(--text);
  background: rgba(14, 165, 233, 0.08);
}
.topnav-links a.active {
  background: linear-gradient(130deg, rgba(14,165,233,0.16), rgba(249,115,22,0.14));
  color: var(--text);
  border-color: rgba(14, 165, 233, 0.22);
}

.topnav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--faint);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.desktop-only {
  display: flex;
}

@media (max-width: 640px) {
  .desktop-only {
    display: none;
  }
}

#navUser {
  border-radius: 999px;
  border: 1px solid var(--faint);
  padding: 8px 14px;
  font-size: 13px;
  background: var(--surface-alt);
  color: var(--text);
}
#navUser::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #16a34a;
  display: inline-flex;
  margin-right: 8px;
}

/* Session status color indicators for agent view */
.status-waiting_link {
  color: var(--surface);
  background: var(--danger);
  padding: 6px 10px;
  border-radius: 10px;
}
.status-waiting_for_terms {
  color: var(--surface);
  background: var(--warning);
  padding: 6px 10px;
  border-radius: 10px;
}
.status-waiting_for_video {
  color: var(--surface);
  background: var(--primary-strong);
  padding: 6px 10px;
  border-radius: 10px;
}
.status-customer_joined {
  color: var(--surface);
  background: var(--success);
  padding: 6px 10px;
  border-radius: 10px;
}

#mobileMenuBtn {
  display: none;
  height: 38px;
  width: 44px;
  border-radius: 12px;
  border: 1px solid var(--faint);
  background: var(--surface-alt);
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
}

#mobileMenuBtn span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  margin: 4px 0;
  border-radius: 4px;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100%;
  background: var(--surface);
  box-shadow: -4px 0 26px rgba(15, 23, 42, 0.28);
  padding: 20px 18px;
  transition: transform 0.28s ease, right 0.28s ease;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mobile-drawer.open {
  right: 0;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-links a {
  display: block;
  padding: 12px 10px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  border: 1px solid var(--faint);
  margin-bottom: 6px;
  background: var(--surface);
}
.drawer-links a:hover {
  border-color: rgba(14, 165, 233, 0.24);
  background: rgba(14, 165, 233, 0.06);
}
.drawer-links a.active {
  background: linear-gradient(130deg, rgba(14,165,233,0.14), rgba(249,115,22,0.10));
  border-color: rgba(14, 165, 233, 0.3);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 9998;
}
.drawer-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--faint);
  padding: 18px 18px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
}

.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.card p.small,
.small {
  font-size: 13px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.1);
  color: var(--primary-strong);
  font-weight: 600;
  font-size: 12px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 11px;
}

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

label {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--faint);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-alt);
  transition: all 0.12s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(14, 165, 233, 0.5);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
  background: var(--surface);
  outline: none;
}

textarea {
  resize: vertical;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.checkbox-inline input {
  width: auto;
  flex-shrink: 0;
}
.checkbox-inline span {
  display: inline-block;
}

.form-row,
.form-grid,
.two-col {
  display: grid;
  gap: 14px;
}

.form-row {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.two-col {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.form-grid-users .form-button-inline {
  display: flex;
  align-items: flex-end;
}
.form-grid-users .form-button-inline button {
  width: 100%;
}

@media (min-width: 1024px) {
  .form-grid-users {
    grid-template-columns: 1fr 1fr 1fr 1fr auto !important;
    align-items: end;
  }
  .form-grid-users .form-button-inline button {
    width: auto;
    min-width: 44px;
  }
}

/* ---------- Buttons ---------- */

button,
button[type='submit'],
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(130deg, var(--primary), var(--primary-strong));
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.35);
  transition: transform 0.1s ease, box-shadow 0.12s ease, opacity 0.1s ease;
  min-height: 44px;
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-strong);
}

button:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-secondary {
  background: #0f172a;
  color: #ffffff;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--faint);
  box-shadow: none;
}

.btn-quiet {
  background: transparent;
  border: 1px solid var(--faint);
  color: var(--text);
  box-shadow: none;
}

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

.table-wrapper {
  margin-top: 12px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--faint);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}

thead {
  background: var(--surface-alt);
}

thead th {
  text-align: left;
  font-weight: 700;
  padding: 12px 14px;
  color: var(--muted);
}

tbody tr {
  border-bottom: 1px solid #f1f5f9;
}

tbody tr:nth-child(even) {
  background: var(--surface-alt);
}

tbody tr:hover {
  background: rgba(14, 165, 233, 0.06);
}

td {
  padding: 12px 14px;
  color: var(--text);
}

.row-selected {
  background: rgba(14, 165, 233, 0.12) !important;
}

/* ---------- Metrics ---------- */

.metrics-grid,
.history-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

.metric-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
}

/* ---------- Agent layout ---------- */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.agent-session-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr);
  gap: 16px;
  align-items: start;
  /* Constrain height to prevent scrolling for tall videos */
  max-height: calc(100vh - 120px);
  overflow: hidden; /* Hide any overflow within the layout */
}

/* Enable independent scrolling for columns */
.agent-session-layout > * {
  max-height: 100%;
  overflow-y: auto;
}

.video-wrapper {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: #0b1224;
  box-shadow: var(--shadow-strong);
  /* Ensure wrapper takes full height of grid cell and centers content */
  min-height: 420px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrapper video {
  width: 100%; /* Make video take 100% width of its container */
  height: auto; /* Maintain aspect ratio */
  max-height: 100%; /* Ensure it fits vertically within its container */
  display: block;
  background: #000;
  object-fit: contain; /* Scale video to fit, adding letterboxing if needed */
}

.video-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-layer.inactive {
  display: none;
}

#highlightCanvas {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.01); /* subtle visible background for drawing */
  z-index: 1000;
}

.agent-page #highlightCanvas {
  pointer-events: auto;
}

.fullpage #highlightCanvas {
  pointer-events: none;
}

.draw-hint {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7eb;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 2;
}

.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.screenshot-grid img {
  width: 100%;
  border-radius: 10px;
  box-shadow: var(--shadow-card);
}

.table-card {
  border: 1px solid var(--faint);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.annotator-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
}
.annotator-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}
.annotator-modal {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--faint);
  border-radius: 16px;
  box-shadow: var(--shadow-strong);
  max-width: 900px;
  width: min(92%, 940px);
  /* Fix for tall images: constrain modal height */
  max-height: 95vh;
  margin: 20px auto; /* reduced top margin */
  padding: 16px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.annotator-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.annotator-canvas-wrap {
  position: relative;
  /* Shrink to fit image so canvas aligns perfectly */
  width: fit-content;
  margin: 0 auto;
  overflow: hidden; /* clip borders */
}
.annotator-canvas-wrap img {
  /* Constrain image height so buttons stay visible */
  max-height: 75vh;
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  border-radius: 12px;
}
.annotator-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.annotator-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---------- Customer / survey ---------- */

.fullpage {
  background: var(--bg);
}

.privacy-box {
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  margin: 20px auto;
  max-width: 820px;
}

.privacy-box ul {
  padding-left: 20px;
}

.fullscreen-customer {
  background: #0b1224;
  color: #e5e7eb;
}

.fullscreen-video-area {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 80% 20%, rgba(14,165,233,0.10), transparent 46%),
    radial-gradient(120% 120% at 20% 80%, rgba(249,115,22,0.08), transparent 50%),
    #010915;
  min-height: 420px;
}

.fullscreen-video-area video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fullscreen-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.customer-preview {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
}
.customer-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.customer-preview-card {
  position: relative;
  width: min(92vw, 620px);
  max-height: 86vh;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--faint);
  border-radius: 16px;
  box-shadow: var(--shadow-strong);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.customer-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--faint);
}
.customer-preview-body {
  padding: 10px;
  display: grid;
  place-items: center;
}
.customer-preview img {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

.customer-overlay-bar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(10, 15, 30, 0.65);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px) saturate(120%);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  color: #e5e7eb;
  padding: 12px 14px;
  border-radius: 12px;
}

.customer-overlay-bar button {
  width: auto;
  background: transparent;
  box-shadow: none;
  border-color: rgba(255,255,255,0.2);
  color: #e5e7eb;
}
.customer-overlay-bar button:hover {
  background: rgba(255,255,255,0.08);
}

@media (max-width: 640px) {
  .customer-preview-card {
    width: 92vw;
    max-height: 88vh;
  }
  .customer-preview img {
    max-height: 64vh;
  }
  .customer-chat {
    width: 90vw;
    height: 70%;
    left: 5vw;
    right: auto;
  }
  .customer-chat-input input,
  .customer-chat-input button {
    font-size: 15px;
  }
  #customerScreenshotStrip img {
    width: 48px !important;
    height: 36px !important;
  }
}

.customer-chat {
  position: absolute;
  top: 14px;
  right: 10px;
  width: min(420px, 80vw);
  min-width: 260px;
  max-width: 520px;
  height: 72%;
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--faint);
}

/* Agent overlay specifics (reuse customer-overlay-bar layout) */
.agent-overlay-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.agent-overlay-actions .btn-ghost,
.agent-overlay-actions select {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  color: #e5e7eb;
  padding: 8px 10px;
  border-radius: 10px;
}
.agent-overlay-actions select {
  min-width: 92px;
}

/* Tool buttons for drawing modes */
.tool-group {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04); /* Match previous hover state */
  color: #e5e7eb;
  cursor: pointer;
}
.tool-btn svg { display: block; }
.tool-btn:hover { background: rgba(255,255,255,0.04); } /* Hover same as default non-active */
.tool-btn.active {
  background: linear-gradient(90deg, rgba(14,165,233,0.18), rgba(249,146,60,0.12));
  border-color: rgba(14,165,233,0.34);
  color: #fff;
  box-shadow: 0 6px 18px rgba(14,165,233,0.12);
}
.customer-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--faint);
}
.customer-chat-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}
.customer-chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--faint);
  background: var(--surface-alt);
}
.customer-chat-message {
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(14, 165, 233, 0.1);
}
.customer-chat-message.agent {
  background: rgba(251, 146, 60, 0.12);
  text-align: right;
}

.rating-emoji {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.rating-emoji label {
  display: grid;
  place-items: center;
  padding: 8px 0;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--faint);
  font-size: 20px;
  cursor: pointer;
}
.rating-emoji label:has(input:checked) {
  border-color: rgba(14, 165, 233, 0.6);
  background: rgba(14, 165, 233, 0.12);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.22);
}
.rating-emoji input {
  display: none;
}
.rating-emoji label:hover {
  border-color: rgba(14, 165, 233, 0.4);
  background: rgba(14, 165, 233, 0.08);
}
.rating-emoji .emoji {
  display: grid;
  place-items: center;
  width: 100%;
  border-radius: 10px;
  border: 1px solid transparent;
}
.rating-emoji input:checked + .emoji {
  border-color: rgba(14, 165, 233, 0.6);
  background: rgba(14, 165, 233, 0.12);
}

/* ---------- Utilities ---------- */

.tight {
  margin-bottom: 4px;
}

.mt-8 {
  margin-top: 18px;
}

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

.page-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-messages {
  border: 1px solid var(--faint);
  border-radius: 12px;
  min-height: 160px;
  max-height: 260px;
  padding: 10px;
  overflow-y: auto;
  background: var(--surface-alt);
}
.chat-message {
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(14, 165, 233, 0.08);
}
.chat-message.customer {
  background: rgba(251, 146, 60, 0.12);
}
.chat-meta {
  font-size: 11px;
  color: var(--muted);
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

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

@media (max-width: 1024px) {
  .topnav-links {
    display: none;
  }
  #mobileMenuBtn {
    display: inline-flex;
  }
  .page-hero {
    flex-direction: column;
  }
  .agent-session-layout {
    grid-template-columns: 1fr;
  }
  /* Agent video on mobile/tablet should not be huge fixed height */
  .video-wrapper {
    min-height: 300px; 
    aspect-ratio: 16/9;
    height: auto;
  }
  /* Allow body scroll on agent page mobile if content overflows */
  .agent-session-layout {
    max-height: none; 
    overflow: visible;
  }
  .agent-session-layout > * {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 768px) {
  .container {
    width: calc(100% - 24px);
  }
  table {
    min-width: 540px;
  }
  .content-grid {
    grid-template-columns: 1fr;
  }
  .page-hero {
    padding: 16px;
  }
  .card button,
  .card .btn,
  .auth-card button,
  .auth-card .btn,
  .full-btn {
    width: 100%;
  }
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .privacy-box {
    padding: 18px 16px;
  }
  .auth-card {
    padding: 24px 20px; /* reduced padding for mobile auth */
  }
  .auth-card h1 {
    font-size: 26px;
  }
}

@media (max-width: 520px) {
  body {
    background: var(--bg);
  }
  .topnav {
    position: static;
  }
  .topnav-inner {
    padding: 10px 12px;
  }
  .page-hero h1 {
    font-size: 22px;
  }
  .rating-emoji {
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  }
}

/* Safe Area Insets for Mobile */
body {
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-drawer {
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  padding-top: calc(20px + env(safe-area-inset-top));
}
.customer-overlay-bar {
  bottom: calc(14px + env(safe-area-inset-bottom));
}
.customer-chat {
  bottom: calc(86px + env(safe-area-inset-bottom)); /* Push chat up to avoid overlap */
}

/* ---------- Customer fullscreen tweaks ---------- */
/* When customer enters fullscreen-customer mode make the video area fill the viewport */
.fullscreen-customer .page-content {
  padding: 0;
}
.fullscreen-customer .fullscreen-video-area {
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
  overflow: hidden;
}
.fullscreen-customer .fullscreen-video-area video,
.fullscreen-customer .fullscreen-video {
  height: 100vh;
  object-fit: cover;
}

/* Make chat visually part of the video by using a translucent background */
.fullscreen-customer .customer-chat {
  background: rgba(0,0,0,0.28);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  backdrop-filter: blur(6px) saturate(120%);
  color: var(--surface);
  border-radius: 12px 0 0 12px;
  box-shadow: none;
  border: none;
  /* leave space at bottom so overlay bar is visible */
  top: 12px;
  right: 0;
  bottom: 86px; /* matches space for .customer-overlay-bar */
  height: auto;
  width: 34%;
  min-width: 260px;
  max-width: 480px;
}
.fullscreen-customer .customer-chat-header,
.fullscreen-customer .customer-chat-input {
  background: transparent;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.fullscreen-customer .customer-chat-message {
  background: rgba(255,255,255,0.06);
  color: var(--surface);
}

@media (max-width: 768px) {
  .fullscreen-customer .customer-chat {
    width: 66%;
    bottom: 110px; /* provide extra bottom gap on small screens */
  }
}
