/* ============================================
   Mary Assistant — Jobs Vision Widget
   Prefix .chatbot- to avoid collisions
   ============================================ */

:root {
    --chatbot-primary: #00a86b;
    --chatbot-primary-hover: #008f5c;
    --chatbot-primary-light: rgba(0, 168, 107, 0.08);
    --chatbot-primary-glow: rgba(0, 168, 107, 0.25);
    --chatbot-bg: #ffffff;
    --chatbot-bg-secondary: #f8fafc;
    --chatbot-text: #1a1a1a;
    --chatbot-text-secondary: #64748b;
    --chatbot-text-light: #94a3b8;
    --chatbot-border: #e2e8f0;
    --chatbot-user-msg: #00a86b;
    --chatbot-user-text: #ffffff;
    --chatbot-bot-msg: #f8fafc;
    --chatbot-bot-text: #1a1a1a;
    --chatbot-radius: 24px;
    --chatbot-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
    --chatbot-z-index: 9999;
    --chatbot-transition: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ===== FLOATING TRIGGER BUTTON ===== */

.chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--chatbot-z-index);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: chatbot-fadeInUp 0.5s var(--chatbot-transition);
}

.chatbot-trigger-tooltip {
    background: var(--chatbot-bg);
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    font-weight: 500;
    color: var(--chatbot-text);
    white-space: nowrap;
    position: relative;
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s var(--chatbot-transition);
}

.chatbot-trigger-tooltip::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    width: 10px;
    height: 10px;
    background: var(--chatbot-bg);
    border-radius: 2px;
    transform: translateY(-50%) rotate(45deg);
}

.chatbot-trigger-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-hover));
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 30px var(--chatbot-primary-glow);
    transition: all 0.3s var(--chatbot-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.chatbot-trigger-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.3s;
}

.chatbot-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(0, 168, 107, 0.4);
}

/* Open state: rotate icon, hide tooltip */
.chatbot-trigger.chatbot-trigger--open .chatbot-trigger-tooltip {
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
}

.chatbot-trigger.chatbot-trigger--open .chatbot-trigger-btn svg.chatbot-icon-chat {
    display: none;
}
.chatbot-trigger.chatbot-trigger--open .chatbot-trigger-btn svg.chatbot-icon-close {
    display: block;
}

.chatbot-trigger-btn svg.chatbot-icon-close {
    display: none;
}

/* Dashboard mode: hide trigger, use sidebar button */
.chatbot-trigger.chatbot-trigger--dashboard {
    display: none;
}

/* Sidebar toggle button (dashboard) */
#rail-chatbot-toggle {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
}

#rail-chatbot-toggle.chatbot-toggle--active {
    color: var(--chatbot-primary);
}

#rail-chatbot-toggle.chatbot-toggle--active svg {
    stroke: var(--chatbot-primary);
}

/* ===== CHAT WINDOW ===== */

.chatbot-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 400px;
    max-height: 600px;
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    z-index: var(--chatbot-z-index);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--chatbot-border);
}

.chatbot-window.chatbot-visible {
    display: flex;
    animation: chatbot-scaleIn 0.35s var(--chatbot-transition);
}

/* Dashboard positioning */
.chatbot-window.chatbot-window--dashboard {
    bottom: 16px;
    right: auto;
    left: 72px;
}

.sidebar-rail.is-expanded ~ #chatbot-widget .chatbot-window--dashboard {
    left: 260px;
}

/* ===== HEADER ===== */

.chatbot-header {
    padding: 18px 20px;
    background: var(--chatbot-bg);
    border-bottom: 1px solid var(--chatbot-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.chatbot-header-avatar::after {
    content: '';
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    border: 2px solid white;
}

.chatbot-header-info {
    flex: 1;
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--chatbot-text);
}

.chatbot-header-info p {
    margin: 0;
    font-size: 12px;
    color: var(--chatbot-primary);
    font-weight: 500;
}

.chatbot-header-actions {
    display: flex;
    gap: 6px;
}

.chatbot-header-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--chatbot-bg-secondary);
    color: var(--chatbot-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chatbot-header-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chatbot-header-btn:hover {
    background: var(--chatbot-border);
    color: var(--chatbot-text);
}

/* ===== MESSAGES AREA ===== */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 200px;
    max-height: 380px;
    background: var(--chatbot-bg);
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

/* ===== WELCOME CARD ===== */

.chatbot-welcome {
    text-align: center;
    padding: 24px 16px;
    animation: chatbot-fadeInUp 0.5s var(--chatbot-transition);
}

.chatbot-welcome-icon {
    margin-bottom: 14px;
    display: flex;
    justify-content: center;
}

.chatbot-welcome-icon svg {
    width: 48px;
    height: 48px;
    stroke: var(--chatbot-primary);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chatbot-welcome h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--chatbot-text);
}

.chatbot-welcome p {
    font-size: 0.88rem;
    color: var(--chatbot-text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* ===== QUICK ACTIONS ===== */

.chatbot-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
    animation: chatbot-fadeInUp 0.5s var(--chatbot-transition) 0.15s both;
}

.chatbot-quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--chatbot-bg-secondary);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s var(--chatbot-transition);
    border: 1px solid transparent;
}

.chatbot-quick-action:hover {
    background: var(--chatbot-bg);
    border-color: rgba(0, 168, 107, 0.2);
    box-shadow: 0 4px 12px rgba(0, 168, 107, 0.08);
    transform: translateY(-1px);
}

.chatbot-qa-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--chatbot-primary-light);
}

.chatbot-qa-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--chatbot-primary);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chatbot-qa-text {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--chatbot-text);
    flex: 1;
}

.chatbot-qa-arrow {
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.25s;
}

.chatbot-qa-arrow svg {
    width: 14px;
    height: 14px;
    stroke: var(--chatbot-text-secondary);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chatbot-quick-action:hover .chatbot-qa-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ===== MESSAGE BUBBLES ===== */

.chatbot-msg-wrapper {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: chatbot-messageIn 0.35s var(--chatbot-transition);
}

.chatbot-msg-wrapper--bot {
    align-self: flex-start;
}

.chatbot-msg-wrapper--user {
    align-self: flex-end;
}

.chatbot-msg-wrapper--staff {
    align-self: flex-start;
}

.chatbot-msg {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-msg-bot {
    background: var(--chatbot-bot-msg);
    color: var(--chatbot-bot-text);
    border-bottom-left-radius: 6px;
}

.chatbot-msg-user {
    background: var(--chatbot-user-msg);
    color: var(--chatbot-user-text);
    border-bottom-right-radius: 6px;
}

.chatbot-msg-staff {
    background: #eef2ff;
    color: #312e81;
    border-bottom-left-radius: 6px;
}

.chatbot-msg-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--chatbot-text-secondary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-msg-label svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chatbot-msg-time {
    font-size: 11px;
    color: var(--chatbot-text-light);
    margin-top: 3px;
    padding: 0 2px;
}

.chatbot-msg-wrapper--user .chatbot-msg-time {
    text-align: right;
}

/* ===== CONFIDENCE BAR ===== */

.chatbot-confidence {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding: 5px 10px;
    background: var(--chatbot-primary-light);
    border-radius: 8px;
    font-size: 11px;
    color: var(--chatbot-text-secondary);
}

.chatbot-confidence-track {
    width: 50px;
    height: 3px;
    background: var(--chatbot-border);
    border-radius: 2px;
    overflow: hidden;
}

.chatbot-confidence-fill {
    height: 100%;
    background: var(--chatbot-primary);
    border-radius: 2px;
    transition: width 0.6s var(--chatbot-transition);
}

/* ===== FEEDBACK BUTTONS ===== */

.chatbot-feedback {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.chatbot-feedback-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--chatbot-border);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--chatbot-text-light);
    padding: 0;
}

.chatbot-feedback-btn svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chatbot-feedback-btn:hover {
    border-color: var(--chatbot-primary);
    color: var(--chatbot-primary);
    transform: scale(1.1);
}

.chatbot-feedback-btn.chatbot-voted {
    background: var(--chatbot-primary);
    border-color: var(--chatbot-primary);
    color: white;
    pointer-events: none;
}

/* ===== SUGGESTIONS ===== */

.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    animation: chatbot-fadeInUp 0.3s var(--chatbot-transition);
}

.chatbot-suggestion-btn {
    background: white;
    border: 1px solid var(--chatbot-border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--chatbot-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-family: inherit;
}

.chatbot-suggestion-btn:hover {
    background: var(--chatbot-primary-light);
    border-color: var(--chatbot-primary);
    transform: translateY(-1px);
}

/* ===== TYPING INDICATOR ===== */

.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chatbot-bot-msg);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    align-self: flex-start;
    animation: chatbot-messageIn 0.35s var(--chatbot-transition);
}

.chatbot-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--chatbot-text-light);
    animation: chatbot-typingBounce 1.4s infinite;
}

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

/* ===== INPUT AREA ===== */

.chatbot-input-area {
    padding: 14px 16px;
    border-top: 1px solid var(--chatbot-border);
    background: var(--chatbot-bg);
    flex-shrink: 0;
}

.chatbot-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--chatbot-bg-secondary);
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.chatbot-input-wrapper:focus-within {
    background: var(--chatbot-bg);
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 4px rgba(0, 168, 107, 0.1);
}

.chatbot-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    font-family: inherit;
    color: var(--chatbot-text);
    padding: 8px 0;
}

.chatbot-input::placeholder {
    color: var(--chatbot-text-light);
}

.chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--chatbot-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    flex-shrink: 0;
}

.chatbot-send svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chatbot-send:hover {
    background: var(--chatbot-primary-hover);
    transform: scale(1.05);
}

.chatbot-send:active {
    transform: scale(0.95);
}

.chatbot-send:disabled {
    background: var(--chatbot-border);
    cursor: not-allowed;
    transform: none;
}

/* ===== FOOTER ===== */

.chatbot-footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: var(--chatbot-text-light);
    background: var(--chatbot-bg);
    flex-shrink: 0;
}

/* ===== DATE SEPARATOR ===== */

.chatbot-date-sep {
    text-align: center;
    font-size: 11px;
    color: var(--chatbot-text-light);
    padding: 4px 0;
    position: relative;
}

.chatbot-date-sep::before,
.chatbot-date-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 28%;
    height: 1px;
    background: var(--chatbot-border);
}

.chatbot-date-sep::before { left: 0; }
.chatbot-date-sep::after { right: 0; }

/* ===== LOAD MORE ===== */

.chatbot-load-more {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: var(--chatbot-primary);
    font-size: 12px;
    cursor: pointer;
    padding: 8px;
    text-align: center;
    transition: background 0.15s;
    border-radius: 8px;
    font-family: inherit;
}

.chatbot-load-more:hover {
    background: var(--chatbot-primary-light);
}

.chatbot-load-more:disabled {
    color: var(--chatbot-text-secondary);
    cursor: default;
}

/* ===== ANIMATIONS ===== */

@keyframes chatbot-fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes chatbot-scaleIn {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes chatbot-messageIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chatbot-typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== RESPONSIVE ===== */

@media (max-width: 480px) {
    .chatbot-window {
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 100vh;
        border-radius: 0;
    }

    .chatbot-messages {
        max-height: calc(100vh - 200px);
    }

    .chatbot-trigger {
        bottom: 16px;
        right: 16px;
    }

    .chatbot-trigger-tooltip {
        display: none;
    }
}
