/* clients/pwa/css/app.css
 *
 * Tema do LAS. A base de variáveis veio do cliente anterior (que era bem
 * estruturado); as seções novas atendem ao que mudou:
 *   · indicador de estado da voz (ouvindo / pensando / falando)
 *   · cartão de ação pendente com os dois botões de decisão
 *   · aviso de privacidade da escuta
 *   · painel de rotinas (Fase 2)
 */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #2c5fd8;
  --danger: #e05555;
  --ok: #3dbd7d;
  --warn: #e0a355;
  --bubble-user: #2c5fd8;
  --bubble-ai: #232833;
  --radius: 14px;
  --border: #262b36;
}

[data-theme='light'] {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --text: #1c2230;
  --muted: #5b6472;
  --bubble-user: #2c5fd8;
  --bubble-ai: #e6eaf2;
  --border: #dde2ec;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  /* iOS: respeita a área segura (notch e barra inferior) */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  background: var(--accent);
  border: 0;
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--panel-2); color: var(--text); }
button.danger { background: var(--danger); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }

input, textarea, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  font: inherit;
  width: 100%;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); }

/* ---------- Estrutura ---------- */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
header h1 { font-size: 17px; margin: 0; flex: 1; }

main { flex: 1; overflow: hidden; position: relative; }
.view { display: none; height: 100%; overflow-y: auto; }
.view.active { display: block; }

nav#main-nav {
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
nav#main-nav button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  padding: 11px 4px;
  font-size: 12px;
}
nav#main-nav button.active { color: var(--accent); }

.pad { padding: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px auto;
  max-width: 420px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.row > input, .row > select { flex: 1; min-width: 120px; }
.section-title {
  font-weight: 600;
  margin: 18px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.muted { color: var(--muted); font-size: 13px; }
.error-msg { color: var(--danger); min-height: 18px; font-size: 13px; margin: 4px 0; }
.badge {
  background: var(--warn);
  color: #1c2230;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 12px;
}
.badge.ok { background: var(--ok); color: #07281a; }

/* ---------- Estado da voz (novo) ---------- */
#voice-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel-2);
  border-radius: 20px;
  font-size: 13px;
}
#voice-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
#voice-state[data-state='ouvindo'] #voice-dot { background: var(--ok); animation: pulse 1.6s infinite; }
#voice-state[data-state='pensando'] #voice-dot { background: var(--warn); animation: pulse 0.8s infinite; }
#voice-state[data-state='falando'] #voice-dot { background: var(--accent); animation: pulse 0.5s infinite; }
#voice-state[data-state='erro'] #voice-dot { background: var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}
/* Respeita quem pediu menos animação no sistema */
@media (prefers-reduced-motion: reduce) {
  #voice-dot { animation: none !important; }
}

/* ---------- Privacidade da escuta (novo) ---------- */
.privacy-note {
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0;
}

/* ---------- Chat ---------- */
#chat-layout { display: flex; height: 100%; }
#conv-panel {
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex: 0 0 auto;
}
#conv-panel.hidden { display: none; }
#chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chat-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
#chat-toolbar input { flex: 1; }
#messages { flex: 1; overflow-y: auto; padding: 14px; }
.msg { display: flex; margin-bottom: 10px; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 76%;
  padding: 9px 13px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user .bubble { background: var(--bubble-user); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--bubble-ai); border-bottom-left-radius: 4px; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 5px; }
.msg.user .bubble .meta { color: #c9d8ff; }
.typing { color: var(--muted); font-style: italic; }

#composer {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  align-items: flex-end;
}
#composer textarea { max-height: 120px; }

#rec-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--danger);
  font-size: 13px;
}
#rec-indicator.on { display: flex; }
#rec-indicator .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); animation: pulse 1s infinite;
}

/* ---------- Cartões (memória, ações, tarefas) ---------- */
.item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
}
.item-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-title { font-weight: 600; }
.item-body { margin-top: 4px; font-size: 14px; }
.item-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; }
.item-actions button { flex: 1; }

/* Ação pendente: destaque, porque exige decisão do usuário */
.item.pendente { border-left: 3px solid var(--warn); }
.item.executada { border-left: 3px solid var(--ok); opacity: 0.85; }
.item.falhou { border-left: 3px solid var(--danger); opacity: 0.85; }

.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
}
.tag.family { background: #2b3a5c; color: #a9c3ff; }
.tag.personal { background: var(--panel-2); }
.tag.shared { background: #3a3020; color: #e0c99a; }

/* ---------- Offline ---------- */
#offline-banner {
  display: none;
  background: var(--warn);
  color: #1c2230;
  padding: 6px 14px;
  font-size: 13px;
  text-align: center;
}
#offline-banner.on { display: block; }

/* ---------- Responsivo ---------- */
@media (max-width: 720px) {
  #conv-panel { position: absolute; z-index: 30; height: 100%; box-shadow: 0 0 24px #0008; }
  .bubble { max-width: 88%; }
  header h1 { font-size: 15px; }
}
