/* assistant.css */

/* Glassmorphism */
  .glass-panel {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
  }

/* Assistant button controls */
  #ai-hints-btn,
  #ai-clear-btn {
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: #3b82f6;
    background: #eff6ff;  /* very light blue fill */
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }

  /* Actions container — top-left inside the panel */
  .ai-panel-actions {
    position: absolute;
    top: 8px;
    left: 8px;
    right: auto;
    display: flex;
    gap: 6px;
    z-index: 2; /* draw above bubble messages (z-index 1) */
  }

  .ai-panel-actions button {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    border: none;
    background: rgba(0, 0, 0, 0.06);
  }

/* Assistant chat panel — floating bubble */
  #ai-chat-panel {
    position: fixed;
    z-index: 10000;
    /* Base floating bubble styles */
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25),
                0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    border-radius: 16px;
    overflow: hidden;
    box-sizing: border-box;
    transform: translateZ(0); /* own compositor layer */

    /* Smooth size & position changes */
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                top 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                bottom 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #ai-chat-panel.is-hidden {
    display: none !important;
  }

  /* Closed = small clickable square (top-right) */
  #ai-chat-panel[data-state="closed"] {
    display: flex;
    align-items: center;
    justify-content: center;

    /* Match the header button look */
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    backdrop-filter: none; /* optional: remove blur for a flatter match */
    top: 20px; /* Must match 20px fallback in adjustPanelForKeyboard() */
    left: auto;
    bottom: auto;
    right: 15px;
  }

  /* Peek = larger bubble (top-right) */
  #ai-chat-panel[data-state="peek"] {
    top: 85px;
    left: auto;
    bottom: auto;
    right: 15px;
  }

  /* Expanded = upper area, anchored on the right */
  #ai-chat-panel[data-state="expanded"] {
    top: 20px;
    left: auto;
    bottom: auto;
    right: 15px;
  }

  /* Peek & Expanded: solid background on inner content */
  #ai-chat-panel[data-state="peek"] .ai-inner,
  #ai-chat-panel[data-state="expanded"] .ai-inner {
    background: rgba(255, 255, 255, 0.75);  /* transparent */
    backdrop-filter: none; /* No blur. For blur use: blur(12px); */
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* Expand & Shrink — left of the close button */
  .ai-expand-btn,
  .ai-shrink-btn {
    position: absolute;
    top: 8px;
    right: 40px;          /* leaves room for the close button */
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3;
    -webkit-appearance: none;
    appearance: none;
  }

  #ai-chat-panel[data-state="peek"] .ai-expand-btn,
  #ai-chat-panel[data-state="expanded"] .ai-shrink-btn {
    display: flex;
  }

  /* Close — far right */
  .ai-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;           /* rightmost */
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
    font-size: 18px;     /* larger than the arrows */
    font-weight: 600;    /* or bold */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3;
    -webkit-appearance: none;
    appearance: none;
  }

  #ai-chat-panel[data-state="peek"] .ai-close-btn,
  #ai-chat-panel[data-state="expanded"] .ai-close-btn {
    display: flex;
  }

/* Assistant closed icon */
  .ai-closed-icon {
    display: none;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    pointer-events: none;
    padding: 4px 8px;
  }

  #ai-chat-panel[data-state="closed"] .ai-closed-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }

  #ai-chat-panel[data-state="closed"] .ai-inner {
    display: none;
  }

/* Assistant messages area */
  #ai-messages,
  .ai-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1; /* draw below panel action buttons (z-index 2) */

    /* Spacing — tight on the right so content can sit under the ✕ button */
    padding: 0 8px 12px 16px;   /* sides + bottom */
    margin-top: 8px;            /* permanent top gap */

    /* Allow user to copy text but don't highlight / show focus ring */
    -webkit-user-select: text;  /* or none if you don’t need selection */
    user-select: text;
    outline: none; /* avoid focus ring if the container is tapped */

    /* Fade messages as they scroll under the top buttons */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 72px, #000 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 72px, #000 100%);
  }

  .ai-top-spacer {
    height: 36px;  /* allows welcome message to avoid fade */
    flex-shrink: 0;
  }

  #ai-chat-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .ai-composer {
    flex-shrink: 0;
  }

  #ai-input {
    flex: 1;
    min-width: 0;

    /* Prevent iOS zoom on focus */
    font-size: 16px;

    /* Remove blue focus highlight without killing native appearance */
    outline: none;
  }

/* Assistant bubble messages */
  .ai-bubble {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .ai-bubble-assistant {
    align-self: flex-start;
    background: #f1f5f9;
  }

  .ai-bubble-user {
    align-self: flex-end;
    background: #ffe4ef;
  }

  .ai-bubble-thinking { opacity: 0.7; }
  .ai-composer {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 8px 12px 12px;
  }
