/* app.css — Callion dashboard styles (extends theme.css variables) */

/* ─── Reset & base (duplicated from theme so pages work standalone) ─── */
:root {
  --bg: #0a0a0f;
  --bg-subtle: #12121a;
  --fg: #f0f0f5;
  --fg-muted: #8a8a9a;
  --accent: #00d4aa;
  --accent-dim: #00a080;
  --accent-glow: rgba(0, 212, 170, 0.15);
  --card-bg: #16161f;
  --card-border: #222230;
  --radius: 16px;
  --radius-sm: 8px;
  --danger: #ff4d6d;
  --danger-glow: rgba(255, 77, 109, 0.15);
  --warning: #f59e0b;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.15;
}

a { color: inherit; text-decoration: none; }

/* ─── Layout shell ─── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  padding: 0 24px 28px;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo .logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-muted);
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--fg);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
}

.back-to-landing {
  font-size: 0.8rem;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

.back-to-landing:hover { color: var(--accent); }

/* ─── Main content ─── */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 40px 48px;
  min-height: 100vh;
}

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

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--accent-dim);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover {
  border-color: var(--fg-muted);
  background: rgba(255,255,255,0.03);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--card-border);
}
.btn-danger:hover {
  border-color: var(--danger);
  background: var(--danger-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--fg); }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* ─── Form controls ─── */
.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.form-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8a9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-select option { background: var(--card-bg); }

.form-hint {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin-top: 6px;
}

/* ─── Card ─── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
}

.card-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--card-border);
}
.card-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

/* ─── Agent list ─── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.agent-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.agent-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

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

.agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--bg);
  flex-shrink: 0;
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}

.agent-status.active {
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.agent-status.inactive {
  background: rgba(255,255,255,0.04);
  color: var(--fg-muted);
  border: 1px solid var(--card-border);
}

.agent-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.agent-status.active .agent-status-dot {
  animation: pulse 2s infinite;
}

.agent-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.agent-mission {
  font-size: 0.82rem;
  color: var(--fg-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
}

.agent-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

.agent-tone-tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.05);
  color: var(--fg-muted);
  border: 1px solid var(--card-border);
  text-transform: capitalize;
}

.agent-call-count {
  font-size: 0.78rem;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--fg-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 0.9rem;
  max-width: 380px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

/* ─── Toast / alerts ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 0.875rem;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--accent-dim); }
.toast.error { border-color: var(--danger); }

/* ─── Call demo ─── */
.call-demo-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  height: calc(100vh - 120px);
  max-height: 700px;
}

.call-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.call-agent-display {
  text-align: center;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 20px;
}

.call-agent-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--bg);
  margin: 0 auto 12px;
  box-shadow: 0 0 32px var(--accent-glow);
}

.call-agent-name-lg {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.call-agent-tone {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-transform: capitalize;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(255,255,255,0.05);
  display: inline-block;
}

.call-status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 12px;
}

.call-status-indicator.idle { color: var(--fg-muted); }
.call-status-indicator.calling { color: var(--accent); }

.call-status-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.call-status-wave span {
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}
.call-status-wave span:nth-child(1) { height: 6px; animation-delay: 0s; }
.call-status-wave span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.call-status-wave span:nth-child(3) { height: 16px; animation-delay: 0.2s; }
.call-status-wave span:nth-child(4) { height: 12px; animation-delay: 0.3s; }
.call-status-wave span:nth-child(5) { height: 6px; animation-delay: 0.4s; }
@keyframes wave { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(0.3); } }

.call-info-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.call-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.call-info-label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.call-info-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.4;
}

.call-controls {
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}

/* Chat window */
.chat-window {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-phone-badge {
  font-size: 0.75rem;
  color: var(--fg-muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  padding: 3px 10px;
  border-radius: 100px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 4px; }

.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: msgIn 0.25s ease-out;
}

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

.chat-msg.agent { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-msg.agent .chat-msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--bg);
}

.chat-msg.user .chat-msg-avatar {
  background: rgba(255,255,255,0.1);
  color: var(--fg);
  font-family: 'Space Grotesk', sans-serif;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: 100%;
}

.chat-msg.agent .chat-msg-bubble {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-top-left-radius: 4px;
  color: var(--fg);
}

.chat-msg.user .chat-msg-bubble {
  background: var(--accent);
  color: var(--bg);
  border-top-right-radius: 4px;
}

.chat-msg-time {
  font-size: 0.7rem;
  color: var(--fg-muted);
  margin-top: 4px;
  text-align: right;
}

.chat-msg.agent .chat-msg-time { text-align: left; }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  border-top-left-radius: 4px;
  display: none;
}

.typing-indicator.visible { display: inline-flex; }

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-muted);
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%,80%,100% { transform: scale(0.7); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

.chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--card-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 10px 14px;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.chat-input:focus { border-color: var(--accent-dim); }
.chat-input::placeholder { color: var(--fg-muted); }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 16px;
}

.chat-send-btn:hover { background: var(--accent-dim); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Status toggle ─── */
.status-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.85rem;
}

.status-toggle:hover { border-color: var(--accent-dim); }

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--card-border);
  border-radius: 100px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch.on { background: var(--accent); }

.toggle-knob {
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch.on .toggle-knob { transform: translateX(16px); }

/* ─── Config page ─── */
.config-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.config-form { }

.config-preview {
  position: sticky;
  top: 40px;
}

.preview-phone {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
}

.preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 16px;
}

.mini-phone {
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 24px;
  border: 2px solid var(--card-border);
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4), 0 0 40px var(--accent-glow);
}

.mini-phone-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--bg);
  margin: 0 auto 10px;
}

.mini-phone-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.mini-phone-tone {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: capitalize;
}

.mini-phone-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 24px;
  margin-top: 12px;
}

.mini-phone-wave span {
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.7;
  animation: wave 1.2s ease-in-out infinite;
}
.mini-phone-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
.mini-phone-wave span:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.mini-phone-wave span:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.mini-phone-wave span:nth-child(4) { height: 14px; animation-delay: 0.3s; }
.mini-phone-wave span:nth-child(5) { height: 8px; animation-delay: 0.4s; }

/* ─── Breadcrumb ─── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin-bottom: 20px;
}

.breadcrumb-sep { opacity: 0.4; }
.breadcrumb-current { color: var(--fg); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 24px 20px; }
  .config-layout { grid-template-columns: 1fr; }
  .call-demo-layout { grid-template-columns: 1fr; height: auto; }
  .call-panel { min-height: auto; }
}
