/* AI Calling UI — Hospital Care Agent */
:root {
  --bg-deep: #0b0e14;
  --bg-card: #13171f;
  --bg-elevated: #1a1f2a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e6edf5;
  --text-muted: #8b9cb8;
  --text-dim: #5c6b82;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --end-call: #ef4444;
  --end-call-hover: #dc2626;
  --success: #22c55e;
  --radius: 12px;
  --radius-lg: 20px;
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden],
.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 24px;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.login-bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 100% 80% at 50% -20%, rgba(59, 130, 246, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 90% 50%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
    linear-gradient(180deg, #0b0e14 0%, #0f1319 40%, #0b0e14 100%);
}

.login-bg-glow {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(48px);
}

.login-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 56px 56px;
}

.login-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.login-card {
  width: 100%;
  position: relative;
  background: rgba(19, 23, 31, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 36px 32px;
  display: grid;
  gap: 18px;
  backdrop-filter: blur(20px);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.login-card-shine {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  border-radius: 24px 24px 0 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
}

.login-brand {
  text-align: center;
  margin-bottom: 4px;
}

.login-logo-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 16px;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  font-size: 26px;
  background: linear-gradient(145deg, var(--accent), #6366f1);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
  position: relative;
  z-index: 1;
}

.login-logo-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.35);
  animation: login-pulse 2.5s ease-out infinite;
}

@keyframes login-pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  100% { transform: scale(1.15); opacity: 0; }
}

.login-card .login-brand h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff 0%, #e6edf5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-tagline {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 4px 0 2px;
}

.login-card h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.login-card .hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.login-card label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.login-card input {
  padding: 13px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: rgba(11, 14, 20, 0.6);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card input::placeholder {
  color: var(--text-dim);
}

.login-card input:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-card #login-submit {
  margin-top: 6px;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
}

.login-card #login-submit:hover {
  background: linear-gradient(135deg, var(--accent-hover), #4338ca);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.login-card #login-submit:active {
  transform: translateY(0);
}

.login-credit {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
}

.login-credit strong {
  color: var(--text-muted);
  font-weight: 600;
}

.login-error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.8125rem;
}

/* ---------- App: full-screen call layout ---------- */
.call-app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr 340px;
  grid-template-areas:
    "header header"
    "view   sidebar"
    "ctrl   sidebar";
  min-height: 100vh;
}

.call-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.call-bg-gradient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 20%, rgba(59, 130, 246, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 45%);
}

.call-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ---------- Header ---------- */
.call-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1;
}

.call-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1rem;
}

.call-logo {
  width: 32px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  font-size: 14px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  border-radius: 50%;
}

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

.call-purpose-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.call-purpose-select {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.875rem;
  background: var(--bg-card);
  color: var(--text);
  min-width: 200px;
}

.call-purpose-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Center: agent view ---------- */
.call-view {
  grid-area: view;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1;
}

.call-agent-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.call-agent-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.2);
  animation: call-pulse 2.5s ease-out infinite;
}

.call-agent-ring-1 { width: 160px; height: 160px; animation-delay: 0s; }
.call-agent-ring-2 { width: 200px; height: 200px; animation-delay: 0.4s; opacity: 0.6; }

@keyframes call-pulse {
  0% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(1.1); opacity: 0; }
}

.call-agent-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.call-agent-icon {
  font-size: 48px;
}

.call-agent-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.call-status {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  min-height: 1.25em;
}

/* Recording state: subtle glow */
.call-app.recording .call-agent-ring {
  border-color: rgba(34, 197, 94, 0.35);
  animation: call-pulse 1.2s ease-out infinite;
}

.call-app.recording .call-agent-avatar {
  box-shadow: 0 0 32px rgba(34, 197, 94, 0.2);
}

/* ---------- Call controls ---------- */
.call-controls {
  grid-area: ctrl;
  padding: 20px 24px 28px;
  z-index: 1;
}

.call-controls-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.call-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.call-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.call-btn:not(:disabled):hover {
  transform: translateY(-2px);
}

.call-btn-icon {
  font-size: 1.25rem;
}

.call-btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.call-btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, var(--accent-hover), #4338ca);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.call-btn-mic {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.call-btn-mic:not(:disabled):hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}

.call-btn-stop {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.call-btn-stop:not(:disabled):hover {
  background: rgba(234, 179, 8, 0.3);
}

.call-btn-end {
  background: var(--end-call);
  color: #fff;
}

.call-btn-end:hover {
  background: var(--end-call-hover);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.35);
}

/* ---------- Sidebar: conversation + timing ---------- */
.call-sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 1;
  min-width: 0;
}

.call-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.timing {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}

.chat-empty {
  color: var(--text-dim);
  font-size: 0.8125rem;
  padding: 16px;
  text-align: center;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 92%;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-meta {
  font-size: 0.6875rem;
  color: var(--text-dim);
}

.chat-message.user .chat-meta {
  text-align: right;
}

.call-summary {
  font-size: 0.8125rem;
  color: var(--text);
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 12px 12px;
  white-space: pre-wrap;
}

.section-disabled {
  opacity: 0.65;
}

.section-disabled button,
.section-disabled textarea {
  cursor: not-allowed;
}

/* Optional: add .recording to body or .call-app when recording for glow */
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
