
/* ================================================================
   ArcReady AI Components — ai.css
   Color tokens: #CC0000 red | #1A1A1A charcoal | #FFFFFF white
                 #F57C00 amber | #2E7D32 green | #F5F5F5 light-gray
   ================================================================ */

/* ── Shared AI panel base ───────────────────────────────────────── */
.ai-panel {
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  animation: ai-fade-in 0.25s ease;
}
@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading dots ───────────────────────────────────────────────── */
.ai-loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 16px;
}
.ai-loading-dots span {
  width: 6px; height: 6px;
  background: #999;
  border-radius: 50%;
  animation: ai-dot-bounce 1.2s infinite ease-in-out;
}
.ai-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%            { transform: scale(1);   opacity: 1;   }
}

/* ================================================================
   1. AI ANSWER EXPLAINER
   ================================================================ */
.btn-explain-ai {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 14px;
  background: #1A1A1A;
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn-explain-ai:hover  { background: #333; transform: translateY(-1px); }
.btn-explain-ai:active { transform: translateY(0); }
.btn-explain-ai:disabled { opacity: 0.6; cursor: not-allowed; }

.ai-explain-panel {
  background: #EEF4FF;
  border: 1.5px solid #4A90D9;
  border-left: 4px solid #4A90D9;
  border-radius: 8px;
  padding: 12px 15px;
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #1A1A1A;
  animation: ai-fade-in 0.25s ease;
}
.ai-explain-panel .ai-explain-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #2255AA;
  margin-bottom: 7px;
}
.ai-explain-panel .ai-explain-header .ai-badge {
  background: #2255AA;
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.ai-explain-panel p { margin: 0; color: #222; }

/* ================================================================
   2. FLOATING STUDY ASSISTANT (Chat Bubble)
   ================================================================ */
#ai-chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: Inter, Roboto, sans-serif;
}

/* FAB Toggle Button */
#ai-chat-toggle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #CC0000;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(204,0,0,0.4);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
#ai-chat-toggle:hover {
  background: #AA0000;
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(204,0,0,0.5);
}
#ai-chat-toggle .chat-icon-open  { display: flex; }
#ai-chat-toggle .chat-icon-close { display: none; }
#ai-chat-bubble.is-open #ai-chat-toggle .chat-icon-open  { display: none; }
#ai-chat-bubble.is-open #ai-chat-toggle .chat-icon-close { display: flex; }

/* Chat Panel */
#ai-chat-panel {
  display: none;
  flex-direction: column;
  width: 360px;
  height: 480px;
  background: #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 10px;
  overflow: hidden;
  animation: ai-chat-slide-in 0.2s ease;
}
#ai-chat-bubble.is-open #ai-chat-panel { display: flex; }
@keyframes ai-chat-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Chat Header */
#ai-chat-header {
  background: #1A1A1A;
  color: #FFFFFF;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#ai-chat-header .chat-avatar {
  width: 32px; height: 32px;
  background: #CC0000;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
#ai-chat-header .chat-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}
#ai-chat-header .chat-subtitle {
  font-size: 11px;
  color: #aaa;
  font-weight: 400;
}

/* Messages area */
#ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#ai-chat-messages::-webkit-scrollbar { width: 4px; }
#ai-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.ai-msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.ai-msg.ai-msg--user {
  background: #CC0000;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.ai-msg.ai-msg--bot {
  background: #F5F5F5;
  color: #1A1A1A;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.ai-msg.ai-msg--system {
  background: #FFF3CD;
  color: #856404;
  align-self: center;
  font-size: 12px;
  font-style: italic;
  border-radius: 8px;
  text-align: center;
  max-width: 95%;
  padding: 7px 12px;
}

/* Chat limit banner */
#ai-chat-limit-banner {
  display: none;
  background: #FFF8E1;
  border-top: 1px solid #F57C00;
  padding: 8px 14px;
  font-size: 12px;
  color: #7a4f00;
  text-align: center;
  flex-shrink: 0;
}

/* Input row */
#ai-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
  background: #fafafa;
}
#ai-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: none;
  height: 36px;
  transition: border-color 0.15s;
  background: #fff;
}
#ai-chat-input:focus { border-color: #CC0000; }
#ai-chat-send {
  background: #CC0000;
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: background 0.15s;
}
#ai-chat-send:hover { background: #AA0000; }
#ai-chat-send:disabled { background: #ccc; cursor: not-allowed; }

/* ================================================================
   3. LAB HINT SYSTEM
   ================================================================ */
#ai-hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: #F57C00;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
  margin-top: 8px;
  width: 100%;
  justify-content: center;
}
#ai-hint-btn:hover  { background: #E65100; transform: translateY(-1px); }
#ai-hint-btn:active { transform: translateY(0); }
#ai-hint-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; }

.ai-hint-counter {
  font-size: 10px;
  opacity: 0.85;
  margin-left: 4px;
}

#ai-hint-panel {
  display: none;
  background: #FFF8E1;
  border: 1.5px solid #F57C00;
  border-left: 4px solid #F57C00;
  border-radius: 8px;
  padding: 11px 14px;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: #1A1A1A;
  animation: ai-fade-in 0.2s ease;
}
#ai-hint-panel .ai-hint-header {
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #E65100;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
#ai-hint-panel p { margin: 0; }

/* ================================================================
   4. WEAK AREA COACH (Progress Tab)
   ================================================================ */
#ai-coach-section {
  margin-top: 24px;
}
#ai-coach-section .ai-coach-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
#ai-coach-section .ai-coach-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1A1A1A;
}
#ai-coach-section .ai-coach-header .ai-coach-badge {
  background: #1A1A1A;
  color: #fff;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

#ai-coach-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #666;
  font-size: 13px;
  padding: 12px 0;
}

#ai-coach-card {
  display: none;
  background: #FFFFFF;
  border: 1.5px solid #1A1A1A;
  border-radius: 10px;
  padding: 18px 20px;
  line-height: 1.65;
  font-size: 14px;
  color: #1A1A1A;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
#ai-coach-card ul {
  margin: 10px 0 0 0;
  padding-left: 20px;
}
#ai-coach-card li {
  margin-bottom: 8px;
}
#ai-coach-card li:last-child { margin-bottom: 0; }
#ai-coach-card strong { color: #CC0000; }

#ai-coach-regenerate {
  display: none;
  margin-top: 10px;
  padding: 6px 13px;
  background: transparent;
  color: #666;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
#ai-coach-regenerate:hover { border-color: #CC0000; color: #CC0000; }

.ai-coach-error {
  color: #999;
  font-size: 13px;
  font-style: italic;
  padding: 8px 0;
}
