/* =============================================
   VOICE CHAT APP - Modern Design System 2024
   ============================================= */

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Modern Theme Variables */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Primary Colors - Modern Palette */
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --primary-light: #a78bfa;
  --accent: #06b6d4;
  --accent-glow: #06b6d440;

  /* Brand Colors */
  --deepseek-blue: #3b82f6;
  --deepseek-purple: #8b5cf6;
  --deepseek-pink: #ec4899;

  /* Dark Theme Colors (Default) */
  --color-bg: #0a0a0f;
  --color-bg-secondary: #12121a;
  --color-bg-tertiary: #1a1a24;
  --color-surface: #16161f;
  --color-text: #e4e4e7;
  --color-text-secondary: #a1a1aa;
  --color-text-muted: #71717a;

  /* Status Colors */
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;

  /* Modern Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 4px 12px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 12px 24px -4px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 24px 48px -8px rgb(0 0 0 / 0.6);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.25);
  --shadow-glow-accent: 0 0 40px rgba(6, 182, 212, 0.2);

  /* Smooth Transitions */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Support (Automatic based on system preference) */
@media (prefers-color-scheme: light) {
  :root {
    /* Light Theme Colors */
    --color-bg: #ffffff;
    --color-bg-secondary: #f8fafc;
    --color-bg-tertiary: #e2e8f0;
    --color-surface: #ffffff;
    --color-text: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #64748b;

    /* Adjusted shadows for light mode */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  }

  /* Adjust specific elements for light mode */
  .header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  }

  .model-dropdown {
    background: var(--color-bg-secondary);
    border-color: var(--color-bg-tertiary);
  }

  .text-input {
    background: var(--color-bg-secondary);
    border-color: var(--color-bg-tertiary);
  }

  body::before {
    opacity: 0.02;
  }

  body::after {
    opacity: 0.1;
  }
}

html,
body {
  overscroll-behavior: contain;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Animated Gradient Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 15% 85%, var(--primary) 0%, transparent 45%),
    radial-gradient(circle at 85% 15%, var(--accent) 0%, transparent 45%),
    radial-gradient(circle at 45% 55%, var(--deepseek-blue) 0%, transparent 40%);
  opacity: 0.08;
  z-index: -1;
  animation: backgroundShift 25s ease-in-out infinite;
  pointer-events: none;
  filter: blur(60px);
}

/* Floating Particles Effect */
body::after {
  content: '';
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
  background-image:
    radial-gradient(2px 2px at 20% 30%, var(--primary-light), transparent),
    radial-gradient(2px 2px at 60% 70%, var(--accent), transparent),
    radial-gradient(1.5px 1.5px at 50% 50%, var(--deepseek-blue), transparent),
    radial-gradient(2px 2px at 80% 10%, var(--deepseek-purple), transparent),
    radial-gradient(1px 1px at 30% 85%, var(--deepseek-pink), transparent);
  background-size: 400% 400%;
  animation: floatingParticles 35s ease infinite;
  opacity: 0.25;
  pointer-events: none;
}

@keyframes floatingParticles {
  0%, 100% {
    background-position: 0% 0%;
  }
  25% {
    background-position: 100% 100%;
  }
  50% {
    background-position: 100% 0%;
  }
  75% {
    background-position: 0% 100%;
  }
}

@keyframes backgroundShift {
  0%, 100% { transform: scale(1) rotate(0deg); }
  33% { transform: scale(1.1) rotate(120deg); }
  66% { transform: scale(0.9) rotate(240deg); }
}

/* ============================================================================
   Header
   ============================================================================ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: auto;
  min-height: 70px;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 1000;
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  padding: calc(14px + var(--safe-top)) 0 14px;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.title {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.4));
  letter-spacing: 0;
  white-space: nowrap;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.btn-admin {
  padding: 10px 14px;
  background: rgba(139, 92, 246, 0.1);
  color: var(--color-text);
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-admin:hover {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.42);
  transform: translateY(-1px);
}

.btn-header-controls-toggle {
  padding: 10px 14px;
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-header-controls-toggle:hover,
.btn-header-controls-toggle.is-expanded {
  background: rgba(139, 92, 246, 0.14);
  color: var(--color-text);
  border-color: rgba(139, 92, 246, 0.3);
}

.btn-header-controls-toggle.is-expanded .header-controls-toggle-icon {
  color: var(--primary-light);
}

.header-buttons .btn-header-controls-toggle {
  flex: 0 0 auto;
  min-width: 42px;
  padding: 10px 12px;
}

.btn-help {
  padding: 10px 14px;
  background: rgba(6, 182, 212, 0.1);
  color: var(--color-text);
  border: 1px solid rgba(6, 182, 212, 0.26);
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-help:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.42);
  transform: translateY(-1px);
}

.advanced-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 560px;
  min-width: min(100%, 360px);
}

.advanced-header-controls.is-collapsed {
  display: none;
}

.btn-logout {
  padding: 10px 18px;
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
  transform: translateY(-1px);
}

.btn-history,
.btn-new-session {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn-history:hover,
.btn-new-session:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-end-session {
  background: linear-gradient(135deg, var(--color-danger) 0%, #dc2626 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.btn-end-session:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(239, 68, 68, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Model Selector */
.model-selector {
  display: flex;
  align-items: center;
  flex: 0 1 230px;
  min-width: 200px;
}

.model-dropdown {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  width: 100%;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.model-dropdown:hover {
  background: var(--color-bg-secondary);
  border-color: rgba(139, 92, 246, 0.3);
}

.model-dropdown:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.model-dropdown option {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  padding: 10px;
}

/* GLM Settings */
.glm-settings {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--color-bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-sm);
}

.glm-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.glm-checkbox input {
  accent-color: var(--accent);
}

/* Project Selector */
.project-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 0;
  flex-wrap: wrap;
  row-gap: 6px;
}

.project-dropdown {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  flex: 1 1 200px;
  min-width: 180px;
  width: auto;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.project-dropdown:hover {
  background: var(--color-bg-secondary);
  border-color: rgba(139, 92, 246, 0.3);
}

.project-dropdown:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.project-dropdown option {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  padding: 10px;
}

.btn-create-project {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex: 0 0 auto;
}

.btn-create-project:hover {
  background: var(--color-bg-secondary);
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateY(-1px);
}

.btn-knowledge,
.btn-knowledge-file {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex: 0 0 auto;
}

.btn-knowledge:hover,
.btn-knowledge-file:hover {
  background: var(--color-bg-secondary);
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateY(-1px);
}

.btn-knowledge:disabled,
.btn-knowledge.is-disabled {
  opacity: 0.5;
  cursor: pointer;
  transform: none;
}

.knowledge-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.knowledge-file-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.knowledge-textarea {
  min-height: 150px;
}

.knowledge-helper {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

.knowledge-status {
  margin: 8px 0 12px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--color-text-muted);
  font-size: 12px;
}

.knowledge-status.hidden {
  display: none;
}

.knowledge-status[data-status="success"] {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.22);
  background: rgba(34, 197, 94, 0.08);
}

.knowledge-status[data-status="error"] {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(239, 68, 68, 0.08);
}

.knowledge-list-header {
  margin: 14px 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0;
}

.knowledge-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.knowledge-empty {
  margin: 0;
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.knowledge-entry {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.knowledge-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.knowledge-entry-title {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-entry-remove {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
  cursor: pointer;
}

.knowledge-entry-remove:hover {
  background: rgba(239, 68, 68, 0.16);
}

.knowledge-entry-meta,
.knowledge-entry-preview {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.knowledge-entry-preview {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Mode Toggle no Header */
.mode-toggle-wrapper {
  display: flex;
  align-items: center;
}

.mode-toggle-header {
  background: var(--color-bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  gap: 3px;
  cursor: pointer;
  transition: var(--transition);
}

.mode-toggle-header:hover {
  border-color: rgba(139, 92, 246, 0.3);
}

.mode-toggle-header .mode-option {
  padding: 7px 10px;
  border-radius: 6px;
  transition: var(--transition);
  cursor: pointer;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-toggle-header .mode-option.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.mode-toggle-header .mode-option:not(.active):hover {
  color: var(--color-text);
}

/* ============================================================================
   Text Chat Interface
   ============================================================================ */

.text-chat-interface {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--color-bg) 0%, var(--color-bg) 80%, transparent 100%);
  padding: 16px 20px calc(24px + var(--safe-bottom));
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.text-input-container {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
  pointer-events: auto;
  position: relative;
}

/* Input de arquivo oculto */
.file-input-hidden {
  display: none;
}

.text-input {
  flex: 1;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 14px 50px 14px 188px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  min-height: 52px;
  max-height: 200px;
  transition: var(--transition);
  outline: none;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), var(--shadow);
  background: var(--color-bg-tertiary);
}

.text-input::placeholder {
  color: var(--color-text-muted);
}

.send-button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  box-shadow: var(--shadow);
  position: absolute;
  right: 8px;
  bottom: 8px;
}

.send-button:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

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

.send-button:disabled {
  background: var(--color-bg-tertiary);
  cursor: not-allowed;
  transform: none;
  opacity: 0.4;
  box-shadow: none;
}

.send-button .send-text {
  display: none;
}

.send-icon {
  width: 18px;
  height: 18px;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding: 0 4px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.typing-text {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* ============================================================================
   Attachment Upload & Preview
   ============================================================================ */

.attach-image-button,
.dictate-text-button,
.deep-search-button {
  background: transparent;
  border: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: var(--transition);
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
}

.dictate-text-button {
  left: 52px;
}

.deep-search-button {
  left: 96px;
  width: auto;
  min-width: 84px;
  padding: 0 11px;
  border-radius: 22px;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.attach-image-button:hover,
.dictate-text-button:hover,
.deep-search-button:hover {
  color: var(--primary-light);
  background: rgba(139, 92, 246, 0.1);
}

.attach-image-button:active,
.dictate-text-button:active,
.deep-search-button:active {
  transform: scale(0.9);
}

.deep-search-button:disabled {
  opacity: 0.45;
  cursor: wait;
  transform: none;
}

.dictate-text-button[data-state="recording"] {
  color: white;
  background: rgba(239, 68, 68, 0.92);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16);
  animation: textDictationPulse 1.4s ease-in-out infinite;
}

.dictate-text-button[data-state="processing"] {
  color: white;
  background: rgba(139, 92, 246, 0.9);
  cursor: wait;
}

.dictate-text-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dictate-icon-stop {
  display: none;
}

.dictate-text-button[data-state="recording"] .dictate-icon-mic {
  display: none;
}

.dictate-text-button[data-state="recording"] .dictate-icon-stop {
  display: block;
}

@keyframes textDictationPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.14);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.28);
  }
}

.image-preview {
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
  pointer-events: auto;
  position: relative;
  padding: 8px 44px 8px 8px;
  border-radius: 12px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  background: var(--color-bg-secondary);
  box-shadow: var(--shadow);
}

.attachment-preview-list {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.attachment-preview-item {
  min-width: 96px;
  max-width: 160px;
  height: 72px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.attachment-preview-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}

.attachment-preview-file-icon,
.message-file-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.attachment-preview-name {
  min-width: 0;
  color: var(--color-text);
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-remove {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.image-preview-remove:hover {
  background: var(--color-danger);
  transform: translateY(-50%) scale(1.08);
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.message-image {
  max-width: 300px;
  max-height: 200px;
  border-radius: 12px;
  margin-bottom: 8px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: var(--transition-fast);
}

.message-image:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.message-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.message-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--color-text);
}

/* ============================================================================
   Main Container
   ============================================================================ */

.main-container {
  flex: 1;
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px calc(120px + var(--safe-bottom));
  padding-top: calc(var(--header-height, 100px) + 20px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================================================
   Voice Button (Botão Central)
   ============================================================================ */

.voice-button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 0;
}

.voice-button {
  position: relative;
  width: 180px;
  height: 180px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  transition: var(--transition);
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.4), 0 0 0 0 rgba(139, 92, 246, 0.4);
  overflow: hidden;
  position: relative;
}

/* Estados do botão */
/* Voice Button States with Stunning Animations */
.voice-button::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 45%, rgba(255,255,255,0.12) 100%);
  animation: pulse 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.voice-button[data-state="idle"] {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}

.voice-button[data-state="listening"],
.voice-button[data-state="recording"] {
  background: linear-gradient(135deg, var(--color-danger) 0%, var(--deepseek-pink) 100%);
  animation: recording 1.5s ease-in-out infinite;
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.5), 0 0 60px rgba(239, 68, 68, 0.3);
}

.voice-button[data-state="processing"] {
  background: linear-gradient(135deg, var(--color-warning) 0%, var(--deepseek-blue) 100%);
  animation: processing 1s linear infinite;
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.5), 0 0 60px rgba(245, 158, 11, 0.3);
}

.voice-button[data-state="speaking"] {
  background: linear-gradient(135deg, var(--color-info) 0%, var(--deepseek-purple) 100%);
  animation: wave 1.2s ease-in-out infinite;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.5), 0 0 60px rgba(59, 130, 246, 0.3);
}

.voice-button[data-state="paused"] {
  background: linear-gradient(135deg, #ff8c00 0%, #ffd700 100%);
  animation: breathe 2.2s ease-in-out infinite;
  box-shadow: 0 8px 32px rgba(255, 140, 0, 0.5), 0 0 60px rgba(255, 140, 0, 0.3);
}

/* Animações */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.3;
  }
}

@keyframes recording {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.4);
  }
  25% {
    transform: scale(1.05) rotate(1deg);
  }
  50% {
    transform: scale(1.1) rotate(-1deg);
    box-shadow: 0 0 60px rgba(239, 68, 68, 0.6);
  }
  75% {
    transform: scale(1.05) rotate(1deg);
  }
}

@keyframes processing {
  0% {
    transform: rotate(0deg) scale(1);
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.4);
  }
  50% {
    transform: rotate(180deg) scale(1.05);
    box-shadow: 0 0 60px rgba(245, 158, 11, 0.6);
  }
  100% {
    transform: rotate(360deg) scale(1);
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.4);
  }
}

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

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

@keyframes breathe {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.98);
  }
}

.voice-button:hover {
  transform: scale(1.05);
}

.voice-button:active {
  transform: scale(0.95);
}

.voice-button-icon {
  pointer-events: none;
  fill: white;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* SVG Icon Styles */
.header-buttons svg,
.mode-option svg {
  vertical-align: middle;
}

.send-icon {
  width: 20px;
  height: 20px;
}

/* Status Text */
.status-text {
  font-size: 18px;
  color: var(--color-text-secondary);
  font-weight: 500;
  text-align: center;
  min-height: 28px;
}

/* ============================================================================
   Conversation History
   ============================================================================ */

.conversation-history {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 0;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
  overflow-wrap: break-word;
}

/* Markdown Styles dentro das mensagens */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
  margin: 12px 0 8px 0;
  font-weight: 700;
  line-height: 1.3;
}

.message-bubble h1 {
  font-size: 1.4em;
}

.message-bubble h2 {
  font-size: 1.25em;
}

.message-bubble h3 {
  font-size: 1.1em;
}

.message-bubble p {
  margin: 8px 0;
}

.message-bubble strong {
  font-weight: 700;
}

.message-bubble em {
  font-style: italic;
}

.message-bubble code.inline-code {
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
  color: var(--primary-light);
}

.message-bubble pre {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-bubble pre code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.85em;
  line-height: 1.5;
  color: var(--color-text);
}

.message-bubble ul,
.message-bubble ol {
  margin: 8px 0;
  padding-left: 24px;
}

.message-bubble li {
  margin: 4px 0;
}

.message-bubble a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-bubble a:hover {
  color: var(--primary-light);
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.message.assistant .message-bubble {
  background: var(--color-surface);
  color: var(--color-text);
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.message-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 6px;
  padding: 0 8px;
  font-weight: 500;
}

.message.user .message-meta {
  text-align: right;
}

.message.assistant .message-meta {
  text-align: left;
}

/* ============================================================================
   Footer
   ============================================================================ */

.footer {
  background: transparent;
  border-top: none;
  padding: 8px 20px calc(8px + var(--safe-bottom));
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 80;
  pointer-events: none;
}

.footer-content {
  max-width: 768px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 10px;
  color: var(--color-bg-tertiary);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.4;
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

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

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-content h3 {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 700;
}

.modal-content p {
  margin-bottom: 24px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

#knowledgeModal .modal-content {
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

#knowledgeModal .knowledge-helper,
#knowledgeModal .knowledge-entry-preview {
  margin: 6px 0 0;
}

#knowledgeModal .knowledge-empty {
  margin: 0;
}

.deep-search-modal-content {
  max-width: 640px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.modal-label {
  display: block;
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 800;
  margin: 10px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.deep-search-hint {
  margin: 4px 0 16px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.save-research-knowledge-btn {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: var(--transition);
}

.save-research-knowledge-btn:hover {
  border-color: rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}

.save-research-knowledge-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.admin-modal-content {
  max-width: min(960px, calc(100vw - 28px));
  width: 960px;
  max-height: min(86vh, 860px);
  overflow-y: auto;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-header h3,
.admin-header p {
  margin: 0;
}

.admin-header p {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-range-select {
  width: auto;
  min-width: 112px;
  margin: 0;
}

.btn-secondary {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.admin-status {
  min-height: 18px;
  color: var(--color-text-muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.admin-metric {
  background: var(--color-bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
}

.admin-metric span {
  display: block;
  color: var(--color-text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.admin-metric strong {
  display: block;
  color: var(--color-text);
  font-size: 20px;
  line-height: 1.15;
}

.admin-section {
  margin-top: 18px;
}

.admin-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.admin-create-user-form {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.admin-create-user-form .modal-input {
  margin: 0;
  min-height: 42px;
}

.admin-create-user-form .btn-secondary {
  min-height: 42px;
  white-space: nowrap;
}

.admin-create-user-form .admin-model-permissions {
  grid-column: 1 / -1;
}

.admin-model-permissions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.admin-model-permissions.is-table {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 340px;
}

.admin-model-permission {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--color-bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--color-text);
  font-size: 12px;
  line-height: 1.2;
}

.admin-model-permission.is-compact {
  padding: 6px 8px;
  min-height: 30px;
  font-size: 11px;
}

.admin-model-permission input {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}

.admin-save-models-btn {
  margin-top: 8px;
  padding: 8px 10px;
  min-height: 34px;
}

.admin-create-status {
  min-height: 18px;
  margin-top: 8px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.admin-create-status.is-error {
  color: #fca5a5;
}

.admin-create-status.is-success {
  color: #86efac;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  font-size: 12px;
}

.admin-table th,
.admin-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

.admin-table th {
  color: var(--color-text-muted);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table .num {
  text-align: right;
  white-space: nowrap;
}

.admin-muted {
  color: var(--color-text-muted);
}

.modal-input,
.modal-textarea,
.modal-select {
  width: 100%;
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: var(--transition);
  margin-bottom: 12px;
}

.modal-textarea {
  resize: vertical;
  font-weight: 500;
}

.modal-input:focus,
.modal-textarea:focus,
.modal-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.modal-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.modal-checkbox input {
  accent-color: var(--primary);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* Modal de Encerrar Sessão */
.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.end-session-content {
  max-width: 520px;
}

.end-session-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.end-session-option {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.end-session-option:hover {
  transform: translateY(-1px);
  border-color: rgba(139, 92, 246, 0.34);
  background: var(--color-bg-secondary);
}

.end-session-option-primary {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.08);
}

.end-session-option-danger {
  border-color: rgba(239, 68, 68, 0.24);
  background: rgba(239, 68, 68, 0.08);
}

.end-session-option-danger:hover {
  border-color: rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.14);
}

.end-session-option-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.end-session-option strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.end-session-option small {
  display: block;
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.35;
}

.btn-save-memory {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.btn-save-memory:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(34, 197, 94, 0.3);
}

.btn-delete-session-modal {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}

.btn-delete-session-modal:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(239, 68, 68, 0.3);
}

.btn-cancel {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-cancel:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border-color: rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  background: #5558e3;
}

/* ============================================================================
   Responsive
   ============================================================================ */

/* Tablets e telas médias */
@media (max-width: 900px) {
  .header-content {
    gap: 12px;
  }

  .title {
    font-size: 1.2rem;
  }

  .model-selector {
    min-width: 180px;
  }

  .project-selector {
    min-width: 180px;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .header {
    padding: 12px 0;
  }

  .header-content {
    padding: 0 10px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .title {
    font-size: 18px;
    flex: 1 1 calc(100% - 104px);
    min-width: 0;
    order: 1;
  }

  .btn-admin {
    order: 1;
    flex: 0 0 auto;
    margin-left: auto;
    padding: 9px 12px;
  }

  .admin-modal-content {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  .admin-header {
    flex-direction: column;
  }

  .admin-toolbar {
    width: 100%;
    justify-content: stretch;
  }

  .admin-range-select,
  .admin-toolbar .btn-secondary {
    flex: 1 1 0;
  }

  .admin-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-create-user-form {
    grid-template-columns: 1fr;
  }

  .admin-create-user-form .btn-secondary {
    width: 100%;
  }

  .admin-model-permissions,
  .admin-model-permissions.is-table {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .btn-history {
    order: 2;
  }

  .header-buttons {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.08fr) minmax(0, 0.82fr) minmax(0, 0.9fr) 42px;
    gap: 8px;
  }

  .header-buttons .btn-logout,
  .header-buttons .btn-end-session,
  .header-buttons .btn-new-session,
  .header-buttons .btn-help {
    width: 100%;
    min-width: 0;
    justify-content: center;
    padding: 10px 8px;
  }

  .header-buttons .btn-header-controls-toggle {
    width: 42px;
    height: 42px;
    padding: 0;
    flex: 0 0 42px;
  }

  .onboarding-card {
    width: calc(100vw - 24px) !important;
  }

  .onboarding-quick-actions {
    grid-template-columns: 1fr;
  }

  .advanced-header-controls {
    order: 4;
    width: 100%;
    min-width: 100%;
    flex: 1 1 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
  }

  .advanced-header-controls.is-collapsed {
    display: none;
  }

  .advanced-header-controls .model-selector {
    order: 1;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    margin-top: 0;
  }

  .mode-toggle-wrapper {
    order: 5;
    width: 100%;
    margin-top: 8px;
  }

  .mode-toggle-header {
    width: 100%;
    justify-content: center;
  }

  .mode-toggle-header .mode-option {
    flex: 1;
    padding: 8px;
  }

  .glm-settings {
    order: 2;
    margin-top: 8px;
  }

  .advanced-header-controls .project-selector {
    order: 3;
    width: 100%;
    flex: 0 0 auto;
    margin-top: 0;
    flex-wrap: wrap;
  }

  .project-dropdown {
    width: 100%;
    font-size: 13px;
  }

  .btn-create-project {
    width: 100%;
  }

  .btn-knowledge {
    width: 100%;
  }

  .model-dropdown {
    width: 100%;
    font-size: 13px;
  }

  .main-container {
    padding: 0 16px 120px;
    padding-top: calc(var(--header-height, 200px) + 20px);
  }

  .history-sidebar {
    width: 100vw;
    border-right: none;
  }

  .sidebar-header {
    padding: 18px 18px 14px;
  }

  .sessions-list {
    padding: 12px;
  }

  .session-item:hover,
  .session-item:focus-visible {
    transform: none;
  }

  .voice-button {
    width: 130px;
    height: 130px;
    font-size: 50px;
  }

  .status-text {
    font-size: 16px;
  }

  .message {
    max-width: 90%;
  }

  .footer-content {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }

  .mode-toggle-container {
    padding: 10px;
  }

  .mode-option {
    padding: 6px 14px;
    font-size: 13px;
  }

  .text-input-container {
    flex-direction: row;
    align-items: flex-end;
  }

  .send-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    right: 6px;
    bottom: 6px;
  }

  .send-icon {
    width: 16px;
    height: 16px;
  }

  .text-chat-interface {
    padding: 12px 16px 20px;
  }

  .text-input {
    font-size: 14px;
    padding: 12px 46px 12px 144px;
    min-height: 48px;
  }

  .attach-image-button,
  .dictate-text-button,
  .deep-search-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    bottom: 6px;
  }

  .attach-image-button {
    left: 6px;
  }

  .dictate-text-button {
    left: 48px;
  }

  .deep-search-button {
    left: 90px;
    width: 48px;
    min-width: 48px;
    padding: 0;
  }

  .deep-search-button span {
    display: none;
  }

  /* Espaçamento adicional no mobile */
}

/* ============================================================================
   Loading Spinner
   ============================================================================ */

.spinner {
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-left: 8px;
}

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

/* ============================================================================
   History Sidebar
   ============================================================================ */

.history-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: min(420px, 92vw);
  height: 100vh;
  height: 100dvh;
  background: rgba(18, 18, 26, 0.98);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 1400;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  padding-top: var(--safe-top);
}

.history-sidebar:not(.hidden) {
  transform: translateX(0);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}

.btn-close-sidebar {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 6px 10px;
  transition: var(--transition);
  border-radius: 6px;
}

.btn-close-sidebar:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.06);
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sessions-list::-webkit-scrollbar {
  width: 6px;
}

.sessions-list::-webkit-scrollbar-track {
  background: transparent;
}

.sessions-list::-webkit-scrollbar-thumb {
  background: var(--color-bg-tertiary);
  border-radius: 3px;
}

.sessions-list::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

.sessions-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 0 0 10px;
  background: rgba(139, 92, 246, 0.1);
  border-left: 3px solid #8b5cf6;
  border-radius: 8px;
  font-size: 13px;
  color: var(--color-text);
}

.sessions-filter-icon {
  flex: 0 0 auto;
}

.sessions-filter-name {
  flex: 1;
  font-weight: 600;
}

.sessions-filter-count {
  font-size: 11px;
  opacity: 0.75;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.sessions-empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 20px 12px;
  font-size: 13px;
}

.project-group {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px;
  margin-top: 14px;
  background: rgba(15, 23, 42, 0.35);
}

.project-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.project-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-secondary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.project-group-count {
  font-size: 11px;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 999px;
}

.project-group-list .session-item {
  margin-bottom: 8px;
}

.project-group-list .session-item:last-child {
  margin-bottom: 0;
}

.session-item {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  transition: var(--transition);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  cursor: pointer;
}

.session-item:hover,
.session-item:focus-visible {
  background: var(--color-bg-tertiary);
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateX(4px);
  outline: none;
}

.session-item.has-open-menu {
  z-index: 120;
}

.session-item.has-open-menu:hover,
.session-item.has-open-menu:focus-within {
  transform: translateX(4px);
}

.session-item-content {
  flex: 1;
  min-width: 0;
}

.session-item-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--color-text);
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 15px;
  line-height: 1.3;
}

.session-item-preview {
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 7px;
  opacity: 0.9;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.session-item-date {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.session-item-project {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  display: inline-flex;
  padding: 4px 8px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item-actions-wrapper {
  position: relative;
  flex: 0 0 auto;
  z-index: 130;
}

.btn-session-actions-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}

.btn-session-actions-toggle:hover,
.btn-session-actions-toggle.is-open {
  color: var(--color-text);
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.14);
}

.session-item-actions-menu {
  position: absolute;
  top: 40px;
  right: 0;
  min-width: 172px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 3px;
  border-radius: 10px;
  background: rgba(24, 24, 34, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-xl);
  z-index: 60;
}

.session-item-actions-menu.opens-up {
  top: auto;
  bottom: 40px;
}

.session-item-actions-menu.is-open {
  display: flex;
}

.session-action-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-secondary);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.session-action-menu-item:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.08);
}

.session-action-menu-item.btn-delete-session:hover {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
}

.session-action-menu-item.btn-save-delete-session:hover {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
}

/* ============================================================================
   Onboarding
   ============================================================================ */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 16000;
  background: rgba(3, 7, 18, 0.18);
  backdrop-filter: none;
}

.onboarding-card {
  position: fixed;
  padding: 18px;
  border-radius: 14px;
  background: rgba(18, 18, 26, 0.98);
  border: 1px solid rgba(139, 92, 246, 0.34);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  color: var(--color-text);
  z-index: 16003;
}

.onboarding-progress {
  color: var(--primary-light);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.onboarding-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.onboarding-card p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.onboarding-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.onboarding-actions-right {
  display: flex;
  gap: 8px;
}

.onboarding-link-btn,
.onboarding-secondary-btn,
.onboarding-primary-btn,
.onboarding-quick-actions button {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.onboarding-link-btn {
  background: transparent;
  color: var(--color-text-muted);
}

.onboarding-link-btn:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.06);
}

.onboarding-secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-secondary);
}

.onboarding-secondary-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-text);
}

.onboarding-secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.onboarding-primary-btn,
.onboarding-quick-actions button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow);
}

.onboarding-primary-btn:hover,
.onboarding-quick-actions button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.onboarding-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.onboarding-highlight {
  position: relative !important;
  z-index: 16002 !important;
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.34), 0 0 34px rgba(6, 182, 212, 0.38) !important;
  border-radius: 12px !important;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-2 {
  margin-top: 8px;
}

.mb-2 {
  margin-bottom: 8px;
}

/* ============================================================================
   Mobile Sidebar
   ============================================================================ */

@media (max-width: 600px) {
  .history-sidebar {
    width: 85vw;
  }
}

/* ============================================================================
   Login Screen
   ============================================================================ */

.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 50%, rgba(139, 92, 246, 0.15), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.12), transparent 50%),
    radial-gradient(circle at 40% 20%, rgba(59, 130, 246, 0.1), transparent 40%);
  animation: backgroundShift 30s ease-in-out infinite;
  pointer-events: none;
}

.login-container {
  background: rgba(22, 22, 31, 0.9);
  backdrop-filter: blur(30px) saturate(180%);
  border-radius: 24px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl), 0 0 80px rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
  margin: 20px;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.login-header {
  text-align: center;
  margin-bottom: 22px;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  fill: url(#logoGradient);
  filter: drop-shadow(0 0 24px rgba(139, 92, 246, 0.5));
  animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.login-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-input-group {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  fill: var(--color-text-muted);
  pointer-events: none;
  transition: var(--transition);
}

.login-input {
  width: 100%;
  padding: 16px 18px 16px 52px;
  background: var(--color-bg-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  color: var(--color-text);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
  font-weight: 500;
}

.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
  background: var(--color-bg-secondary);
}

.login-input:focus + .input-icon {
  fill: var(--primary);
}

.login-input::placeholder {
  color: var(--color-text-muted);
}

.login-button {
  padding: 16px 28px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  box-shadow: var(--shadow-lg), 0 0 40px rgba(139, 92, 246, 0.3);
  letter-spacing: 0.02em;
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl), 0 0 50px rgba(139, 92, 246, 0.4);
}

.login-button:active {
  transform: translateY(0);
}

.button-icon {
  width: 20px;
  height: 20px;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 14px 18px;
  border-radius: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.auth-error-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  color: #ffffff;
  text-decoration: none;
  background: rgba(34, 197, 94, 0.22);
  border: 1px solid rgba(34, 197, 94, 0.45);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

#errorActionLink {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-bottom: 12px;
}

#errorActionLink.hidden {
  display: none;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Responsive Login */
@media (max-width: 600px) {
  .login-container {
    margin: 20px;
    padding: 32px 24px;
  }

  .login-logo {
    width: 60px;
    height: 60px;
  }

  .login-title {
    font-size: 1.5rem;
  }
}

/* Image upload mobile adjustments */
@media (max-width: 600px) {
  .attachment-preview-item {
    min-width: 86px;
    max-width: 136px;
    height: 64px;
  }

  .attachment-preview-thumb {
    width: 44px;
    height: 44px;
  }

  .message-image {
    max-width: 220px;
    max-height: 150px;
  }
}

/* ============================================================================
   Acessibilidade - Reduzir Movimento
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .voice-button::before {
    animation: none;
  }

  .voice-button[data-state="listening"],
  .voice-button[data-state="recording"],
  .voice-button[data-state="processing"],
  .voice-button[data-state="speaking"],
  .voice-button[data-state="paused"] {
    animation: none;
  }

  body::before,
  body::after {
    animation: none;
  }

  .login-logo {
    animation: none;
  }

  .typing-dots span {
    animation: none;
  }
}

/* ============================================================================
   PWA Install Banner
   ============================================================================ */

.pwa-install-banner {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 520px);
  background: rgba(18, 18, 26, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  padding: 14px 16px;
  z-index: 9999;
  animation: pwaBannerSlideIn 0.35s ease;
}

@keyframes pwaBannerSlideIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-install-icon {
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1;
}

.pwa-install-text {
  flex: 1 1 auto;
  color: var(--color-text, #e4e4e7);
  font-size: 14px;
  line-height: 1.4;
}

.pwa-install-text b { color: #a78bfa; font-weight: 600; }

.pwa-install-text .ios-share-icon {
  display: inline-block;
  transform: translateY(1px);
  color: #06b6d4;
  font-weight: 700;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.pwa-install-primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pwa-install-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

.pwa-install-dismiss {
  background: transparent;
  color: #a1a1aa;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pwa-install-dismiss:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

@media (max-width: 480px) {
  .pwa-install-text { font-size: 13px; }
  .pwa-install-primary { padding: 7px 12px; font-size: 12px; }
}

.header-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  margin-left: 8px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s ease, transform 0.2s ease;
  vertical-align: middle;
}
.header-whatsapp:hover {
  opacity: 1;
  transform: scale(1.1);
}
@media (max-width: 480px) {
  .header-whatsapp {
    width: 24px;
    height: 24px;
  }
  .header-whatsapp svg {
    width: 14px;
    height: 14px;
  }
}

.login-disclaimer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}
.disclaimer-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin: 0 0 6px 0;
}
.disclaimer-text a {
  color: #60a5fa;
  text-decoration: underline;
  cursor: pointer;
}
.disclaimer-text a:hover {
  color: #93c5fd;
}
.disclaimer-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  margin: 0;
  line-height: 1.5;
}
.disclaimer-sub strong {
  color: rgba(255, 255, 255, 0.5);
}

.terms-modal-content {
  max-width: 580px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: left;
}
.terms-body {
  font-size: 13px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.75);
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 8px;
}
.terms-body p {
  margin: 8px 0;
}
.terms-body p strong {
  color: rgba(255, 255, 255, 0.9);
}
.terms-body ul {
  margin: 6px 0 12px 20px;
  padding: 0;
}
.terms-body ul li {
  margin: 4px 0;
}
.terms-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}
.terms-intro {
  font-style: italic;
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 16px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* ================================================================ */
/* Workspace (Agente Autônomo)                                       */
/* ================================================================ */

.btn-workspace {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: rgba(255, 255, 255, 0.9);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-workspace:hover {
  background: rgba(99, 102, 241, 0.25);
}

.workspace-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ws-tab {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.ws-tab.active {
  color: rgba(255, 255, 255, 0.95);
  border-bottom-color: #6366f1;
}

.ws-tab:hover {
  color: rgba(255, 255, 255, 0.8);
}

.ws-panel {
  max-height: 400px;
  overflow-y: auto;
}

.workspace-file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.workspace-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  font-size: 14px;
}

.workspace-file-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.workspace-file-icon {
  font-size: 18px;
}

.workspace-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-file-size {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

.workspace-journal {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.2);
  padding: 16px;
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.workspace-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workspace-tool-badge {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.workspace-empty {
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  padding: 24px;
  font-style: italic;
}
