/* -----------------------------------------------------------
   Our AI · chat interface (DinizDynamics dark theme)
   ----------------------------------------------------------- */

:root {
  --bg:        #050a12;
  --bg2:       #0b1525;
  --bg3:       #0f1e35;
  --surface:   #0d1a2e;
  --surface-2: #122644;
  --accent:    #0ea5e9;
  --accent2:   #38bdf8;
  --accent3:   #7dd3fc;
  --gold:      #f59e0b;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --danger:    #ef4444;
  --success:   #22c55e;
  --border:    rgba(56,189,248,.18);
  --border-strong: rgba(56,189,248,.32);
  --card:      rgba(15,30,53,.75);
  --shadow:    0 8px 32px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 60px rgba(14,165,233,.20);
  --radius:    14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Top nav ───────────────────────────────────────────── */
.top-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: rgba(5,10,18,.85);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem; font-weight: 700; color: #fff;
}
.brand img { width: 30px; height: 30px; object-fit: contain; }
.brand-divider { color: var(--muted); font-weight: 400; }
.brand-section { color: var(--accent2); }
.nav-actions { display: flex; align-items: center; gap: 8px; }

.status {
  display: flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--muted);
  background: rgba(56,189,248,.1);
  border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px;
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #f5c842;
}
.status.ok    .dot { background: var(--success); }
.status.error .dot { background: var(--danger);  }

.icon-btn {
  background: transparent; border: 1px solid transparent;
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer; transition: all .2s;
  text-decoration: none;
}
.icon-btn:hover { background: rgba(56,189,248,.12); color: var(--accent2); border-color: var(--border); }
.icon-btn svg { width: 18px; height: 18px; }

/* ─── Privacy strip ────────────────────────────────────── */
.privacy-strip {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 22px;
  font-size: .82rem;
  color: #d8e8ff;
  background: linear-gradient(90deg, rgba(14,165,233,.18), rgba(125,211,252,.06));
  border-bottom: 1px solid var(--border);
}
.privacy-strip .lock { font-size: 1rem; }
.privacy-strip strong { color: var(--accent3); }
.privacy-strip .strip-close {
  margin-left: auto;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: 0 6px; line-height: 1;
}
.privacy-strip .strip-close:hover { color: #fff; }
.privacy-strip.hidden { display: none; }

/* ─── App shell ─────────────────────────────────────────── */
.app {
  display: flex; flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  background: var(--bg2);
  border-left:  1px solid var(--border);
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-height: 0;
}

/* ─── Chat area ─────────────────────────────────────────── */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px 36px;
  scroll-behavior: smooth;
}

.welcome {
  text-align: center;
  max-width: 640px;
  margin: 30px auto 0;
  padding: 30px 16px 12px;
}
.welcome-orb {
  width: 96px; height: 96px; border-radius: 50%;
  margin: 0 auto 24px;
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--accent2) 28%, var(--accent) 60%, transparent 80%);
  box-shadow:
    0 0 60px rgba(56,189,248,.55),
    inset 0 0 24px rgba(255,255,255,.25);
  animation: orb 5s ease-in-out infinite;
}
@keyframes orb { 0%,100%{transform:scale(1)} 50%{transform:scale(1.06)} }
.welcome h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px;
}
.welcome p {
  color: var(--muted);
  margin: 0 0 24px;
}
.quick-actions {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
}
.quick-act {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 10px 18px;
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
  transition: all .2s;
}
.quick-act:hover {
  border-color: var(--border-strong);
  background: rgba(56,189,248,.1);
  transform: translateY(-2px);
}

/* ─── Messages ──────────────────────────────────────────── */
.message {
  display: flex; gap: 12px; margin-bottom: 18px;
  animation: fadeIn .2s ease-out;
}
.message.user { flex-direction: row-reverse; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.avatar {
  flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 12px rgba(14,165,233,.35);
}
.message.user .avatar {
  background: linear-gradient(135deg, #475569, #334155);
  box-shadow: none;
}

.bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
}
.message.user .bubble {
  background: linear-gradient(135deg, rgba(14,165,233,.14), rgba(56,189,248,.07));
  border-color: var(--border-strong);
  color: #f1f5f9;
}
.bubble.error {
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.4);
  color: #fca5a5;
}

.bubble .thumb {
  display: block;
  max-width: 220px; max-height: 220px;
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.bubble audio {
  width: 240px; max-width: 100%;
  margin-bottom: 8px;
}

.bubble .file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--accent3);
  background: rgba(56,189,248,.08);
  border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px;
  margin-right: 6px; margin-bottom: 6px;
}

.bubble .meta {
  display: flex; gap: 10px; align-items: center;
  margin-top: 10px;
  font-size: .72rem; color: var(--muted);
}

.speak-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent3);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .72rem;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .2s;
}
.speak-btn:hover { background: rgba(56,189,248,.12); }
.speak-btn.speaking {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.speak-btn svg { width: 12px; height: 12px; }

.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .72rem;
  cursor: pointer;
  transition: all .2s;
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px;
  background: var(--accent2);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%,60%,100% { transform: translateY(0);    opacity: .55; }
  30%         { transform: translateY(-6px); opacity: 1;   }
}

/* ─── Composer ──────────────────────────────────────────── */
.composer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 14px 22px 18px;
}

.attachment-strip {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 10px;
}
.attachment-strip.hidden { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(56,189,248,.1);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  font-size: .82rem;
  max-width: 280px;
}
.chip img {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
}
.chip-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; color: #fff; flex-shrink: 0;
}
.chip .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .remove {
  background: transparent; border: none;
  color: var(--muted); font-size: 1.1rem;
  cursor: pointer; padding: 0 2px; line-height: 1;
}
.chip .remove:hover { color: var(--danger); }

.recording-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 12px;
  color: #fca5a5;
  font-size: .9rem;
}
.recording-bar.hidden { display: none; }
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }
.rec-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.rec-cancel, .rec-send {
  background: transparent; border: 1px solid rgba(239,68,68,.4);
  color: #fca5a5; font-family: inherit; font-size: .82rem;
  padding: 6px 14px; border-radius: 999px;
  cursor: pointer; transition: all .2s;
}
.rec-cancel:hover { background: rgba(239,68,68,.15); }
.rec-send {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.rec-send:hover { background: var(--accent2); }

.composer-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14,165,233,.18);
}
.composer-row .icon-btn { color: var(--muted); }
.composer-row .icon-btn:hover { background: rgba(56,189,248,.12); color: var(--accent2); }

textarea#message-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: .95rem;
  color: var(--text);
  padding: 10px 6px;
  min-height: 24px;
  max-height: 200px;
  outline: none;
  line-height: 1.5;
}
textarea#message-input::placeholder { color: var(--muted); }

.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(14,165,233,.4);
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(14,165,233,.5);
}
.send-btn:disabled { opacity: .5; cursor: not-allowed; }

#dictate-btn.recording, #voicemsg-btn.recording {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  animation: pulseRec 1.2s infinite;
}
@keyframes pulseRec {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50%     { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.composer-hint {
  margin-top: 10px;
  font-size: .72rem;
  color: var(--muted);
  text-align: center;
}
.composer-warn {
  margin-top: 8px;
  font-size: .78rem;
  color: #fcd34d;
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.28);
  border-radius: 8px;
  padding: 8px 14px;
  text-align: center;
}
.composer-warn strong { color: var(--gold); }
.composer-hint kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: .68rem;
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.modal[aria-hidden="false"] { opacity: 1; pointer-events: auto; }
.modal[hidden] { display: none; }
.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(2,6,15,.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-panel {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 32px 32px 28px;
  transform: translateY(8px) scale(.98);
  transition: transform .18s ease;
}
.modal[aria-hidden="false"] .modal-panel {
  transform: translateY(0) scale(1);
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: transparent; border: none;
  font-size: 1.7rem; line-height: 1;
  color: var(--muted);
  cursor: pointer; padding: 4px 10px; border-radius: 50%;
  transition: all .15s;
}
.modal-close:hover { background: rgba(56,189,248,.12); color: #fff; }
.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  color: #fff;
  font-size: 1.4rem;
  margin: 0 0 8px;
}
.modal-lead {
  color: var(--muted);
  margin: 0 0 18px;
}
.rules {
  list-style: decimal;
  margin: 0 0 18px;
  padding-left: 22px;
  color: var(--text);
  font-size: .92rem;
}
.rules li { margin-bottom: 10px; line-height: 1.55; }
.rules strong { color: #fff; }
.rules em { color: var(--accent3); font-style: normal; }
.modal-disclaimer {
  font-size: .82rem;
  color: var(--muted);
  background: rgba(245,158,11,.06);
  border: 1px solid rgba(245,158,11,.25);
  padding: 12px 14px;
  border-radius: 10px;
  margin: 0 0 22px;
}
.modal-disclaimer strong { color: var(--gold); }
.modal-footer {
  text-align: right;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 8px;
  font-family: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: all .2s; border: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 16px rgba(14,165,233,.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(14,165,233,.5); }

/* ─── Mobile ────────────────────────────────────────────── */
@media (max-width: 720px) {
  .top-nav { padding: 10px 14px; }
  .brand { font-size: .95rem; }
  .brand img { width: 26px; height: 26px; }
  .brand-section { display: none; }

  .privacy-strip { font-size: .76rem; padding: 9px 14px; }

  .app { border-left: none; border-right: none; }
  .chat { padding: 20px 14px 28px; }

  .welcome  { padding: 18px 8px 8px; }
  .welcome-orb { width: 76px; height: 76px; margin-bottom: 18px; }
  .welcome h2 { font-size: 1.4rem; }
  .quick-act  { font-size: .82rem; padding: 9px 14px; }

  .bubble { max-width: 86%; font-size: .98rem; padding: 12px 15px; }
  .avatar { width: 34px; height: 34px; font-size: .75rem; }

  .composer { padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  textarea#message-input { font-size: 16px; padding: 11px 6px; }
  .icon-btn { width: 42px; height: 42px; }
  .icon-btn svg { width: 20px; height: 20px; }
  .send-btn { width: 44px; height: 44px; }
  .send-btn svg { width: 20px; height: 20px; }

  .modal { padding: 14px; }
  .modal-panel { padding: 24px 20px 22px; max-height: calc(100vh - 28px); }
  .modal-title { font-size: 1.25rem; }
  .rules { font-size: .9rem; }
}
