/* sam quiz : chat avec Samoloski AI */

/* le bouton robot remplace le bouton + Matiere (le bouton reste dans le code, simplement cache) */
#btn-add-subject {
  display: none;
}

.chat-fab {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 15;
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e1b4b, #4338ca);
  box-shadow: 0 8px 22px rgba(67, 56, 202, 0.5);
  cursor: pointer;
  animation: popIn 0.5s ease 0.4s both, fabGlow 3s ease-in-out 1.2s infinite;
  transition: transform 0.12s ease;
}

.chat-fab[hidden] {
  display: none;
}

.chat-fab:active {
  transform: scale(0.92);
}

.chat-fab svg {
  display: block;
  width: 44px;
  height: 44px;
  margin: auto;
}

@keyframes fabGlow {
  0%, 100% { box-shadow: 0 8px 22px rgba(67, 56, 202, 0.5); }
  50%      { box-shadow: 0 8px 30px rgba(14, 165, 233, 0.75); }
}

.chat-open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
}

.chat-open:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.32);
}

.chat-open span {
  font-size: 1.2rem;
}

.chat-screen {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: slideUp 0.3s ease both;
}

.chat-screen[hidden] {
  display: none;
}

.chat-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, #1e1b4b, #4338ca);
  color: #fff;
}

.chat-top .quiz-close {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.chat-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-title small {
  font-size: 0.75rem;
  opacity: 0.8;
}

.chat-left {
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.chat-msgs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: fadeUp 0.25s ease both;
}

.chat-msg.me {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-bottom-right-radius: 6px;
}

.chat-msg.ai {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}

.chat-msg.err {
  align-self: center;
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.9rem;
  text-align: center;
}

.chat-welcome {
  padding: 10px 6px;
  text-align: center;
  color: var(--muted);
}

.chat-welcome img {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.chat-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.chat-chip {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.chat-chip:active {
  background: #eef0ff;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 14px;
}

.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingDot 1s infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1); opacity: 1; }
}

.chat-input {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
}

.chat-input textarea {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  font: inherit;
  resize: none;
}

.chat-input textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.chat-input button {
  flex: none;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.chat-input button:disabled {
  opacity: 0.45;
}
