/* ============================================================
   AI ASSISTANT WIDGET
   Extracted from Chatbot.html — shared by Chatbot.html and
   index.html. Keyframes are prefixed (aiPulse, aiBlink, aiMsgIn,
   aiBounce) so they cannot clash with animate.min.css, and the
   design tokens are scoped to .ai instead of :root so they cannot
   leak into the portfolio styles.
   ============================================================ */

.ai {
    /* widget design tokens (values from Chatbot.html :root) */
    --panel-2: #111413;
    --stroke: #20241f;
    --stroke-soft: #181b17;
    --text: #f2f4f1;
    --muted: #9aa39a;
    --muted-2: #6c746c;
    --accent: #33d982;
    --accent-strong: #2ee07f;
    --accent-glow: rgba(51, 217, 130, .35);
    --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    position: fixed;
    top: 100px;
    right: 34px;
    z-index: 50;
    font-family: var(--font);
}

/* launcher (robot button) */
.ai-launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 20px;
    cursor: pointer;
    border: none;
    background: linear-gradient(150deg, #14201a, #0a0f0c);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5), inset 0 0 0 1px var(--stroke);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s;
}

.ai-launcher::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 22px;
    background: radial-gradient(circle at 50% 0, var(--accent-glow), transparent 70%);
    opacity: 0;
    transition: .3s;
    z-index: -1;
}

.ai-launcher:hover {
    transform: translateY(-3px);
}

.ai-launcher:hover::after {
    opacity: 1;
}

.ai-launcher .robot {
    width: 34px;
    height: 34px;
    color: var(--accent);
}

.ai-launcher .robot .eye {
    animation: aiBlink 4s infinite;
}

.ai-launcher .pulse {
    position: absolute;
    top: 11px;
    right: 11px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent-glow);
    animation: aiPulse 2s infinite;
}

@keyframes aiPulse {
    0% { box-shadow: 0 0 0 0 var(--accent-glow); }
    70% { box-shadow: 0 0 0 8px rgba(51, 217, 130, 0); }
    100% { box-shadow: 0 0 0 0 rgba(51, 217, 130, 0); }
}

@keyframes aiBlink {
    0%, 92%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(.1); }
}

.ai-tip {
    position: absolute;
    top: 50%;
    right: 74px;
    transform: translateY(-50%) translateX(6px);
    white-space: nowrap;
    background: #0b0d0c;
    border: 1px solid var(--stroke);
    color: var(--text);
    font-size: 12.5px;
    padding: 9px 14px;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    transition: .25s;
}

.ai-tip b {
    color: var(--accent);
    font-weight: 600;
}

.ai-launcher:hover + .ai-tip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* panel */
.ai-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 378px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 130px);
    background: linear-gradient(180deg, #0c0f0d, #070907);
    border: 1px solid var(--stroke);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .65);
    transform-origin: top right;
    opacity: 0;
    transform: translateY(-8px) scale(.9);
    pointer-events: none;
    transition: opacity .28s ease, transform .34s cubic-bezier(.22, 1, .36, 1);
}

.ai.open .ai-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ai.open .ai-launcher {
    transform: scale(.85);
    opacity: 0;
    pointer-events: none;
}

.ai.open .ai-tip {
    display: none;
}

.ai-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--stroke-soft);
    background: linear-gradient(180deg, rgba(51, 217, 130, .07), transparent);
}

.ai-ava {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    flex: 0 0 auto;
    background: linear-gradient(150deg, #16241c, #0a0f0c);
    border: 1px solid var(--stroke);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    position: relative;
}

.ai-ava svg {
    width: 24px;
    height: 24px;
}

.ai-ava .dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #0c0f0d;
}

.ai-meta {
    flex: 1;
    min-width: 0;
}

.ai-meta h4 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    margin: 0;
}

.ai-meta span {
    font-size: 12px;
    color: var(--accent);
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-meta span::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.ai-min {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--stroke);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
}

.ai-min:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.ai-min svg {
    width: 16px;
    height: 16px;
}

.ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.ai-body::-webkit-scrollbar {
    width: 6px;
}

.ai-body::-webkit-scrollbar-thumb {
    background: var(--stroke);
    border-radius: 6px;
}

.ai .msg {
    max-width: 82%;
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 14px;
    border-radius: 16px;
    animation: aiMsgIn .35s cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes aiMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.ai .msg.bot {
    align-self: flex-start;
    background: var(--panel-2);
    border: 1px solid var(--stroke-soft);
    color: var(--text);
    border-top-left-radius: 5px;
}

.ai .msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #04140b;
    font-weight: 500;
    border-top-right-radius: 5px;
}

.ai-chips {
    padding: 0 18px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai .chip {
    background: transparent;
    border: 1px solid var(--stroke);
    color: var(--muted);
    font-family: var(--font);
    font-size: 12.5px;
    padding: 8px 13px;
    border-radius: 20px;
    cursor: pointer;
    transition: .2s;
}

.ai .chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(51, 217, 130, .06);
}

.ai-foot {
    padding: 14px 16px;
    border-top: 1px solid var(--stroke-soft);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    background: var(--panel-2);
    border: 1px solid var(--stroke);
    border-radius: 16px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    padding: 12px 14px;
    resize: none;
    max-height: 96px;
    line-height: 1.4;
    outline: none;
    transition: .2s;
}

.ai-input::placeholder {
    color: var(--muted-2);
}

.ai-input:focus {
    border-color: var(--accent);
}

.ai-send {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 14px;
    border: none;
    background: var(--accent);
    color: #04140b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
}

.ai-send:hover {
    background: var(--accent-strong);
    box-shadow: 0 6px 18px var(--accent-glow);
}

.ai-send svg {
    width: 19px;
    height: 19px;
}

/* typing indicator */
.ai .typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel-2);
    border: 1px solid var(--stroke-soft);
    border-radius: 16px;
    border-top-left-radius: 5px;
    padding: 13px 16px;
    animation: aiMsgIn .3s both;
}

.ai .typing .txt {
    font-size: 13px;
    color: var(--muted);
}

.ai .typing .dots {
    display: flex;
    gap: 5px;
}

.ai .typing .dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
    animation: aiBounce 1.2s infinite ease-in-out;
}

.ai .typing .dots i:nth-child(2) {
    animation-delay: .18s;
}

.ai .typing .dots i:nth-child(3) {
    animation-delay: .36s;
}

@keyframes aiBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* widget responsive rules (from Chatbot.html) */
@media (max-width: 720px) {
    .ai {
        top: auto;
        bottom: 22px;
        right: 18px;
    }

    .ai-panel {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: auto;
        width: 100%;
        max-width: 100%;
        height: 78vh;
        max-height: 78vh;
        border-radius: 24px 24px 0 0;
        transform-origin: bottom center;
        transform: translateY(20px) scale(1);
    }

    .ai.open .ai-panel {
        transform: translateY(0) scale(1);
    }

    .ai-launcher {
        width: 56px;
        height: 56px;
    }
}

/* ============================================================
   Placement on the portfolio page (index.html, body.home1-page):
   the widget is docked at the bottom-right corner of the viewport,
   on the same vertical axis as the right-hand navigation menu.
   The panel opens upward from the launcher. Chatbot.html keeps
   the original top-right placement.
   ============================================================ */
.home1-page .ai {
    top: auto;
    bottom: 30px;
    right: 65px; /* aligns launcher center with the menu center */
}

.home1-page .ai-panel {
    top: auto;
    bottom: 0;
    transform-origin: bottom right;
    transform: translateY(8px) scale(.9);
}

.home1-page .ai.open .ai-panel {
    transform: translateY(0) scale(1);
}

/* the right-hand menu is hidden below 1220px: dock the launcher
   bottom-right (the widget's own <=720px rules then take over) */
@media (max-width: 1220px) {
    .home1-page .ai {
        top: auto;
        bottom: 30px;
        right: 34px;
    }
}

@media (max-width: 720px) {
    .home1-page .ai {
        bottom: 22px;
        right: 18px;
    }
}
