/* ============================================
   Re-Kit Reko AI Page CSS — Premium Redesign
   ============================================ */

.reko-layout {
  display: flex;
  height: calc(100vh - var(--nav-h));
  margin-top: var(--nav-h);
  overflow: hidden;
}

/* ---- Sidebar ---- */
.reko-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
[dir="rtl"] .reko-sidebar { border-left: none; border-right: 1px solid var(--border); }

.reko-sidebar-header {
  padding: 24px 16px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.reko-sidebar-mascot { width: 70px; height: 70px; margin: 0 auto 10px; object-fit: contain; animation: float-mascot 4s ease-in-out infinite; }
.reko-sidebar-header h2 { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.reko-sidebar-header p { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }

.reko-modes-list { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }

.reko-mode-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.reko-mode-btn:hover { background: var(--bg-3); }
.reko-mode-btn.active {
  background: var(--primary-glow);
  border-color: rgba(87,242,135,0.25);
}
.mode-icon { font-size: 1.3rem; flex-shrink: 0; }
.mode-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.mode-desc { font-size: 0.72rem; color: var(--text-muted); margin-top: 1px; }

.reko-sidebar-actions { padding: 12px; border-top: 1px solid var(--border); }

/* ---- Chat Area ---- */
.reko-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  overflow: hidden;
}

.reko-chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.reko-mode-info { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; }
#active_mode_icon { font-size: 1.2rem; }

/* ============================================
   Messages Container
   ============================================ */
.reko-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}
.reko-messages::-webkit-scrollbar { width: 5px; }
.reko-messages::-webkit-scrollbar-track { background: transparent; }
.reko-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ============================================
   Base Message Row
   ============================================ */
.reko-msg {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 82%;
  animation: msg-in 0.28s cubic-bezier(0.16,1,0.3,1);
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.reko-msg.user {
  flex-direction: row-reverse;
  align-self: flex-end;
  animation: msg-in-user 0.28s cubic-bezier(0.16,1,0.3,1);
}
@keyframes msg-in-user {
  from { opacity: 0; transform: translateY(10px) translateX(6px); }
  to   { opacity: 1; transform: translateY(0) translateX(0); }
}

/* ============================================
   Avatars
   ============================================ */
.reko-msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}
.reko-msg.ai .reko-msg-avatar {
  background: linear-gradient(135deg, rgba(87,242,135,0.18), rgba(87,242,135,0.06));
  border: 1.5px solid rgba(87,242,135,0.3);
  box-shadow: 0 0 0 3px rgba(87,242,135,0.08);
}
.reko-msg-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ============================================
   AI Message Bubble
   ============================================ */
.reko-msg.ai .reko-msg-bubble {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.reko-msg.ai .reko-msg-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(87,242,135,0.55);
  border-radius: 4px 18px 18px 18px;
  padding: 14px 18px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-primary);
  word-break: break-word;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  position: relative;
  max-width: 100%;
}
[dir="rtl"] .reko-msg.ai .reko-msg-content {
  border-left: 1px solid var(--border);
  border-right: 3px solid rgba(87,242,135,0.55);
  border-radius: 18px 4px 18px 18px;
}
[data-theme="light"] .reko-msg.ai .reko-msg-content {
  background: #fff;
  box-shadow: 0 2px 14px rgba(0,0,0,0.06);
}

/* AI text typography */
.reko-msg.ai .reko-msg-content p {
  margin: 0 0 8px 0;
}
.reko-msg.ai .reko-msg-content p:last-child { margin-bottom: 0; }
.reko-msg.ai .reko-msg-content ul,
.reko-msg.ai .reko-msg-content ol {
  margin: 6px 0 6px 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
[dir="rtl"] .reko-msg.ai .reko-msg-content ul,
[dir="rtl"] .reko-msg.ai .reko-msg-content ol { margin: 6px 18px 6px 0; }
.reko-msg.ai .reko-msg-content li { line-height: 1.7; }
.reko-msg.ai .reko-msg-content strong { color: var(--primary); font-weight: 700; }
.reko-msg.ai .reko-msg-content em { color: var(--text-secondary); font-style: italic; }
.reko-msg.ai .reko-msg-content h3, .reko-msg.ai .reko-msg-content h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 10px 0 4px;
}

/* ============================================
   User Message Bubble
   ============================================ */
.reko-msg.user .reko-msg-bubble {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.reko-msg.user .reko-msg-content {
  background: linear-gradient(145deg, var(--primary), #3dd68c);
  color: #061910;
  border-radius: 18px 4px 18px 18px;
  padding: 13px 18px;
  font-size: 0.9rem;
  line-height: 1.75;
  font-weight: 500;
  word-break: break-word;
  box-shadow: 0 4px 18px rgba(87,242,135,0.25);
  white-space: pre-wrap;
}
[dir="rtl"] .reko-msg.user .reko-msg-content {
  border-radius: 4px 18px 18px 18px;
}
[data-theme="light"] .reko-msg.user .reko-msg-content {
  box-shadow: 0 4px 16px rgba(87,242,135,0.35);
}

/* ============================================
   Message Timestamp & Meta
   ============================================ */
.reko-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}
.reko-msg-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.7;
  letter-spacing: 0.2px;
}

/* ============================================
   Message Actions (Copy / Regenerate)
   ============================================ */
.reko-msg-actions {
  display: flex;
  gap: 5px;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.reko-msg:hover .reko-msg-actions { opacity: 1; }
.reko-msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.reko-msg-action-btn:hover {
  background: var(--primary-glow);
  border-color: rgba(87,242,135,0.3);
  color: var(--primary);
}
.reko-msg-action-btn.copied {
  background: rgba(87,242,135,0.15);
  color: var(--primary);
  border-color: rgba(87,242,135,0.35);
}

/* ============================================
   Code Blocks — Enhanced
   ============================================ */
.reko-msg-content .code-block-wrap {
  margin: 12px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(87,242,135,0.12);
}
.reko-msg-content .code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(87,242,135,0.06);
  border-bottom: 1px solid rgba(87,242,135,0.12);
  padding: 7px 14px;
}
.code-block-lang {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.reko-msg-content pre {
  background: #0d1117 !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 14px 16px !important;
  font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace !important;
  font-size: 0.82rem !important;
  line-height: 1.65 !important;
  color: #e2e8f0 !important;
  overflow-x: auto;
  white-space: pre;
  margin: 0 !important;
}
.reko-msg-content code {
  font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace !important;
  font-size: 0.84em !important;
  background: rgba(87,242,135,0.1);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(87,242,135,0.15);
}
.reko-msg-content pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  border: none !important;
}
.code-copy-btn {
  font-family: 'Cairo', 'Inter', sans-serif !important;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.code-copy-btn:hover { color: var(--primary); border-color: rgba(87,242,135,0.3); }
.code-copy-btn.copied { color: var(--primary); background: rgba(87,242,135,0.12); }

/* Syntax highlighting colors */
.kw  { color: #ff79c6; font-weight: 600; }
.str { color: #f1fa8c; }
.num { color: #bd93f9; }
.cmt { color: #6272a4; font-style: italic; }

/* ============================================
   Typing Indicator
   ============================================ */
.reko-typing .reko-msg-content {
  padding: 16px 20px;
  min-width: 72px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.typing-dots { display: flex; gap: 5px; align-items: center; }
.typing-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typing-bounce 1.3s ease-in-out infinite;
  opacity: 0.5;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-7px); opacity: 1; }
}

/* ============================================
   Welcome Message
   ============================================ */
.reko-welcome .reko-msg-avatar {
  width: 44px; height: 44px;
  border: 2px solid rgba(87,242,135,0.35);
  box-shadow: 0 0 0 4px rgba(87,242,135,0.08);
}
.reko-welcome .reko-msg-content {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 4px 0;
}
.reko-welcome .reko-msg-content p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.welcome-chip {
  padding: 7px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s;
  font-weight: 500;
}
.welcome-chip:hover {
  border-color: rgba(87,242,135,0.4);
  color: var(--primary);
  background: var(--primary-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(87,242,135,0.12);
}

/* ============================================
   Input Area
   ============================================ */
.reko-input-area {
  padding: 16px 20px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}

.reko-input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.reko-input-box:focus-within {
  border-color: rgba(87,242,135,0.5);
  box-shadow: 0 0 0 3px rgba(87,242,135,0.08);
}

.reko-textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
  font-family: inherit;
  padding: 2px 0;
}
.reko-textarea::placeholder { color: var(--text-muted); }

.reko-send-btn {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), #3dd68c);
  color: #061910;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(87,242,135,0.25);
}
.reko-send-btn:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 6px 18px rgba(87,242,135,0.4);
}
.reko-send-btn:disabled { opacity: 0.4; transform: none; box-shadow: none; }

.reko-disclaimer {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  opacity: 0.7;
}

/* ============================================
   Mic Button
   ============================================ */
.reko-mic-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.reko-mic-btn:hover {
  background: var(--primary-glow);
  color: var(--primary);
  border-color: rgba(87,242,135,0.4);
  transform: scale(1.05);
}
.reko-mic-btn.recording {
  background: rgba(239,68,68,0.15);
  border-color: #ef4444;
  color: #ef4444;
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.35); }
  50% { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
}

/* ============================================
   Clear Chat Buttons
   ============================================ */
.reko-clear-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.reko-clear-btn:hover {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.35);
  color: #ef4444;
}
.reko-clear-btn svg { flex-shrink: 0; }

.reko-clear-topbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.reko-clear-topbar-btn:hover {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.35);
  color: #ef4444;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .reko-sidebar { display: none; }
  .reko-sidebar.open {
    display: flex;
    position: fixed;
    top: var(--nav-h); left: 0;
    width: 100%;
    height: calc(100vh - var(--nav-h));
    z-index: 800;
  }
  [dir="rtl"] .reko-sidebar.open { left: auto; right: 0; }
  .reko-msg { max-width: 92%; }
  .reko-messages { padding: 20px 16px; gap: 16px; }
}

/* ============================================
   Mobile Touch Fixes
   ============================================ */
.reko-mode-btn, .welcome-chip, .reko-send-btn, .reko-mic-btn,
.reko-clear-btn, .reko-clear-topbar-btn, .reko-msg-action-btn,
.code-copy-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.reko-messages { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.reko-mode-btn { cursor: pointer; }
