/* Variáveis CSS alinhadas com a plataforma */
:root {
  --primary-color: #00a2e8;
  --primary-light: rgba(0, 162, 232, 0.15);
  --primary-dark: #415a77;
  --secondary-color: #415a77;
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --border-color: rgba(0, 0, 0, 0.08);
  --background-light: transparent;
  --background-card: rgba(255, 255, 255, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.6);
  --bg-glass-hover: rgba(255, 255, 255, 0.8);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.1);
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Tema Aprova Fácil */
.aprova-facil {
  --primary-color: #7b04db;
  --primary-light: rgba(123, 4, 219, 0.15);
  --primary-dark: #5a0399;
  --secondary-color: #ff8c00;
}

/* ===== RIBBON BACKGROUND ===== */
.quanta-ribbon-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  z-index: 0;
  overflow: hidden;
}

.quanta-ribbon-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Aprova Fácil light purple background */
.aprova-facil .quanta-ribbon-container,
.quanta-ribbon-container.aprova-facil {
  background: linear-gradient(135deg, #f5f0fa 0%, #ebe0f5 100%) !important;
}

/* ===== LAYOUT INTEGRADO COM GLASSMORPHISM ===== */
.chat-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  background: transparent;
  z-index: 1;
  transition: var(--transition);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  background: transparent;
  z-index: 10;
  position: relative;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  z-index: 2;
  position: sticky;
  top: 0;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.chat-header h5 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  background: linear-gradient(135deg, var(--primary-color), #33b5ed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.aprova-facil .chat-header h5 {
  background: linear-gradient(135deg, #9f2bff, #ff8c00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.form-control {
  border: none !important;
  &:focus {
    box-shadow: none !important;
  }
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) transparent;
  position: relative;
}

.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 3px;
  opacity: 0.6;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  opacity: 1;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 0;
  width: 100%;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: fadeIn 0.3s ease;
  width: 100%;
  padding: 0 16px;
}

.message.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

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

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
  transition: var(--transition);
}

.message.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--primary-color), #33b5ed);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 162, 232, 0.3);
}

.aprova-facil .message.user .message-avatar {
  background: linear-gradient(135deg, #7b04db, #9f2bff);
  box-shadow: 0 4px 15px rgba(123, 4, 219, 0.3);
}

.message.assistant .message-avatar,
.message.system .message-avatar {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--primary-color);
  border: 2px solid rgba(0, 162, 232, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.aprova-facil .message.assistant .message-avatar,
.aprova-facil .message.system .message-avatar {
  color: #7b04db;
  border-color: rgba(123, 4, 219, 0.2);
}

.message.error .message-avatar {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.message-content {
  flex: 0 1 auto;
  max-width: 75%;
  padding: 16px 20px;
  border-radius: var(--radius-xl) 0 var(--radius-xl) var(--radius-xl) !important;
  font-size: 0.95rem;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--primary-color), #33b5ed);
  color: white;
  border-bottom-right-radius: 6px !important;
  box-shadow: 0 8px 32px rgba(0, 162, 232, 0.25);
}

.aprova-facil .message.user .message-content {
  background: linear-gradient(135deg, #7b04db, #9f2bff);
  box-shadow: 0 8px 32px rgba(123, 4, 219, 0.25);
}

.message.assistant .message-content {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 6px !important;
}

.message.system .message-content {
  background: rgba(0, 162, 232, 0.1);
  color: var(--primary-color);
  border: 1px solid rgba(0, 162, 232, 0.2);
  font-weight: 500;
}

.aprova-facil .message.system .message-content {
  background: rgba(123, 4, 219, 0.1);
  color: #7b04db;
  border: 1px solid rgba(123, 4, 219, 0.2);
}

.message.error .message-content {
  background: #ef4444;
  color: white;
}

.message-content p {
  margin-bottom: 12px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.chat-input-container {
  padding: 20px 24px 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 
    0 -8px 32px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.chat-form {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

.suggestion-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
}

.pill-item {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.pill-item:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 
    0 8px 20px rgba(0, 162, 232, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.08);
  color: var(--primary-color);
}

.aprova-facil .pill-item:hover {
  border-color: #7b04db;
  box-shadow: 
    0 8px 20px rgba(123, 4, 219, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.08);
  color: #7b04db;
}

/* Modern Input Group */
.input-group {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 28px;
  padding: 6px 6px 6px 20px;
  transition: var(--transition);
  min-height: 56px;
  position: relative;
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 1);
}

.input-group:focus-within {
  border-color: var(--primary-color);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 
    0 0 0 3px rgba(0, 162, 232, 0.12),
    0 8px 32px rgba(0, 162, 232, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 1);
}

.aprova-facil .input-group:focus-within {
  border-color: #7b04db;
  box-shadow: 
    0 0 0 3px rgba(123, 4, 219, 0.12),
    0 8px 32px rgba(123, 4, 219, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 1);
}

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  padding: 8px 0;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
  min-height: 24px;
  font-family: inherit;
  margin: 0;
}

#messageInput::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Modern Send Button */
.btn-send {
  background: linear-gradient(135deg, var(--primary-color) 0%, #33b5ed 100%);
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 
    0 4px 12px rgba(0, 162, 232, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.btn-send::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  border-radius: 50%;
}

.btn-send i {
  font-size: 1.25rem !important;
  transform: translateX(1px);
  position: relative;
  z-index: 1;
}

.btn-send:hover {
  transform: scale(1.08);
  box-shadow: 
    0 6px 20px rgba(0, 162, 232, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-send:active {
  transform: scale(0.95);
  box-shadow: 
    0 2px 8px rgba(0, 162, 232, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.aprova-facil .btn-send {
  background: linear-gradient(135deg, #7b04db 0%, #9f2bff 100%);
  box-shadow: 
    0 4px 12px rgba(123, 4, 219, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.aprova-facil .btn-send:hover {
  box-shadow: 
    0 6px 20px rgba(123, 4, 219, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-send.active {
  animation: pulse-send 1.5s ease-in-out infinite;
}

@keyframes pulse-send {
  0%, 100% { box-shadow: 0 4px 12px rgba(0, 162, 232, 0.35); }
  50% { box-shadow: 0 4px 20px rgba(0, 162, 232, 0.5); }
}

/* Typing indicators */
.typing-indicator {
  display: none;
  padding: 10px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  position: absolute;
  bottom: 100%;
  left: 24px;
  margin-bottom: 10px;
  box-shadow: 
    0 4px 20px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.typing-indicator.visible {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.typing-indicator span:nth-of-type(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-of-type(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-of-type(3) {
  animation-delay: 0.4s;
}

/* Thinking message */
.message.thinking {
  align-self: flex-start;
  width: 100%;
  justify-content: flex-start;
  padding: 0 16px;
}

.message.thinking .message-avatar {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--primary-color);
  border: 2px solid var(--primary-light);
}

.message.thinking .message-content {
  background: var(--bg-glass-hover);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 6px !important;
  display: flex;
  align-items: center;
  min-height: 50px;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

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

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

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

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

/* Animações simples e suaves */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.4;
  }
  40% {
    opacity: 1;
  }
}

/* Code blocks */
pre {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-primary);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.875rem;
  margin: 12px 0;
  border: 1px solid var(--border-color);
  font-family: "Monaco", "Consolas", monospace;
  line-height: 1.5;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

code {
  font-family: "Monaco", "Consolas", monospace;
  background: var(--bg-glass);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

pre code {
  background: transparent;
  padding: 0;
}

/* Fix for sidebar */
@media (min-width: 768px) {
  /* Quando a sidebar está aberta (280px) */
  .chat-fullscreen {
    left: 280px;
    width: calc(100vw - 280px);
  }

  /* Quando a sidebar está fechada/colapsada (70px ou similar) */
  .modern-sidebar.collapsed ~ .content .chat-fullscreen,
  .sidebar.close ~ .content .chat-fullscreen {
    left: 70px;
    width: calc(100vw - 70px);
  }

  /* Para sidebars que se escondem completamente */
  .sidebar.hidden ~ .content .chat-fullscreen {
    left: 0;
    width: 100vw;
  }
}

/* Utility classes for different sidebar states */
.chat-fullscreen.sidebar-open {
  left: 280px;
  width: calc(100vw - 280px);
}

.chat-fullscreen.sidebar-collapsed {
  left: 70px;
  width: calc(100vw - 70px);
}

.chat-fullscreen.sidebar-hidden {
  left: 0;
  width: 100vw;
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .chat-fullscreen {
    left: 0 !important;
    width: 100vw !important;
    z-index: 5; /* Lower than sidebar */
  }

  .chat-header {
    padding: 16px;
    justify-content: flex-end;
  }

  .chat-header h5 {
    font-size: 1.2rem;
  }

  .chat-messages {
    padding: 16px 0;
    gap: 16px;
  }

  .message {
    padding: 0 12px;
  }

  .message-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }

  .message-content {
    font-size: 0.9rem;
    padding: 12px 16px;
    max-width: 80%;
  }

  .suggestion-pills {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }

  .pill-item {
    padding: 12px 16px;
    font-size: 0.85rem;
    min-height: 44px;
  }

  .chat-input-container {
    padding: 16px 12px;
  }

  .input-group {
    padding: 8px 12px;
    min-height: 40px;
  }

  #messageInput {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 6px 0;
  }

  .btn-send {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 6px;
  }

  /* Hide sidebar on mobile */
  .sidebar,
  .modern-sidebar {
    z-index: 1000; /* Ensure sidebar is above chat */
  }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 1024px) {
  .chat-fullscreen.sidebar-open {
    left: 240px;
    width: calc(100vw - 240px);
  }

  .chat-fullscreen.sidebar-collapsed {
    left: 60px;
    width: calc(100vw - 60px);
  }

  .suggestion-pills {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Performance optimization */
@media (prefers-reduced-motion: reduce) {
  .thinking-dots span,
  .typing-indicator span {
    animation: none;
  }

  .message {
    animation: none;
  }

  .pill-item {
    transition: none;
  }

  .quanta-ribbon-container canvas {
    display: none;
  }

  * {
    transition: none !important;
  }
}
