@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300..700&family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Vazirmatn:wght@400;500;600;700&display=swap");

:root {
  --bg: #07090e;
  --panel: #0c1018;
  --panel-2: #111820;
  --surface: #161d28;
  --surface-2: #1c2535;
  --line: #1e2a3a;
  --border: #253347;
  --text: #e2e8f0;
  --muted: #64748b;
  --muted-2: #8898aa;

  --patient: #3b82f6;
  --patient-glow: rgba(59, 130, 246, 0.32);
  --patient-dim: rgba(59, 130, 246, 0.1);

  --clinician: #10b981;
  --clinician-glow: rgba(16, 185, 129, 0.32);
  --clinician-dim: rgba(16, 185, 129, 0.1);

  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.38);

  --processing: #8b5cf6;
  --processing-glow: rgba(139, 92, 246, 0.38);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Topbar ───────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: rgba(12, 16, 24, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.brand-title {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
}

.brand-sub {
  font-size: 0.71rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 1px;
}

.topbar-hint {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ── Main layout ──────────────────────────────────── */

.main {
  width: min(960px, calc(100% - 2rem));
  margin: 1.75rem auto 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* ── Speaker grid ─────────────────────────────────── */

.speakers-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* ── Speaker cards ────────────────────────────────── */

.speaker-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.3rem 1.3rem 1.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* Accent stripe at the top of each card */
.speaker-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 20px 20px 0 0;
}

/* Subtle colored glow from the bottom (behind the button) */
.speaker-card::after {
  content: "";
  position: absolute;
  bottom: -30px; left: 50%;
  translate: -50% 0;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  pointer-events: none;
}

.patient-card::before { background: linear-gradient(90deg, var(--patient), transparent 70%); }
.patient-card::after  { background: radial-gradient(circle, var(--patient-dim) 0%, transparent 70%); }

.clinician-card::before  { background: linear-gradient(90deg, var(--clinician), transparent 70%); }
.clinician-card::after   { background: radial-gradient(circle, var(--clinician-dim) 0%, transparent 70%); }

/* Card header row */
.card-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.role-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 1rem;
}

.role-icon { font-size: 1.05rem; }

.patient-badge { color: var(--patient); }
.clinician-badge  { color: var(--clinician); }

/* Language picker */
.lang-picker {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.18rem;
  cursor: pointer;
}

.lang-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.lang-picker select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.lang-picker select:focus { border-color: var(--muted-2); }

/* Direction badge */
.direction-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: var(--muted-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  margin-bottom: 1.3rem;
}

/* ── PTT Button ───────────────────────────────────── */

.btn-wrap {
  position: relative;
  z-index: 1;
}

.ptt-btn {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font: inherit;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.ptt-btn.patient {
  background: radial-gradient(circle at 38% 32%, #60a5fa, var(--patient) 70%);
  box-shadow:
    0 0 0 10px var(--patient-dim),
    0 10px 30px rgba(0, 0, 0, 0.45);
}

.ptt-btn.clinician {
  background: radial-gradient(circle at 38% 32%, #34d399, var(--clinician) 70%);
  box-shadow:
    0 0 0 10px var(--clinician-dim),
    0 10px 30px rgba(0, 0, 0, 0.45);
}

.ptt-btn:hover {
  transform: translateY(-3px) scale(1.03);
}

.ptt-btn.patient:hover {
  box-shadow:
    0 0 0 16px var(--patient-dim),
    0 14px 36px rgba(0, 0, 0, 0.5);
}

.ptt-btn.clinician:hover {
  box-shadow:
    0 0 0 16px var(--clinician-dim),
    0 14px 36px rgba(0, 0, 0, 0.5);
}

.ptt-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Recording state */
.ptt-btn.recording {
  background: radial-gradient(circle at 38% 32%, #f87171, var(--danger) 70%) !important;
  box-shadow:
    0 0 0 14px var(--danger-glow),
    0 10px 30px rgba(0, 0, 0, 0.45) !important;
  transform: scale(1.06) !important;
  animation: pulse-glow 1.1s ease-in-out infinite;
}

/* Processing state */
.ptt-btn.processing {
  background: radial-gradient(circle at 38% 32%, #a78bfa, var(--processing) 70%) !important;
  box-shadow:
    0 0 0 14px var(--processing-glow),
    0 10px 30px rgba(0, 0, 0, 0.45) !important;
}

.ptt-btn.processing .btn-label { opacity: 0; }

.ptt-btn.processing::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #fff;
  animation: spin 0.72s linear infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 12px var(--danger-glow), 0 10px 30px rgba(0,0,0,0.45); }
  50%       { box-shadow: 0 0 0 24px rgba(239, 68, 68, 0.08), 0 10px 30px rgba(0,0,0,0.45); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Conversation ──────────────────────────────────── */

.history-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.1rem 1.3rem 1.3rem;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.history-title {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 7px;
  padding: 0.3rem 0.72rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.clear-btn:hover {
  border-color: var(--muted-2);
  color: var(--text);
}

.history {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.history:empty::after {
  content: "Conversation will appear here.";
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2.5rem 0;
}

/* Scrollbar */
.history::-webkit-scrollbar { width: 4px; }
.history::-webkit-scrollbar-track { background: transparent; }
.history::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Bubbles ───────────────────────────────────────── */

.bubble {
  max-width: min(72ch, 94%);
  padding: 0.72rem 0.9rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: slide-up 0.22s ease;
}

.bubble.patient {
  align-self: flex-start;
  border-left: 3px solid var(--patient);
}

.bubble.clinician {
  align-self: flex-end;
  border-right: 3px solid var(--clinician);
}

.bubble .meta {
  font-size: 0.71rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}

.bubble.patient .meta { color: color-mix(in srgb, var(--patient) 65%, var(--muted-2)); }
.bubble.clinician  .meta { color: color-mix(in srgb, var(--clinician)  65%, var(--muted-2)); }

.bubble .text {
  font-size: 0.92rem;
  line-height: 1.57;
  color: var(--text);
}

.bubble .text + .text {
  margin-top: 0.38rem;
  padding-top: 0.38rem;
  border-top: 1px solid var(--line);
}

.text .fa {
  direction: rtl;
  unicode-bidi: plaintext;
  display: inline;
  font-size: 0.97rem;
  font-family: "Vazirmatn", "Noto Naskh Arabic", "Tahoma", sans-serif;
}

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

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-size: 0.84rem;
  max-width: 300px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 600px) {
  .topbar-hint { display: none; }

  .main {
    width: calc(100% - 1rem);
    margin: 1rem auto 2.5rem;
  }

  .speakers-grid { grid-template-columns: 1fr; }

  .ptt-btn {
    width: 132px;
    height: 132px;
  }
}
