/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body { margin: 0; padding: 0; }

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar { position: relative; min-width: 256px; }
.sidebar.collapsed { min-width: 68px; width: 68px !important; }
.sidebar.collapsed .sidebar-text { display: none; }
.sidebar.collapsed #collapse-icon { transform: rotate(180deg); }

/* ── Nav buttons ─────────────────────────────────────────────────────── */
.nav-btn { color: #94a3b8; }
.nav-btn:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; }
.nav-btn.active { background: rgba(108,62,244,0.15); color: #a78bfa; }

/* ── Tab content ─────────────────────────────────────────────────────── */
.tab-content { display: none !important; }
.tab-content:not(.hidden) { display: flex !important; flex-direction: column; }
#tab-chat:not(.hidden)     { display: flex !important; flex-direction: column; }
#tab-employees:not(.hidden) { display: flex !important; flex-direction: row; }
#tab-dashboard:not(.hidden),
#tab-leave:not(.hidden),
#tab-approvals:not(.hidden),
#tab-mission:not(.hidden),
#tab-helpdesk:not(.hidden),
#tab-assets:not(.hidden),
#tab-departments:not(.hidden),
#tab-reports:not(.hidden),
#tab-planner:not(.hidden),
#tab-tasks:not(.hidden),
#tab-quick:not(.hidden),
#tab-slides:not(.hidden),
#tab-settings:not(.hidden) { display: block !important; }

/* ── Profile Tabs ────────────────────────────────────────────────────── */
.profile-tab-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-weight: 600;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}
.profile-tab-btn.active {
  border-bottom-color: #6C3EF4;
  color: #6C3EF4;
}

/* ── Chat bubbles ────────────────────────────────────────────────────── */
.msg-user .bubble {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
  max-width: 36rem;
}
.msg-ai .bubble {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.msg-user { display: flex; justify-content: flex-end; }
.msg-ai { display: flex; justify-content: flex-start; gap: 0.75rem; }

/* ── Typing indicator ────────────────────────────────────────────────── */
.typing-dot {
  width: 7px; height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: .5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Prose rendering for markdown ────────────────────────────────────── */
.prose-content h1, .prose-content h2, .prose-content h3 {
  font-weight: 700; margin-top: 1rem; margin-bottom: 0.375rem; color: #1e293b;
}
.prose-content h1 { font-size: 1.1rem; }
.prose-content h2 { font-size: 1rem; }
.prose-content h3 { font-size: 0.9rem; }
.prose-content p { margin: 0.375rem 0; line-height: 1.65; }
.prose-content ul, .prose-content ol { padding-left: 1.25rem; margin: 0.375rem 0; }
.prose-content li { margin: 0.2rem 0; line-height: 1.6; }
.prose-content strong { font-weight: 700; color: #1e293b; }
.prose-content em { font-style: italic; }
.prose-content code {
  background: #f1f5f9; color: #7c3aed;
  padding: 0.1rem 0.35rem; border-radius: 0.3rem;
  font-size: 0.82em; font-family: 'Fira Code', monospace;
}
.prose-content pre {
  background: #1e293b; color: #e2e8f0;
  padding: 0.75rem 1rem; border-radius: 0.75rem;
  overflow-x: auto; margin: 0.5rem 0;
}
.prose-content pre code { background: transparent; color: inherit; padding: 0; }
.prose-content blockquote {
  border-left: 3px solid #7c3aed;
  padding-left: 0.75rem; margin: 0.5rem 0;
  color: #475569;
}
.prose-content table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.85rem; }
.prose-content th { background: #f8fafc; font-weight: 600; text-align: left; padding: 0.4rem 0.6rem; border: 1px solid #e2e8f0; }
.prose-content td { padding: 0.4rem 0.6rem; border: 1px solid #e2e8f0; }
.prose-content hr { border: none; border-top: 1px solid #e2e8f0; margin: 0.75rem 0; }

/* ── User bubble prose (white text) ─────────────────────────────────── */
.msg-user .prose-content,
.msg-user .prose-content strong,
.msg-user .prose-content h1,
.msg-user .prose-content h2,
.msg-user .prose-content h3 { color: white; }
.msg-user .prose-content code { background: rgba(255,255,255,0.2); color: white; }
.msg-user .prose-content blockquote { border-color: rgba(255,255,255,0.5); color: rgba(255,255,255,0.85); }

/* ── Task cards ──────────────────────────────────────────────────────── */
.task-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s;
}
.task-card:hover { border-color: #c4b5fd; box-shadow: 0 2px 8px rgba(124,58,237,0.08); }
.task-card.done { opacity: 0.55; }
.task-card.done .task-title { text-decoration: line-through; color: #9ca3af; }

/* ── Task filter buttons ─────────────────────────────────────────────── */
.task-filter { background: white; color: #6b7280; border-color: #e5e7eb; }
.task-filter:hover { background: #f5f3ff; border-color: #c4b5fd; color: #7c3aed; }
.task-filter.active { background: #7c3aed; border-color: #7c3aed; color: white; }

/* ── Quick action cards ──────────────────────────────────────────────── */
.quick-action-card { transition: all 0.2s ease; }
.quick-action-card:hover { transform: translateY(-2px); }

/* ── Time blocks ─────────────────────────────────────────────────────── */
.time-block-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #f9fafb;
}
.time-block-row:last-child { border-bottom: none; }
.time-block-color { width: 4px; border-radius: 99px; align-self: stretch; min-height: 36px; }

/* ── Suggestion chips ────────────────────────────────────────────────── */
.suggestion-chip { transition: all 0.15s ease; }

/* ── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ── Toast ───────────────────────────────────────────────────────────── */
#toast.show { transform: translateY(0); opacity: 1; }

/* ── AI plan loading ─────────────────────────────────────────────────── */
.ai-generating {
  display: flex; align-items: center; gap: 0.5rem;
  color: #7c3aed; font-size: 0.8rem; font-weight: 500;
}
.ai-generating-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #7c3aed;
  animation: bounce 1.4s infinite ease-in-out both;
}

/* ── Focus styles ────────────────────────────────────────────────────── */
textarea:focus, input:focus, select:focus { outline: none; }

/* ── Message action toolbars (copy / edit) ──────────────────────────────── */

/* User message wrapper — stacks bubble + edit box + time */
.msg-wrapper-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  position: relative;
  max-width: 48rem;
  width: 100%;
}

/* Action buttons row — hidden until hover */
.msg-actions-user {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.15s ease;
  order: -1;           /* sits above bubble */
  align-self: flex-end;
}
.msg-wrapper-user:hover .msg-actions-user { opacity: 1; }

/* AI bubble wrapper — relative container so copy btn can be positioned inside */
.msg-bubble-wrap {
  position: relative;
  display: block;
}

/* Quick Action result bubble — same padding as AI chat bubble */
.quick-result-bubble {
  padding-bottom: 2rem !important;
}

/* The bubble itself — extra bottom padding so last line never hides under button */
.msg-bubble-ai {
  padding-bottom: 2rem !important;
}

/* Copy button — absolute inside wrapper, bottom-right corner of bubble */
.msg-copy-ai {
  position: absolute;
  bottom: 0.45rem;
  right: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.375rem;
  border: 1px solid #e5e7eb;
  background: white;
  color: #9ca3af;
  font-size: 0.65rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s, border-color 0.15s, background 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  z-index: 1;
}
.msg-ai:hover .msg-copy-ai        { opacity: 1; }
#quick-result-wrap:hover .msg-copy-ai { opacity: 1; }
#quick-result-wrap .msg-copy-ai    { opacity: 0.3; } /* always faintly visible in Quick Actions */
.msg-copy-ai:hover                 { background: #f5f3ff; border-color: #c4b5fd; color: #7c3aed; }

/* Reply-to-design button — sits left of the copy button on AI messages */
.msg-reply-ai {
  position: absolute;
  bottom: 0.45rem;
  right: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.375rem;
  border: 1px solid #e5e7eb;
  background: white;
  color: #9ca3af;
  font-size: 0.65rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s, border-color 0.15s, background 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  z-index: 1;
}
.msg-ai:hover .msg-reply-ai { opacity: 1; }
.msg-reply-ai:hover         { background: #f5f3ff; border-color: #c4b5fd; color: #7c3aed; }
.msg-copy-ai.msg-action-copied     { opacity: 1 !important; background: #ecfdf5 !important; border-color: #6ee7b7 !important; color: #059669 !important; }

/* Shared action button */
.msg-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.4rem;
  border: 1px solid #e5e7eb;
  background: white;
  color: #6b7280;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.msg-action-btn:hover { background: #f5f3ff; border-color: #c4b5fd; color: #7c3aed; }
.msg-action-copied    { background: #ecfdf5 !important; border-color: #6ee7b7 !important; color: #059669 !important; }

/* Timestamp below bubble */
.msg-time {
  font-size: 0.65rem;
  color: #9ca3af;
  padding-right: 0.25rem;
}

/* ── Inline edit box ─────────────────────────────────────────────────────── */
.msg-edit-box {
  width: 100%;
  min-width: min(48rem, 100%);
  background: white;
  border: 1.5px solid #a78bfa;
  border-radius: 0.875rem;
  padding: 0.625rem 0.75rem;
  box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}
.msg-edit-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #1f2937;
  background: transparent;
  min-height: 2.5rem;
  max-height: 12rem;
  overflow-y: auto;
  font-family: inherit;
}
.msg-edit-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid #f3f4f6;
}
.msg-edit-send {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.msg-edit-send:hover { opacity: 0.88; }
.msg-edit-cancel {
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid #e5e7eb;
  background: white;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.msg-edit-cancel:hover { background: #f9fafb; border-color: #d1d5db; color: #374151; }

/* ── Chat action bar (cross-tab integration) ─────────────────────────── */
.chat-action-bar {
  margin-top: 0.5rem;
  padding: 0.25rem 0 0.5rem 0;
  display: block;          /* full column width — bubble is unaffected */
}
.chat-action-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}
.chat-action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: flex-start;
  width: fit-content;      /* container hugs its pill children — never full-row */
  max-width: 100%;
}
.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  border: 1.5px solid;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  background: white;
  line-height: 1.4;
  width: max-content;      /* key: never stretch wider than label+desc */
  white-space: nowrap;     /* keep label on one line */
}
.chat-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.chat-action-btn:active { transform: translateY(0); }
.chat-action-desc {
  font-size: 0.68rem;
  opacity: 0.75;
  max-width: 18rem;        /* cap long descriptions so pills stay compact */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* colour variants */
.chat-action-violet  { background: #f5f3ff; border-color: #c4b5fd; color: #6d28d9; }
.chat-action-violet:hover  { background: #ede9fe; border-color: #a78bfa; }

.chat-action-blue    { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.chat-action-blue:hover    { background: #dbeafe; border-color: #60a5fa; }

.chat-action-emerald { background: #ecfdf5; border-color: #6ee7b7; color: #047857; }
.chat-action-emerald:hover { background: #d1fae5; border-color: #34d399; }

.chat-action-amber   { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.chat-action-amber:hover   { background: #fef3c7; border-color: #fbbf24; }

.chat-action-indigo  { background: #eef2ff; border-color: #a5b4fc; color: #3730a3; }
.chat-action-indigo:hover  { background: #e0e7ff; border-color: #818cf8; }

.chat-action-rose    { background: #fff5f5; border-color: #fecaca; color: #dc2626; }
.chat-action-rose:hover    { background: #fee2e2; border-color: #fca5a5; }

.chat-action-used    { opacity: 0.45; pointer-events: none; }

/* ── Mobile responsive ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar { min-width: 60px; width: 60px; }
  .sidebar-text { display: none; }
  .chat-action-bar { margin-left: 0.5rem; }
}

/* ── Attachments (chat input staging area) ──────────────────────────────── */
#attachment-preview.flex { display: flex; }

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 12rem;
  padding: 0.3rem 0.6rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 0.6rem;
  font-size: 0.75rem;
  color: #374151;
}
.attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip-uploading { background: #f5f3ff; border-color: #ddd6fe; }
.attachment-chip-error     { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.attachment-chip-clickable { cursor: pointer; }
.attachment-chip-clickable:hover { background: #ede9fe; border-color: #ddd6fe; }
.attachment-chip-remove {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0 0.15rem;
  line-height: 1;
}
.attachment-chip-remove:hover { color: #ef4444; }

/* ── Attachments (rendered inside a sent chat bubble) ───────────────────── */
.attachment-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}
.attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 11rem;
  padding: 0.3rem 0.55rem;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 0.6rem;
  font-size: 0.72rem;
  color: #4b5563;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.attachment-badge:hover {
  background: #e5e7eb;
  color: #1f2937;
  border-color: #9ca3af;
}
.attachment-badge-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Attachment preview modal ────────────────────────────────────────────── */
.attachment-preview-image {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  margin: 0 auto;
  object-fit: contain;
}
.attachment-preview-pdf {
  width: 100%;
  height: 75vh;
  border: none;
  display: block;
}
.attachment-preview-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #374151;
  padding: 1.25rem 1.5rem;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.attachment-preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  color: #9ca3af;
  font-size: 0.85rem;
  text-align: center;
}
.attachment-preview-empty i { font-size: 1.75rem; }
