/* ============================================================
   AI ASSISTANT STYLES
   Matches the portfolio's modern.css palette:
     --accent: #7dd3fc (sky blue)
     --accent-strong: #38bdf8
   Glassmorphism + soft glow + smooth motion.
   ============================================================ */

   :root {
    --ai-bg: rgba(15, 23, 42, 0.85);
    --ai-bg-strong: rgba(15, 23, 42, 0.95);
    --ai-border: rgba(125, 211, 252, 0.25);
    --ai-border-hover: rgba(125, 211, 252, 0.55);
    --ai-glow: rgba(56, 189, 248, 0.4);
    --ai-text: #f1f5f9;
    --ai-text-dim: #94a3b8;
    --ai-accent: #7dd3fc;
    --ai-accent-strong: #38bdf8;
  }
  
  /* ============================================================
     1. AI ORB — floating launcher that pulses gently
     ============================================================ */
  .ai-orb {
    position: fixed;
    bottom: 22px;
    left: 22px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 20000;
    background: radial-gradient(circle at 30% 30%, #7dd3fc 0%, #38bdf8 45%, #1e40af 100%);
    box-shadow:
      0 0 0 0 rgba(56, 189, 248, 0.6),
      0 8px 32px rgba(56, 189, 248, 0.35),
      inset 0 0 20px rgba(255, 255, 255, 0.15);
    animation: orbPulse 3s ease-in-out infinite;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: visible;
  }
  
  .ai-orb::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: conic-gradient(
      from 0deg,
      transparent,
      rgba(125, 211, 252, 0.6),
      transparent,
      rgba(56, 189, 248, 0.6),
      transparent
    );
    filter: blur(12px);
    opacity: 0.7;
    animation: orbRotate 6s linear infinite;
    z-index: -1;
  }
  
  .ai-orb::after {
    content: "✨";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
  }
  
  .ai-orb:hover {
    transform: scale(1.1) translateY(-2px);
  }
  
  .ai-orb.active {
    transform: scale(0.92);
  }
  
  .ai-orb-label {
    position: absolute;
    bottom: 70px;
    left: 0;
    background: var(--ai-bg-strong);
    color: var(--ai-text);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--ai-border);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform: translateY(4px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
  
  .ai-orb:hover .ai-orb-label {
    opacity: 1;
    transform: translateY(0);
  }
  
  @keyframes orbPulse {
    0%, 100% {
      box-shadow:
        0 0 0 0 rgba(56, 189, 248, 0.5),
        0 8px 32px rgba(56, 189, 248, 0.35),
        inset 0 0 20px rgba(255, 255, 255, 0.15);
    }
    50% {
      box-shadow:
        0 0 0 14px rgba(56, 189, 248, 0),
        0 8px 32px rgba(56, 189, 248, 0.5),
        inset 0 0 20px rgba(255, 255, 255, 0.25);
    }
  }
  
  @keyframes orbRotate {
    to { transform: rotate(360deg); }
  }
  
  /* ============================================================
     2. CHAT PANEL
     ============================================================ */
  .ai-chat {
    position: fixed;
    bottom: 100px;
    left: 22px;
    width: 380px;
    max-width: calc(100vw - 44px);
    height: 540px;
    max-height: calc(100vh - 140px);
    background: var(--ai-bg);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    box-shadow:
      0 30px 80px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(56, 189, 248, 0.08);
    z-index: 19999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  .ai-chat.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
  
  .ai-chat-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--ai-border);
    background: linear-gradient(180deg, rgba(56, 189, 248, 0.08), transparent);
  }
  
  .ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #7dd3fc, #1e40af);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.5);
    flex-shrink: 0;
  }
  
  .ai-chat-title {
    flex: 1;
    min-width: 0;
  }
  
  .ai-chat-title h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ai-text);
    letter-spacing: -0.01em;
  }
  
  .ai-chat-title .ai-status {
    font-size: 11px;
    color: var(--ai-text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
  }
  
  .ai-chat-title .ai-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px #22c55e;
    animation: aiBlink 2s ease-in-out infinite;
  }
  
  @keyframes aiBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
  }
  
  .ai-chat-close {
    background: transparent;
    border: none;
    color: var(--ai-text-dim);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
  }
  
  .ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--ai-text);
  }
  
  .ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(125, 211, 252, 0.3) transparent;
  }
  
  .ai-chat-body::-webkit-scrollbar { width: 6px; }
  .ai-chat-body::-webkit-scrollbar-thumb {
    background: rgba(125, 211, 252, 0.3);
    border-radius: 3px;
  }
  
  .ai-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  @keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  .ai-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--ai-accent-strong), #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
  }
  
  .ai-msg.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
  }
  
  .ai-msg.bot strong { color: var(--ai-accent); font-weight: 600; }
  .ai-msg.bot a { color: var(--ai-accent); text-decoration: underline; }
  
  .ai-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ai-border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
  }
  
  .ai-typing span {
    width: 6px;
    height: 6px;
    background: var(--ai-accent);
    border-radius: 50%;
    animation: typingDot 1.2s ease-in-out infinite;
  }
  
  .ai-typing span:nth-child(2) { animation-delay: 0.15s; }
  .ai-typing span:nth-child(3) { animation-delay: 0.3s; }
  
  @keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
  }
  
  .ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
  }
  
  .ai-suggestion-chip {
    background: rgba(125, 211, 252, 0.08);
    border: 1px solid var(--ai-border);
    color: var(--ai-text);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
    font-family: inherit;
  }
  
  .ai-suggestion-chip:hover {
    background: rgba(125, 211, 252, 0.18);
    border-color: var(--ai-border-hover);
    transform: translateY(-1px);
  }
  
  .ai-chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--ai-border);
    background: rgba(0, 0, 0, 0.2);
  }
  
  .ai-chat-input input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--ai-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
  }
  
  .ai-chat-input input:focus {
    border-color: var(--ai-border-hover);
    background: rgba(255, 255, 255, 0.08);
  }
  
  .ai-chat-input input::placeholder {
    color: var(--ai-text-dim);
  }
  
  .ai-chat-input button {
    background: linear-gradient(135deg, var(--ai-accent-strong), #2563eb);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
  }
  
  .ai-chat-input button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.35);
  }
  
  .ai-chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  .ai-chat-input button svg {
    width: 18px;
    height: 18px;
  }
  
  /* ============================================================
     3. SMART SEARCH — top-of-page command-K style
     ============================================================ */
  .ai-search-trigger {
    position: fixed;
    top: 18px;
    right: 80px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--ai-text-dim);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    z-index: 19998;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
  }
  
  .ai-search-trigger:hover {
    border-color: var(--ai-border-hover);
    background: rgba(15, 23, 42, 0.9);
    color: var(--ai-text);
  }
  
  .ai-search-trigger svg {
    width: 14px;
    height: 14px;
  }
  
  .ai-search-trigger kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-family: inherit;
  }
  
  .ai-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20002;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  
  .ai-search-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
  
  .ai-search-panel {
    width: min(640px, 92vw);
    background: var(--ai-bg-strong);
    border: 1px solid var(--ai-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    transform: translateY(-10px) scale(0.98);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  .ai-search-overlay.open .ai-search-panel {
    transform: translateY(0) scale(1);
  }
  
  .ai-search-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--ai-border);
  }
  
  .ai-search-input-row svg {
    width: 18px;
    height: 18px;
    color: var(--ai-accent);
    flex-shrink: 0;
  }
  
  .ai-search-input-row input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--ai-text);
    font-size: 16px;
    font-family: inherit;
  }
  
  .ai-search-input-row input::placeholder {
    color: var(--ai-text-dim);
  }
  
  .ai-search-esc {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--ai-text-dim);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
  }
  
  .ai-search-results {
    max-height: 50vh;
    overflow-y: auto;
    padding: 8px;
  }
  
  .ai-search-result {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
  }
  
  .ai-search-result:hover,
  .ai-search-result.active {
    background: rgba(125, 211, 252, 0.08);
    border-color: var(--ai-border);
  }
  
  .ai-search-result-type {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ai-accent);
    background: rgba(125, 211, 252, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
  }
  
  .ai-search-result-title {
    color: var(--ai-text);
    font-weight: 600;
    font-size: 14px;
    margin: 2px 0;
  }
  
  .ai-search-result-snippet {
    color: var(--ai-text-dim);
    font-size: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .ai-search-result mark {
    background: rgba(125, 211, 252, 0.25);
    color: var(--ai-accent);
    padding: 0 2px;
    border-radius: 2px;
  }
  
  .ai-search-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--ai-text-dim);
    font-size: 13px;
  }
  
  .ai-search-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--ai-border);
    font-size: 11px;
    color: var(--ai-text-dim);
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  
  .ai-search-footer kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
    margin: 0 2px;
  }
  
  /* ============================================================
     4. LIGHT MODE TWEAKS
     ============================================================ */
  body.light-mode {
    --ai-bg: rgba(255, 255, 255, 0.9);
    --ai-bg-strong: rgba(255, 255, 255, 0.98);
    --ai-border: rgba(56, 189, 248, 0.3);
    --ai-border-hover: rgba(56, 189, 248, 0.6);
    --ai-text: #0f172a;
    --ai-text-dim: #475569;
  }
  
  body.light-mode .ai-msg.bot {
    background: rgba(56, 189, 248, 0.06);
    color: #0f172a;
  }
  
  body.light-mode .ai-chat-input {
    background: rgba(0, 0, 0, 0.03);
  }
  
  body.light-mode .ai-chat-input input {
    background: rgba(255, 255, 255, 0.7);
    color: #0f172a;
  }
  
  body.light-mode .ai-search-trigger {
    background: rgba(255, 255, 255, 0.8);
    color: #475569;
  }
  
  /* ============================================================
     5. MOBILE
     ============================================================ */
  @media (max-width: 600px) {
    .ai-chat {
      width: calc(100vw - 24px);
      left: 12px;
      bottom: 92px;
      height: calc(100vh - 130px);
    }
    .ai-orb {
      bottom: 18px;
      left: 18px;
      width: 54px;
      height: 54px;
    }
    .ai-orb::after { font-size: 22px; }
    .ai-search-trigger {
      right: 70px;
      padding: 6px 10px;
      font-size: 12px;
    }
    .ai-search-trigger .ai-search-trigger-label { display: none; }
    .ai-search-overlay { padding-top: 6vh; }
  }
  
  /* Hide search trigger when hero is visible to keep it clean */
  .ai-search-trigger.hero-mode { opacity: 0; pointer-events: none; }