/* ==========================================================================
   Assistente Pessoal - Estilos Mobile-First & Glassmorphism Moderno
   ========================================================================== */

:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #111722;
  --bg-card: rgba(19, 27, 41, 0.75);
  --bg-card-hover: rgba(28, 38, 58, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --user-bubble-bg: linear-gradient(135deg, #2563eb, #1d4ed8);
  --bot-bubble-bg: #151d2d;
  --bot-bubble-border: rgba(255, 255, 255, 0.07);

  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --safe-bottom: env(safe-area-inset-bottom, 12px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

/* App Container (centralizado em telas maiores, 100% no mobile) */
.app-container {
  width: 100%;
  max-width: 520px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

/* ==========================================================================
   Header & Status
   ========================================================================== */
.app-header {
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.assistant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  position: relative;
}

.status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  border: 2px solid var(--bg-primary);
}

.header-info {
  flex: 1;
  margin-left: 12px;
}

.header-info h1 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.header-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.icon-button {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-button:hover, .icon-button:active {
  background: var(--bg-secondary);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Painel de Resumo Rápido */
.quick-summary-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideDown 0.25s ease forwards;
}

.quick-summary-panel.hidden {
  display: none;
}

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

.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.summary-card .card-icon {
  font-size: 1.3rem;
}

.summary-card .card-data {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.summary-card .card-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-card .card-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-card .card-value {
  color: var(--accent-emerald);
}

.calendar-card .card-value {
  color: var(--accent-cyan);
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px;
}

/* ==========================================================================
   Chat Messages
   ========================================================================== */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
  width: 4px;
}
.chat-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.message {
  display: flex;
  width: 100%;
}

.user-message {
  justify-content: flex-end;
}

.assistant-message {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-message .message-bubble {
  background: var(--user-bubble-bg);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.assistant-message .message-bubble {
  background: var(--bot-bubble-bg);
  border: 1px solid var(--bot-bubble-border);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.user-message .message-header {
  color: rgba(255, 255, 255, 0.7);
}

.message-author {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-text ul {
  margin: 6px 0 6px 18px;
}

.message-text li {
  margin-bottom: 4px;
}

/* Card especial de Ação Executada (Tool Call feedback) */
.tool-action-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-top: 8px;
  font-weight: 500;
}

.tool-action-badge.calendar {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.3);
  color: #38bdf8;
}

.tool-action-badge.error {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fb7185;
}

/* Loading / Digitando */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ==========================================================================
   Quick Action Chips
   ========================================================================== */
.quick-chips-wrapper {
  padding: 6px 16px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.quick-chips-wrapper::-webkit-scrollbar {
  display: none;
}

.quick-chips {
  display: inline-flex;
  gap: 8px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover, .chip:active {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* ==========================================================================
   Footer & Input Area
   ========================================================================== */
.app-footer {
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(10, 13, 20, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 6px 8px 6px 12px;
  transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.speech-button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: color 0.2s;
}

.speech-button:hover, .speech-button:active {
  color: var(--accent-cyan);
}

.speech-button.listening {
  color: var(--accent-rose);
}

.speech-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.25);
  display: none;
}

.speech-button.listening .speech-pulse {
  display: block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.92rem;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  padding: 6px 0;
}

#chat-input::placeholder {
  color: var(--text-dim);
}

.send-button {
  background: var(--accent-primary);
  border: none;
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, background-color 0.2s;
}

.send-button:disabled {
  background: #1f2937;
  color: #4b5563;
  cursor: not-allowed;
}

.send-button:not(:disabled):hover {
  background: #2563eb;
  transform: scale(1.05);
}

.send-button:not(:disabled):active {
  transform: scale(0.95);
}

.footer-hint {
  text-align: center;
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ==========================================================================
   Overlay de Voz (Speech Recognition Modal)
   ========================================================================== */
.speech-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.speech-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.speech-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
}

.speech-waves {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
}

.speech-waves span {
  width: 6px;
  background: linear-gradient(180deg, var(--accent-cyan), var(--accent-primary));
  border-radius: 4px;
  animation: wave 1s infinite ease-in-out;
}

.speech-waves span:nth-child(1) { height: 16px; animation-delay: 0.1s; }
.speech-waves span:nth-child(2) { height: 32px; animation-delay: 0.2s; }
.speech-waves span:nth-child(3) { height: 48px; animation-delay: 0.3s; }
.speech-waves span:nth-child(4) { height: 28px; animation-delay: 0.4s; }
.speech-waves span:nth-child(5) { height: 14px; animation-delay: 0.5s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

#speech-status-text {
  font-size: 0.95rem;
  color: var(--text-main);
  font-weight: 500;
}

.btn-cancel-speech {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel-speech:hover {
  background: var(--accent-rose);
  border-color: var(--accent-rose);
}
