/*
 * Excel task-pane navigation.
 * Icon-only buttons with a small label that pops up BELOW the icon on hover.
 * Buttons keep the same compact size whether hovered or not — the label is
 * positioned absolutely so it never displaces neighbouring icons.
 */
.menu {
    position: relative;
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    width: 100%;
    /* Bottom padding hosts the hover label so it stays inside the white pill */
    padding: 3px 4px 18px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.06);
  }

  .link {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    border-radius: 6px;
    text-decoration: none;
    color: #4b5563;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .link:hover,
  .link:focus {
    outline: 0;
    background-color: #eef2ff;
    color: #4338ca;
  }

  .link.active {
    background-color: #d1fae5;
    color: #059669;
  }

  .link-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .link-icon svg {
    width: 16px;
    height: 16px;
    display: block;
  }

  /*
   * Hover label sits in the white reserved strip at the bottom of the menu.
   * Always laid out (no layout shift), only shown on hover/focus.
   */
  .link-title {
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    color: #4338ca;
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.12s ease;
  }

  /* AI extract context — compact breadcrumb bar */
  .ai-context-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .ai-context-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 5px 10px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  .ai-context-source {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #059669;
    padding: 2px 6px;
    background: #ecfdf5;
    border-radius: 4px;
  }

  .ai-context-value {
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    max-width: 42%;
  }

  .ai-context-value--query {
    font-weight: 600;
    color: #111827;
    flex: 1;
    max-width: none;
  }

  .ai-context-value--empty {
    color: #9ca3af;
    font-weight: 400;
    font-style: italic;
  }

  .ai-context-sep {
    flex-shrink: 0;
    color: #9ca3af;
    font-size: 13px;
    line-height: 1;
    user-select: none;
  }

  .ai-context-hint {
    font-size: 11px;
    color: #b45309;
    padding: 0 4px;
    margin: 0;
    line-height: 1.35;
  }

  /* AI conversation panel */
  .ai-chat {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 280px;
    max-height: 420px;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #9ca3af #eef2f7;
    padding: 16px;
    background: #f3f4f6;
    border: 1px solid #9ca3af;
    border-radius: 12px;
  }

  .ai-chat::-webkit-scrollbar {
    width: 8px;
  }

  .ai-chat::-webkit-scrollbar-track {
    background: #eef2f7;
    border-radius: 8px;
  }

  .ai-chat::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 8px;
  }

  .ai-chat::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
  }

  .ai-chat-empty {
    margin: auto;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
    padding: 24px 12px;
  }

  .ai-chat-msg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 92%;
  }

  .ai-chat-msg.user {
    align-self: flex-end;
    align-items: flex-end;
  }

  .ai-chat-msg.assistant {
    align-self: flex-start;
    align-items: flex-start;
  }

  .ai-chat-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0 4px;
  }

  .ai-chat-msg--prompt .ai-chat-label {
    color: #1d4ed8;
  }

  .ai-chat-msg--reply .ai-chat-label {
    color: #047857;
  }

  .ai-chat-msg--filters .ai-chat-label {
    color: #b45309;
  }

  .ai-chat-msg--meta-risk .ai-chat-label {
    color: #b91c1c;
  }

  .ai-chat-msg--meta-info .ai-chat-label {
    color: #4338ca;
  }

  .ai-chat-msg--success .ai-chat-label {
    color: #15803d;
  }

  .ai-chat-msg--notice .ai-chat-label {
    color: #6b7280;
  }

  .ai-chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    width: 100%;
    box-sizing: border-box;
  }

  .ai-chat-bubble--prompt {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.35);
  }

  .ai-chat-bubble--reply {
    background: #fff;
    color: #1f2937;
    border: 1px solid #a7f3d0;
    border-left: 4px solid #059669;
    border-bottom-left-radius: 4px;
  }

  .ai-chat-bubble--filters {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    border-bottom-left-radius: 4px;
  }

  .ai-chat-bubble--meta-risk {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    font-size: 12px;
  }

  .ai-chat-bubble--meta-info {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    border-left: 4px solid #6366f1;
    font-size: 12px;
  }

  .ai-chat-bubble--success {
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #86efac;
    border-left: 4px solid #22c55e;
    font-weight: 500;
  }

  .ai-chat-bubble--notice {
    background: #f9fafb;
    color: #4b5563;
    border: 1px solid #d1d5db;
    border-left: 4px solid #9ca3af;
    font-size: 12px;
  }

  .ai-chat-msg.thinking .ai-chat-bubble {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    font-style: italic;
  }

  .ai-chat-msg.thinking .ai-chat-label {
    color: #6b7280;
  }

  .ai-chat-msg.thinking .animate-spin {
    flex-shrink: 0;
  }

  .link:hover .link-title,
  .link:focus .link-title {
    visibility: visible;
    opacity: 1;
  }
  