/* ============================================================
   SISTER AGENT — UI STYLESHEET
   Premium dark interface. Warm, focused, personal.
   ============================================================ */

/* ── CSS VARIABLES ──────────────────────────────────────────────────────── */
:root {
  /* Color Palette — deep violet-indigo with warm amber accent */
  --clr-bg:          #0a0a12;
  --clr-surface:     #111120;
  --clr-surface-2:   #191930;
  --clr-border:      rgba(139, 92, 246, 0.15);
  --clr-border-light:rgba(139, 92, 246, 0.30);

  --clr-primary:     #8b5cf6;       /* Violet */
  --clr-primary-glow:rgba(139, 92, 246, 0.35);
  --clr-accent:      #f59e0b;       /* Warm amber — feels personal, not corporate */
  --clr-accent-soft: rgba(245, 158, 11, 0.15);

  --clr-user-bubble: #8b5cf6;
  --clr-agent-bubble:#191930;

  --clr-text:        #f1f0f8;
  --clr-text-muted:  #7c7a9a;
  --clr-text-dim:    #4a4870;

  /* Typography */
  --font-ui:         'Outfit', 'Inter', sans-serif;
  --font-chat:       'Inter', sans-serif;

  /* Sizes */
  --header-h:        68px;
  --input-bar-h:     80px;
  --radius-lg:       20px;
  --radius-md:       14px;
  --radius-sm:       8px;

  /* Transitions */
  --transition:      0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--clr-bg);
  color: var(--clr-text);
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ── AMBIENT BACKGROUND ORBS ───────────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  top: -150px; left: -100px;
  animation-duration: 20s;
}
.orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #6d28d9, transparent 70%);
  bottom: -100px; right: -80px;
  animation-duration: 25s;
  animation-delay: -8s;
}
.orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #f59e0b, transparent 70%);
  top: 40%; left: 55%;
  opacity: 0.12;
  animation-duration: 30s;
  animation-delay: -14s;
}
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, -20px) scale(1.05); }
  100% { transform: translate(-20px, 30px) scale(0.97); }
}

/* ── APP SHELL ─────────────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
}

/* ── HEADER ────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 20px;
  background: rgba(10, 10, 18, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.agent-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Agent Avatar — animated ring when "thinking" */
.agent-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: conic-gradient(
    from 0deg,
    var(--clr-primary) 0%,
    var(--clr-accent) 50%,
    var(--clr-primary) 100%
  ) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  transition: opacity var(--transition);
}
.avatar-core {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--clr-primary), #6d28d9);
  box-shadow: 0 0 20px var(--clr-primary-glow);
}

/* Pulse when agent is "thinking" */
.app.thinking .avatar-ring {
  animation: spin-ring 1.5s linear infinite;
}
.app.thinking .avatar-core {
  animation: pulse-core 1.5s ease-in-out infinite;
}
@keyframes spin-ring {
  to { transform: rotate(360deg); }
}
@keyframes pulse-core {
  0%, 100% { box-shadow: 0 0 20px var(--clr-primary-glow); }
  50% { box-shadow: 0 0 40px var(--clr-primary-glow), 0 0 10px var(--clr-accent); }
}

/* Recording state */
.app.recording .avatar-ring {
  animation: spin-ring 0.6s linear infinite;
  background: conic-gradient(
    from 0deg,
    var(--clr-accent) 0%,
    #ef4444 50%,
    var(--clr-accent) 100%
  ) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
}
.app.recording .avatar-core {
  background: linear-gradient(135deg, var(--clr-accent), #ef4444);
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
}

.agent-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.agent-name {
  font-family: var(--font-ui);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--clr-text);
  letter-spacing: -0.01em;
}
.agent-status {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color var(--transition);
}
.app.thinking .agent-status,
.app.recording .agent-status { color: var(--clr-accent); }

.header-actions { display: flex; gap: 8px; }
.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  background: transparent;
  color: var(--clr-text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover {
  background: var(--clr-surface-2);
  color: var(--clr-text);
  border-color: var(--clr-border-light);
}

/* ── CONVERSATION ──────────────────────────────────────────────────────── */
.conversation {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.conversation::-webkit-scrollbar { width: 4px; }
.conversation::-webkit-scrollbar-track { background: transparent; }
.conversation::-webkit-scrollbar-thumb {
  background: var(--clr-border-light);
  border-radius: 2px;
}

/* ── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state {
  margin: auto;
  text-align: center;
  padding: 40px 20px;
  animation: fade-up 0.6s ease both;
}
.empty-icon {
  font-size: 2.5rem;
  color: var(--clr-primary);
  opacity: 0.6;
  margin-bottom: 16px;
  display: block;
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.empty-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--clr-text-muted);
  margin-bottom: 6px;
}
.empty-sub {
  font-size: 0.85rem;
  color: var(--clr-text-dim);
}

/* ── MESSAGE BUBBLES ────────────────────────────────────────────────────── */
.message {
  display: flex;
  gap: 10px;
  animation: fade-up 0.3s ease both;
  max-width: 85%;
}
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.message.agent {
  align-self: flex-start;
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-family: var(--font-chat);
  font-size: 0.93rem;
  line-height: 1.6;
  word-break: break-word;
}
.message.user .bubble {
  background: var(--clr-user-bubble);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}
.message.agent .bubble {
  background: var(--clr-surface-2);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
  border-bottom-left-radius: var(--radius-sm);
}

.message-time {
  font-size: 0.7rem;
  color: var(--clr-text-dim);
  align-self: flex-end;
  padding-bottom: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  align-items: center;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--clr-primary);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── INPUT BAR ─────────────────────────────────────────────────────────── */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px 20px;
  background: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--clr-border);
  flex-shrink: 0;
}

/* Mic Button */
.mic-btn {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--clr-border-light);
  background: var(--clr-surface-2);
  color: var(--clr-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  overflow: hidden;
}
.mic-btn:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
  background: var(--clr-surface-2);
  box-shadow: 0 0 20px var(--clr-primary-glow);
}
.mic-btn.active {
  background: linear-gradient(135deg, var(--clr-accent), #ef4444);
  border-color: var(--clr-accent);
  color: #fff;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
}
.mic-ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--clr-accent);
  opacity: 0;
  transform: scale(0);
}
.mic-btn.active .mic-ripple {
  animation: mic-ripple 1s ease-out infinite;
}
@keyframes mic-ripple {
  0% { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 0; transform: scale(2); }
}

/* Text Input */
.text-input-wrapper {
  flex: 1;
  position: relative;
}
.text-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  color: var(--clr-text);
  font-family: var(--font-chat);
  font-size: 0.93rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  max-height: 120px;
  overflow-y: auto;
}
.text-input::placeholder { color: var(--clr-text-dim); }
.text-input:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-glow);
}

/* Send Button */
.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--clr-primary), #6d28d9);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 4px 16px var(--clr-primary-glow);
}
.send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.5);
}
.send-btn:active:not(:disabled) { transform: scale(0.96); }
.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── ANIMATIONS ─────────────────────────────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── MOBILE ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-header { padding: 0 14px; }
  .conversation { padding: 16px 12px; }
  .input-bar { padding: 10px 12px 16px; gap: 8px; }
  .message { max-width: 92%; }
  .agent-name { font-size: 1rem; }
}

/* ── SAFE AREA (iPhone notch/home bar) ──────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .input-bar { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
