/* ═══════════════════════════════════════════════
   PLIVO VOICE AGENT — PREMIUM DASHBOARD STYLES
   ═══════════════════════════════════════════════ */

/* ── Reset & Foundations ───────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg:          #0a0a0f;
  --bg-card:     rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.055);
  --border:      rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-dim:    #475569;
  --accent-1:    #6366f1;
  --accent-2:    #a855f7;
  --accent-3:    #ec4899;
  --success:     #22c55e;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --radius:      16px;
  --radius-sm:   10px;
  --radius-xs:   8px;
  --blur:        20px;
  --transition:  .25s cubic-bezier(.4,0,.2,1);
  --gradient:    linear-gradient(135deg, var(--accent-1), var(--accent-2), var(--accent-3));
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Background Textures ──────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}

.bg-glow {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .12;
  pointer-events: none;
}
.bg-glow--1 {
  width: 600px;
  height: 600px;
  top: -200px;
  left: -100px;
  background: var(--accent-1);
}
.bg-glow--2 {
  width: 500px;
  height: 500px;
  bottom: -200px;
  right: -100px;
  background: var(--accent-3);
}

/* ── Animations ───────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(1.6); }
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,.0); }
  50%      { box-shadow: 0 0 30px 4px rgba(99,102,241,.18); }
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

.fade-in {
  opacity: 0;
  animation: fadeInUp .6s var(--transition) forwards;
}
.fade-in[data-delay="1"] { animation-delay: .08s; }
.fade-in[data-delay="2"] { animation-delay: .16s; }
.fade-in[data-delay="3"] { animation-delay: .24s; }
.fade-in[data-delay="4"] { animation-delay: .32s; }

/* ── Navbar ───────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, .7);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  height: 64px;
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar__logo svg {
  width: 34px;
  height: 34px;
  display: block;
}

.navbar__title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.navbar__status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.18);
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--success);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  position: relative;
}
.status-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

/* ── Dashboard Grid ───────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 28px auto 0;
  padding: 0 28px 40px;
}

.dashboard__left,
.dashboard__right {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Card ─────────────────────────────────── */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,.08), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.card--tall {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 340px;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 0;
}

.card__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}
.card__title svg {
  opacity: .5;
  flex-shrink: 0;
}

.card__body {
  padding: 18px 22px 22px;
}
.card__body--scroll {
  flex: 1;
  overflow-y: auto;
  padding-top: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.card__body--scroll::-webkit-scrollbar {
  width: 5px;
}
.card__body--scroll::-webkit-scrollbar-track {
  background: transparent;
}
.card__body--scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.08);
  border-radius: 10px;
}

/* ── Stats Row ────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
}

.stat-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-card__icon--calls {
  background: rgba(99,102,241,.12);
  color: var(--accent-1);
}
.stat-card__icon--active {
  background: rgba(34,197,94,.12);
  color: var(--success);
}
.stat-card__icon--duration {
  background: rgba(168,85,247,.12);
  color: var(--accent-2);
}

.stat-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-card__value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
}

.stat-card__label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Active card breathing glow */
.active-glow {
  position: absolute;
  inset: -1px;
  border-radius: var(--radius);
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s;
}
#active-card.has-active .active-glow {
  opacity: 1;
  animation: breathe 3s ease-in-out infinite;
}
#active-card.has-active {
  border-color: rgba(34,197,94,.2);
}

/* ── Input Styles ─────────────────────────── */
.input-group {
  margin-bottom: 16px;
}

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

.input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input::placeholder {
  color: var(--text-dim);
}
.input:focus {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15), 0 0 20px rgba(99,102,241,.08);
  background: rgba(255,255,255,.06);
}

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

.input-phone {
  display: flex;
  align-items: stretch;
}
.input-phone__prefix {
  display: grid;
  place-items: center;
  padding: 0 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.input-phone .input {
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* ── Buttons ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 24px;
  border: none;
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  position: relative;
  overflow: hidden;
}
.btn:active {
  transform: scale(.97);
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

.btn--primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 20px rgba(99,102,241,.25), 0 1px 3px rgba(0,0,0,.3);
}
.btn--primary:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 8px 32px rgba(99,102,241,.35), 0 2px 6px rgba(0,0,0,.3);
}
.btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.15), transparent 60%);
  pointer-events: none;
}

.btn--secondary {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.btn--secondary:hover:not(:disabled) {
  background: rgba(255,255,255,.1);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* ── Status Messages ──────────────────────── */
.call-status,
.config-status {
  margin-top: 14px;
  padding: 0;
  font-size: .82rem;
  font-weight: 500;
  min-height: 20px;
  transition: all var(--transition);
  border-radius: var(--radius-xs);
}
.call-status:empty,
.config-status:empty {
  display: none;
}
.call-status.success, .config-status.success {
  display: block;
  padding: 10px 14px;
  color: var(--success);
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.15);
}
.call-status.error, .config-status.error {
  display: block;
  padding: 10px 14px;
  color: var(--danger);
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.15);
}
.call-status.loading, .config-status.loading {
  display: block;
  padding: 10px 14px;
  color: var(--text-muted);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
}

/* ── Badge ────────────────────────────────── */
.badge {
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: var(--text-muted);
  border: 1px solid var(--border);
  letter-spacing: .02em;
}
.badge--live {
  font-size: .68rem;
}
.badge--live.connected {
  background: rgba(34,197,94,.1);
  color: var(--success);
  border-color: rgba(34,197,94,.2);
}
.badge--live.disconnected {
  background: rgba(239,68,68,.08);
  color: var(--danger);
  border-color: rgba(239,68,68,.15);
}

/* ── Live Dot ─────────────────────────────── */
.live-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  display: inline-block;
  animation: livePulse 1.5s ease-in-out infinite;
}

/* ── Call Log Items ───────────────────────── */
.call-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  position: relative;
}
.call-item:nth-child(odd) {
  background: rgba(255,255,255,.015);
}
.call-item:hover {
  background: rgba(255,255,255,.05);
}

.call-item__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: .85rem;
}
.call-item__icon--inbound {
  background: rgba(34,197,94,.1);
  color: var(--success);
}
.call-item__icon--outbound {
  background: rgba(99,102,241,.1);
  color: var(--accent-1);
}

.call-item__info {
  flex: 1;
  min-width: 0;
}
.call-item__phone {
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-item__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: .73rem;
  color: var(--text-muted);
}
.call-item__meta span {
  white-space: nowrap;
}

.call-item__status {
  font-size: .68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.call-item__status--completed {
  background: rgba(34,197,94,.1);
  color: var(--success);
}
.call-item__status--ringing,
.call-item__status--in-progress {
  background: rgba(245,158,11,.1);
  color: var(--warning);
}
.call-item__status--failed,
.call-item__status--busy,
.call-item__status--no-answer {
  background: rgba(239,68,68,.08);
  color: var(--danger);
}

/* ── Transcript Messages ──────────────────── */
.transcript-msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  max-width: 85%;
  animation: fadeInUp .3s ease forwards;
}
.transcript-msg--user {
  align-self: flex-start;
  align-items: flex-start;
}
.transcript-msg--agent {
  align-self: flex-end;
  align-items: flex-end;
}

.transcript-msg__role {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
  padding: 0 4px;
}
.transcript-msg--user .transcript-msg__role {
  color: var(--accent-1);
}
.transcript-msg--agent .transcript-msg__role {
  color: var(--accent-3);
}

.transcript-msg__bubble {
  padding: 10px 16px;
  border-radius: 14px;
  font-size: .85rem;
  line-height: 1.55;
  word-break: break-word;
}
.transcript-msg--user .transcript-msg__bubble {
  background: rgba(99,102,241,.1);
  border: 1px solid rgba(99,102,241,.15);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.transcript-msg--agent .transcript-msg__bubble {
  background: rgba(236,72,153,.08);
  border: 1px solid rgba(236,72,153,.12);
  border-bottom-right-radius: 4px;
  color: var(--text);
}

#transcript {
  display: flex;
  flex-direction: column;
}

/* ── Empty States ─────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  gap: 8px;
  height: 100%;
  min-height: 200px;
}
.empty-state p {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-muted);
}
.empty-state span {
  font-size: .78rem;
  color: var(--text-dim);
}

/* ── Footer ───────────────────────────────── */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 28px 32px;
  font-size: .72rem;
  color: var(--text-dim);
}
.footer__sep {
  opacity: .3;
}

/* ── Spinner (used in JS) ─────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  html { font-size: 14px; }

  .navbar__inner {
    padding: 0 16px;
    height: 56px;
  }
  .navbar__title {
    font-size: 1rem;
  }

  .dashboard {
    padding: 0 14px 32px;
    margin-top: 18px;
    gap: 16px;
  }

  .stats-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }
  .stat-card__value {
    font-size: 1.35rem;
  }

  .card__header {
    padding: 14px 16px 0;
  }
  .card__body {
    padding: 14px 16px 16px;
  }

  .call-item {
    padding: 12px;
    gap: 10px;
  }
}

/* NEW STYLES */
.card__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn--danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn--danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 6px;
  height: 32px;
}

.call-item--clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-item--clickable:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}
.call-item--clickable.active {
  background: rgba(255, 255, 255, 0.08);
  border-left: 2px solid #6366f1;
}
