/* ============================================
   AI Career Advisor - Clean Chat UI
   ============================================ */

/* -- Bubble Wrapper -- */
.ai-bubble-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

/* -- Annotation Label -- */
.ai-bubble-label {
    background: #fff;
    color: #333;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    animation: ai-label-float 3s infinite ease-in-out;
    border: 1px solid #e8e8ee;
}

.ai-bubble-label::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 28px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #e8e8ee;
    border-bottom: 1px solid #e8e8ee;
    transform: rotate(45deg);
}

.ai-bubble-label-close {
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.ai-bubble-label-close:hover { color: #333; }
.ai-bubble-label.hidden { display: none; }

@keyframes ai-label-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* -- Bubble Button -- */
.ai-chat-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
.ai-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(79, 70, 229, 0.5);
}
.ai-chat-bubble.active {
    background: linear-gradient(135deg, #dc2626, #e11d48);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
}
.ai-bubble-icon { pointer-events: none; }

/* -- Chat Panel -- */
.ai-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    transform: translateY(16px) scale(0.96);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    border: 1px solid #e5e7eb;
}
.ai-chat-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* -- Header -- */
.ai-chat-header {
    background: #fff;
    color: #111;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    border-bottom: 1px solid #e5e7eb;
}
.ai-chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ai-chat-header-info { flex: 1; min-width: 0; }
.ai-chat-header-info h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #111;
}
.ai-chat-header-info small {
    font-size: 11px;
    color: #6b7280;
}
.ai-chat-header-actions { display: flex; gap: 4px; }
.ai-chat-header-actions button {
    background: none;
    border: 1px solid #e5e7eb;
    color: #6b7280;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}
.ai-chat-header-actions button:hover {
    background: #f3f4f6;
    color: #111;
}
.ai-chat-header-actions button.active-view {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}

/* -- History Panel -- */
.ai-history-panel {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f9fafb;
    display: none;
}
.ai-history-panel.show { display: block; }

.ai-history-empty {
    text-align: center;
    padding: 40px 16px;
    color: #9ca3af;
    font-size: 13px;
}

.ai-history-item {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.15s;
    border: 1px solid transparent;
}
.ai-history-item:hover {
    background: #fff;
    border-color: #e5e7eb;
}
.ai-history-item-title {
    font-size: 13px;
    font-weight: 500;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-history-item-meta {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* -- Messages Area -- */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
}
.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* -- Messages -- */
.ai-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}
.ai-msg.user { align-self: flex-end; }
.ai-msg.assistant { align-self: flex-start; }

.ai-msg-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}
.ai-msg.user .ai-msg-content {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ai-msg.assistant .ai-msg-content {
    background: #fff;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.ai-msg-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 3px;
    padding: 0 4px;
}
.ai-msg.user .ai-msg-time { text-align: right; }

/* -- Result Cards -- */
.ai-result-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-top: 8px;
    overflow: hidden;
}
.ai-result-card-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid #f3f4f6;
}
.ai-result-card-header.evaluation { background: #f5f3ff; color: #5b21b6; }
.ai-result-card-header.skills { background: #fef3c7; color: #92400e; }
.ai-result-card-header.jobs { background: #ecfdf5; color: #065f46; }
.ai-result-card-body {
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.55;
}

/* -- Skill Items -- */
.ai-skill-item {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}
.ai-skill-item:last-child { border-bottom: none; }
.ai-skill-name { font-weight: 600; color: #92400e; font-size: 12.5px; margin-bottom: 2px; }
.ai-skill-reason { color: #6b7280; font-size: 12px; margin-bottom: 2px; }
.ai-skill-course { font-size: 11.5px; color: #2563eb; }
.ai-skill-course i { margin-right: 3px; }

/* -- Job Items -- */
.ai-job-item {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.ai-job-item:last-child { border-bottom: none; }
.ai-job-info { flex: 1; min-width: 0; }
.ai-job-title { font-weight: 600; color: #065f46; font-size: 12.5px; margin-bottom: 2px; }
.ai-job-salary { font-size: 11.5px; color: #92400e; font-weight: 500; }
.ai-job-reason { font-size: 11.5px; color: #6b7280; }
.ai-job-action .btn { font-size: 11px; padding: 3px 10px; border-radius: 6px; }

/* -- Matched Jobs -- */
.ai-matched-jobs-header { background: #eff6ff; color: #1e40af; }
.ai-matched-job-item {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}
.ai-matched-job-item:last-child { border-bottom: none; }
.ai-matched-job-title { font-weight: 600; font-size: 12.5px; color: #1e40af; }
.ai-matched-job-company { font-size: 11.5px; color: #6b7280; }
.ai-matched-job-meta { font-size: 11.5px; color: #9ca3af; margin-top: 1px; }

/* -- Save Button -- */
.ai-save-roadmap-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 7px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.ai-save-roadmap-btn:hover { background: #4338ca; }
.ai-save-roadmap-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* -- Typing -- */
.ai-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e7eb;
}
.ai-typing-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4f46e5;
    animation: ai-typing-bounce 1.4s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes ai-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* -- Input Area -- */
.ai-chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.ai-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.ai-chat-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s;
    resize: none;
    min-height: 38px;
    max-height: 80px;
    line-height: 1.4;
    font-family: inherit;
}
.ai-chat-input:focus { border-color: #4f46e5; }
.ai-chat-input::placeholder { color: #9ca3af; }

.ai-chat-send-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: #4f46e5;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.15s;
    flex-shrink: 0;
}
.ai-chat-send-btn:hover { background: #4338ca; }
.ai-chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* -- Upload -- */
.ai-upload-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}
.ai-chat-upload-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: #f3f4f6;
    color: #4f46e5;
    border: 1px solid #d1d5db;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s;
}
.ai-chat-upload-btn:hover {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}
.ai-upload-label {
    font-size: 9px;
    font-weight: 700;
    color: #4f46e5;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* -- Send Wrapper (symmetric with upload) -- */
.ai-send-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}
.ai-send-label {
    font-size: 9px;
    font-weight: 700;
    color: #4f46e5;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* -- Welcome -- */
.ai-welcome {
    text-align: center;
    padding: 32px 20px;
}
.ai-welcome-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}
.ai-welcome h6 {
    font-size: 15px;
    font-weight: 600;
    color: #111;
    margin-bottom: 6px;
}
.ai-welcome p {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
}

/* -- Login Required -- */
.ai-login-required {
    text-align: center;
    padding: 40px 24px;
}
.ai-login-required i { font-size: 40px; color: #4f46e5; margin-bottom: 14px; }
.ai-login-required p { color: #6b7280; margin-bottom: 14px; font-size: 13px; }
.ai-login-required .btn { border-radius: 8px; padding: 6px 20px; font-size: 13px; }

/* -- Responsive -- */
@media (max-width: 480px) {
    .ai-chat-panel {
        right: 8px;
        bottom: 76px;
        width: calc(100vw - 16px);
        height: calc(100vh - 96px);
        border-radius: 14px;
    }
    .ai-bubble-wrapper { bottom: 12px; right: 12px; }
    .ai-chat-bubble { width: 50px; height: 50px; }
    .ai-bubble-label { font-size: 12px; padding: 6px 10px; }
}
