/* chatbot/assets/chat.css */
/* Modern Floating AI Chatbot Widget - Light/Dark Mode Native */

.doc-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 80px; /* Positioned gracefully next to backToTop button */
    z-index: 999;
    font-family: inherit;
}

/* Floating Launcher Button */
.doc-chat-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border-radius: 999px;
    background: var(--green);
    color: #ffffff;
    border: 1px solid var(--green-border);
    cursor: pointer;
    box-shadow: 0 10px 30px var(--green-glow), 0 4px 14px rgba(0,0,0,.2);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-weight: 800;
    font-size: 0.92rem;
    will-change: transform, box-shadow;
    -webkit-animation: launcherPulseAura 3s infinite, launcherNudge 6s ease-in-out infinite;
    animation: launcherPulseAura 3s infinite, launcherNudge 6s ease-in-out infinite;
}

[data-theme="dark"] .doc-chat-launcher {
    color: #06110d;
}

/* Pulsing radar ripple ring behind button */
.doc-chat-launcher::before {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 999px;
    border: 2px solid var(--green);
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity;
    -webkit-animation: launcherRipple 3s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    animation: launcherRipple 3s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

/* Online glowing notification badge */
.doc-chat-launcher::after {
    content: "";
    position: absolute;
    top: -3px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid var(--bg);
    border-radius: 50%;
    box-shadow: 0 0 10px #22c55e;
    -webkit-animation: badgeBlink 2s infinite;
    animation: badgeBlink 2s infinite;
}

.doc-chat-launcher:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 16px 40px var(--green-glow);
    animation-play-state: paused;
    -webkit-animation-play-state: paused;
}

.doc-chat-launcher svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    -webkit-animation: iconTilt 4s ease-in-out infinite;
    animation: iconTilt 4s ease-in-out infinite;
}

/* Attention-Grabbing Keyframe Animations */
@keyframes launcherNudge {
    0%, 75%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    78% {
        transform: translateY(-8px) rotate(-4deg) scale(1.04);
    }
    82% {
        transform: translateY(-2px) rotate(3deg) scale(1.02);
    }
    86% {
        transform: translateY(-6px) rotate(-2deg);
    }
    90% {
        transform: translateY(0) rotate(0deg);
    }
}

@keyframes launcherPulseAura {
    0%, 100% {
        box-shadow: 0 10px 28px var(--green-glow), 0 0 0 0 rgba(114, 230, 197, 0.4);
    }
    50% {
        box-shadow: 0 14px 40px var(--green-glow), 0 0 0 14px rgba(114, 230, 197, 0);
    }
}

@keyframes launcherRipple {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    70% {
        transform: scale(1.25);
        opacity: 0;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

@keyframes iconTilt {
    0%, 80%, 100% { transform: scale(1); }
    85% { transform: scale(1.2) rotate(-15deg); }
    90% { transform: scale(1.2) rotate(15deg); }
    95% { transform: scale(1.1) rotate(0deg); }
}

@keyframes badgeBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* Chat Modal / Window */
.doc-chat-box {
    position: absolute;
    bottom: 65px;
    right: 0;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 120px);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    box-shadow: var(--shadow), 0 20px 50px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.doc-chat-box.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.doc-chat-header {
    padding: 16px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.doc-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.doc-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--green);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 850;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px var(--green-glow);
}

[data-theme="dark"] .doc-chat-avatar {
    color: #06110d;
}

.doc-chat-title-group h4 {
    font-size: 0.95rem;
    color: var(--text-strong);
    font-weight: 750;
    line-height: 1.2;
}

.doc-chat-title-group .doc-chat-status {
    font-size: 0.72rem;
    color: var(--green);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.doc-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    display: inline-block;
    animation: docPulse 2s infinite;
}

@keyframes docPulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.doc-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-chat-btn-icon {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.doc-chat-btn-icon:hover {
    color: var(--text-strong);
    background: var(--line);
}

/* Reference Badge */
.doc-chat-ref-badge {
    padding: 6px 16px;
    background: var(--green-bg);
    border-bottom: 1px solid var(--green-border);
    font-size: 0.75rem;
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.doc-chat-ref-badge button {
    background: none;
    border: none;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.72rem;
}

/* Body / Message Area */
.doc-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--bg);
}

/* Registration Form View */
.doc-chat-auth-view {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 10px;
    text-align: center;
}

.doc-chat-auth-view h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-strong);
}

.doc-chat-auth-view p {
    font-size: 0.86rem;
    color: var(--muted);
    margin-bottom: 22px;
}

.doc-chat-form-group {
    margin-bottom: 14px;
    text-align: left;
}

.doc-chat-form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-strong);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.doc-chat-form-group input {
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--bg-surface);
    color: var(--text);
    font-size: 0.88rem;
    outline: none;
    transition: var(--transition);
}

.doc-chat-form-group input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
}

.doc-chat-btn-submit {
    width: 100%;
    padding: 13px;
    margin-top: 8px;
    border-radius: 999px;
    background: var(--green);
    color: #ffffff;
    border: none;
    font-weight: 750;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

[data-theme="dark"] .doc-chat-btn-submit {
    color: #06110d;
}

.doc-chat-btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--green-glow);
}

.doc-chat-resume-link {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--muted);
}

.doc-chat-resume-link a {
    color: var(--green);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

/* Chat Bubbles */
.doc-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 84%;
    animation: docMsgIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

.doc-chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-break: break-word;
}

.doc-chat-msg.user .doc-chat-bubble {
    background: var(--green);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

[data-theme="dark"] .doc-chat-msg.user .doc-chat-bubble {
    color: #06110d;
}

.doc-chat-msg.assistant .doc-chat-bubble {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-bottom-left-radius: 4px;
    box-shadow: var(--card-shadow);
}

.doc-chat-time {
    font-size: 0.68rem;
    color: var(--dim);
    margin-top: 4px;
    align-self: flex-end;
}

.doc-chat-msg.assistant .doc-chat-time {
    align-self: flex-start;
}

/* Typing Indicator */
.doc-chat-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    gap: 4px;
}

.doc-chat-typing.active {
    display: flex;
    align-items: center;
}

.doc-chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: docTyping 1.4s infinite ease-in-out;
}

.doc-chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.doc-chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes docTyping {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* Footer / Input */
.doc-chat-footer {
    padding: 12px 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-chat-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--bg);
    color: var(--text);
    font-size: 0.88rem;
    outline: none;
    transition: var(--transition);
}

.doc-chat-input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
}

.doc-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--green);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

[data-theme="dark"] .doc-chat-send-btn {
    color: #06110d;
}

.doc-chat-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 12px var(--green-glow);
}

.doc-chat-send-btn svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
}

/* Mobile full-screen adaptation */
@media (max-width: 480px) {
    .doc-chat-widget {
        right: 15px;
        bottom: 15px;
    }
    .doc-chat-box {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        bottom: 0;
        right: 0;
    }
}
