/* =========================================================================
   SHA AI DOUBT & COACHING PANEL — CALM EDITORIAL MONOCHROME
   Minimalist, matte surfaces, full-width editorial text, zero AI slop
   ========================================================================= */

/* Floating "Ask Sha" Trigger Button */
.sha-trigger-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #111827;
  color: #ffffff;
  border: 1px solid #111827;
  border-radius: 9999px;
  padding: 9px 16px;
  font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: all 0.18s ease;
  outline: none;
  user-select: none;
}

.sha-trigger-btn:hover {
  background: #000000;
  border-color: #000000;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.sha-trigger-btn:active {
  transform: translateY(0);
}

[data-theme="dark"] .sha-trigger-btn,
.dark .sha-trigger-btn {
  background: #f4f4f5;
  color: #111214;
  border-color: #f4f4f5;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .sha-trigger-btn:hover,
.dark .sha-trigger-btn:hover {
  background: #ffffff;
  border-color: #ffffff;
}

.sha-trigger-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Modal Backdrop */
.sha-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.sha-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

/* Sha Slide-over Panel (Desktop Dock: 440px Right Dock with Zero-Overflow Transform) */
.sha-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #ffffff;
  color: #18181b;
  border-left: 1px solid #e5e7eb;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.08);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
  box-sizing: border-box;
  overflow-x: hidden;
  visibility: hidden;
  pointer-events: none;
}

.sha-panel.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

/* Dark mode panel support */
[data-theme="dark"] .sha-panel,
.dark .sha-panel {
  background: #111214;
  color: #f4f4f5;
  border-left-color: #27272a;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.45);
}

/* Panel Header: Calm, clean editorial title */
.sha-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f6f6f4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

[data-theme="dark"] .sha-header,
.dark .sha-header {
  background: #18191c;
  border-bottom-color: #27272a;
}

.sha-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sha-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  color: #18181b;
  letter-spacing: -0.015em;
}

[data-theme="dark"] .sha-title,
.dark .sha-title {
  color: #f4f4f5;
}

.sha-subtitle {
  font-size: 12px;
  color: #71717a;
  line-height: 1.35;
}

[data-theme="dark"] .sha-subtitle,
.dark .sha-subtitle {
  color: #a1a1aa;
}

.sha-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sha-btn-close {
  background: transparent;
  border: 1px solid transparent;
  color: #71717a;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sha-btn-close:hover {
  background: #e5e7eb;
  color: #18181b;
}

[data-theme="dark"] .sha-btn-close,
.dark .sha-btn-close {
  color: #a1a1aa;
}

[data-theme="dark"] .sha-btn-close:hover,
.dark .sha-btn-close:hover {
  background: #27272a;
  color: #ffffff;
}

/* Quick Action Chips Bar */
.sha-chips-bar {
  padding: 10px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

[data-theme="dark"] .sha-chips-bar,
.dark .sha-chips-bar {
  background: #111214;
  border-bottom-color: #27272a;
}

.sha-chip {
  background: #f6f6f4;
  color: #18181b;
  border: 1px solid #e5e7eb;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.sha-chip:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #111827;
}

[data-theme="dark"] .sha-chip,
.dark .sha-chip {
  background: #18191c;
  border-color: #27272a;
  color: #f4f4f5;
}

[data-theme="dark"] .sha-chip:hover,
.dark .sha-chip:hover {
  background: #27272a;
  border-color: #3f3f46;
}

/* Chat Transcript Scroll Area */
.sha-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #ffffff;
  box-sizing: border-box;
}

[data-theme="dark"] .sha-messages,
.dark .sha-messages {
  background: #111214;
}

/* Full-width editorial message structure */
.sha-msg {
  display: flex;
  flex-direction: column;
  font-size: 14.5px;
  line-height: 1.72;
  animation: shaFadeIn 0.2s ease;
}

@keyframes shaFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* User Messages: Subtle, neutral right-aligned pill */
.sha-msg-user {
  align-self: flex-end;
  background: #f6f6f4;
  color: #18181b;
  border: 1px solid #e5e7eb;
  padding: 8px 14px;
  border-radius: 12px;
  max-width: 82%;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

[data-theme="dark"] .sha-msg-user,
.dark .sha-msg-user {
  background: #18191c;
  color: #f4f4f5;
  border-color: #27272a;
}

/* Assistant Messages: Clean, full-width editorial text (NO chat bubble) */
.sha-msg-assistant {
  align-self: stretch;
  background: transparent;
  color: #18181b;
  border: none;
  padding: 4px 0 12px;
  border-radius: 0;
  box-shadow: none;
  word-break: break-word;
}

[data-theme="dark"] .sha-msg-assistant,
.dark .sha-msg-assistant {
  color: #e4e4e7;
}

.sha-msg-assistant p {
  margin: 0 0 10px 0;
}

.sha-msg-assistant p:last-child {
  margin-bottom: 0;
}

.sha-msg-assistant ul, .sha-msg-assistant ol {
  margin: 6px 0 10px 18px;
  padding: 0;
}

.sha-msg-assistant li {
  margin-bottom: 4px;
}

.sha-msg-assistant strong {
  font-weight: 700;
  color: #111827;
}

[data-theme="dark"] .sha-msg-assistant strong,
.dark .sha-msg-assistant strong {
  color: #ffffff;
}

.sha-msg-assistant code {
  background: #f6f6f4;
  border: 1px solid #e5e7eb;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] .sha-msg-assistant code,
.dark .sha-msg-assistant code {
  background: #18191c;
  border-color: #27272a;
}

.sha-exam-trap-box {
  margin: 12px 0 6px;
  padding: 10px 14px;
  background: #f6f6f4;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #111827;
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.55;
}

[data-theme="dark"] .sha-exam-trap-box,
.dark .sha-exam-trap-box {
  background: #18191c;
  border-color: #27272a;
  border-left-color: #f4f4f5;
}

/* Typing / Generating Indicator */
.sha-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background: #f6f6f4;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

[data-theme="dark"] .sha-typing,
.dark .sha-typing {
  background: #18191c;
  border-color: #27272a;
}

.sha-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #71717a;
  animation: shaBounce 1.3s infinite ease-in-out both;
}

[data-theme="dark"] .sha-dot,
.dark .sha-dot {
  background: #a1a1aa;
}

.sha-dot:nth-child(1) { animation-delay: -0.32s; }
.sha-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes shaBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

/* Input Area */
.sha-input-area {
  padding: 12px 18px;
  border-top: 1px solid #e5e7eb;
  background: #f6f6f4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

[data-theme="dark"] .sha-input-area,
.dark .sha-input-area {
  background: #18191c;
  border-top-color: #27272a;
}

.sha-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.sha-input {
  flex: 1;
  background: #ffffff;
  color: #18181b;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 42px 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.sha-input:focus {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08);
}

[data-theme="dark"] .sha-input,
.dark .sha-input {
  background: #111214;
  border-color: #27272a;
  color: #f4f4f5;
}

[data-theme="dark"] .sha-input:focus,
.dark .sha-input:focus {
  border-color: #f4f4f5;
  box-shadow: 0 0 0 2px rgba(244, 244, 245, 0.12);
}

.sha-btn-send {
  position: absolute;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #111827;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sha-btn-send:hover {
  background: #000000;
}

.sha-btn-send:active {
  transform: scale(0.96);
}

.sha-btn-send:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

[data-theme="dark"] .sha-btn-send,
.dark .sha-btn-send {
  background: #f4f4f5;
  color: #111214;
}

[data-theme="dark"] .sha-btn-send:hover,
.dark .sha-btn-send:hover {
  background: #ffffff;
}

[data-theme="dark"] .sha-btn-send:disabled,
.dark .sha-btn-send:disabled {
  background: #27272a;
  color: #71717a;
}

.sha-grounding-tag {
  font-size: 11px;
  color: #71717a;
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
}

[data-theme="dark"] .sha-grounding-tag,
.dark .sha-grounding-tag {
  color: #a1a1aa;
}

/* Mobile Responsive Drawer: Slide up from bottom */
@media (max-width: 768px) {
  .sha-trigger-btn {
    bottom: 20px;
    right: 16px;
    padding: 8px 14px;
    font-size: 13px;
  }
  
  .sha-panel {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 85vh !important;
    height: 85dvh !important;
    border-radius: 18px 18px 0 0 !important;
    border-left: none !important;
    border-top: 1px solid #e5e7eb !important;
    transform: translateY(100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  [data-theme="dark"] .sha-panel,
  .dark .sha-panel {
    border-top-color: #27272a !important;
  }
  
  .sha-panel.is-open {
    transform: translateY(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  
  .sha-drag-handle {
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 9999px;
    margin: 8px auto 4px;
    display: block;
  }

  [data-theme="dark"] .sha-drag-handle,
  .dark .sha-drag-handle {
    background: #3f3f46;
  }
}

/* Inline "Ask Sha" Context Triggers */
.sha-inline-ask {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f6f6f4;
  color: #18181b;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.16s ease;
  user-select: none;
}

.sha-inline-ask:hover {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
  transform: translateY(-1px);
}

.sha-inline-ask:active {
  transform: translateY(0);
}

.sha-inline-ask-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

[data-theme="dark"] .sha-inline-ask,
.dark .sha-inline-ask {
  background: #18191c;
  color: #f4f4f5;
  border-color: #27272a;
}

[data-theme="dark"] .sha-inline-ask:hover,
.dark .sha-inline-ask:hover {
  background: #f4f4f5;
  color: #111214;
  border-color: #f4f4f5;
}
