/* Betternship ChatBot — Frontend Widget Styles */

/* ── CSS Custom Properties ──────────────────────────────────────────────────── */
:root {
    --bc-primary:        #90A955;
    --bc-primary-dark:   #7a9248;
    --bc-primary-light:  #f0f4e8;
    --bc-secondary:      #6b7280;
    --bc-bg:             #ffffff;
    --bc-surface:        #f9fafb;
    --bc-border:         #e5e7eb;
    --bc-text:           #111827;
    --bc-text-muted:     #6b7280;
    --bc-user-bg:        #90A955;
    --bc-user-text:      #ffffff;
    --bc-bot-bg:         #f3f4f6;
    --bc-bot-text:       #111827;
    --bc-shadow:         0 4px 24px rgba(0,0,0,0.14);
    --bc-shadow-lg:      0 8px 40px rgba(0,0,0,0.18);
    --bc-radius:         16px;
    --bc-radius-msg:     12px;
    --bc-z:              99999;
    --bc-width:          380px;
    --bc-height:         540px;
    --bc-font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Wrapper ────────────────────────────────────────────────────────────────── */
#betternship-chatbot-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--bc-z);
    font-family: var(--bc-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--bc-text);
}

/* ── Toggle button ──────────────────────────────────────────────────────────── */
#betternship-chat-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--bc-shadow-lg);
    transition: background 0.2s, transform 0.2s;
    outline: none;
}

#betternship-chat-toggle:hover {
    background: var(--bc-primary-dark);
    transform: scale(1.06);
}

#betternship-chat-toggle:focus-visible {
    outline: 3px solid var(--bc-primary);
    outline-offset: 3px;
}

#betternship-chat-toggle svg {
    width: 26px;
    height: 26px;
    transition: opacity 0.2s, transform 0.2s;
}

/* Show chat icon by default, hide close icon */
#betternship-chat-toggle .bc-icon-chat  { opacity: 1; transform: scale(1); }
#betternship-chat-toggle .bc-icon-close { opacity: 0; transform: scale(0.7); position: absolute; }

/* When open: swap icons */
#betternship-chat-toggle[aria-expanded="true"] .bc-icon-chat  { opacity: 0; transform: scale(0.7); }
#betternship-chat-toggle[aria-expanded="true"] .bc-icon-close { opacity: 1; transform: scale(1); }

/* Unread badge */
.bc-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}

/* ── Chat window ────────────────────────────────────────────────────────────── */
#betternship-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: var(--bc-width);
    height: var(--bc-height);
    background: var(--bc-bg);
    border-radius: var(--bc-radius);
    box-shadow: var(--bc-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: bc-slide-up 0.22s ease;
}

#betternship-chat-window[hidden] {
    display: none;
}

@keyframes bc-slide-up {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.bc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bc-primary);
    color: #fff;
    flex-shrink: 0;
}

.bc-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.bc-header-info {
    flex: 1;
    min-width: 0;
}

.bc-header-name {
    display: block;
    font-weight: 700;
    font-size: 15px;
}

.bc-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    opacity: 0.85;
}

.bc-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
}

.bc-header-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.bc-header-close:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.bc-header-close svg {
    width: 18px;
    height: 18px;
}

/* ── Messages area ──────────────────────────────────────────────────────────── */
.bc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.bc-messages::-webkit-scrollbar { width: 4px; }
.bc-messages::-webkit-scrollbar-track { background: transparent; }
.bc-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* Message bubbles */
.bc-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    animation: bc-fade-in 0.18s ease;
}

@keyframes bc-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bc-message-bot {
    align-self: flex-start;
}

.bc-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.bc-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bc-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.bc-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--bc-radius-msg);
    word-break: break-word;
    line-height: 1.55;
    font-size: 14px;
}

.bc-message-bot  .bc-msg-bubble {
    background: var(--bc-bot-bg);
    color: var(--bc-bot-text);
    border-bottom-left-radius: 4px;
}

.bc-message-user .bc-msg-bubble {
    background: var(--bc-user-bg);
    color: var(--bc-user-text);
    border-bottom-right-radius: 4px;
}

/* Timestamp */
.bc-msg-time {
    font-size: 10px;
    color: var(--bc-text-muted);
    margin-top: 3px;
    padding: 0 4px;
    text-align: right;
}

.bc-message-bot .bc-msg-time { text-align: left; }

/* ── Typing indicator ───────────────────────────────────────────────────────── */
.bc-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 8px;
    flex-shrink: 0;
}

.bc-typing-indicator[hidden] {
    display: none;
}

.bc-typing-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bc-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.bc-typing-dots {
    background: var(--bc-bot-bg);
    border-radius: var(--bc-radius-msg);
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.bc-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bc-secondary);
    animation: bc-bounce 1.2s ease-in-out infinite;
}

.bc-typing-dots span:nth-child(1) { animation-delay: 0s; }
.bc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.bc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Action buttons ─────────────────────────────────────────────────────────── */
.bc-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 14px 10px;
    flex-shrink: 0;
}

.bc-action-buttons[hidden] {
    display: none;
}

.bc-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    border: 2px solid transparent;
    font-family: var(--bc-font);
}

.bc-action-btn:focus-visible {
    outline: 3px solid var(--bc-primary);
    outline-offset: 2px;
}

.bc-action-btn.primary {
    background: var(--bc-primary);
    color: #fff;
    border-color: var(--bc-primary);
}

.bc-action-btn.primary:hover {
    background: var(--bc-primary-dark);
    border-color: var(--bc-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(144,169,85,0.35);
}

.bc-action-btn.secondary {
    background: transparent;
    color: var(--bc-primary);
    border-color: var(--bc-primary);
}

.bc-action-btn.secondary:hover {
    background: var(--bc-primary-light);
    transform: translateY(-1px);
}

/* ── Input footer ───────────────────────────────────────────────────────────── */
.bc-footer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--bc-border);
    background: var(--bc-bg);
    flex-shrink: 0;
}

.bc-input {
    flex: 1;
    border: 1.5px solid var(--bc-border);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--bc-font);
    color: var(--bc-text);
    background: var(--bc-surface);
    resize: none;
    outline: none;
    max-height: 96px;
    overflow-y: auto;
    transition: border-color 0.15s;
    line-height: 1.4;
}

.bc-input:focus {
    border-color: var(--bc-primary);
    background: #fff;
}

.bc-input::placeholder {
    color: #9ca3af;
}

.bc-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
}

.bc-send-btn:hover:not(:disabled) {
    background: var(--bc-primary-dark);
    transform: scale(1.05);
}

.bc-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.bc-send-btn svg {
    width: 18px;
    height: 18px;
}

/* ── Branding ────────────────────────────────────────────────────────────────── */
.bc-branding {
    text-align: center;
    font-size: 11px;
    color: var(--bc-text-muted);
    padding: 4px 0 8px;
    flex-shrink: 0;
}

.bc-branding a {
    color: var(--bc-primary);
    text-decoration: none;
}

/* ── AI label ────────────────────────────────────────────────────────────────── */
.bc-header-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bc-ai-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.22);
    color: #fff;
    font-family: var(--bc-font);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.35);
    white-space: nowrap;
}

.bc-ai-label::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

/* ── Prompt banner ───────────────────────────────────────────────────────────── */
.bc-chat-banner {
    position: absolute;
    bottom: 72px;
    right: 0;
    background: var(--bc-primary);
    color: #fff;
    border-radius: 12px;
    padding: 12px 36px 12px 14px;
    box-shadow: var(--bc-shadow);
    max-width: 220px;
    animation: bc-banner-in 0.3s ease;
}

.bc-chat-banner[hidden] {
    display: none;
}

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

/* Arrow pointing down toward the toggle button */
.bc-chat-banner::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--bc-primary);
}

.bc-banner-text {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}

.bc-banner-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s;
}

.bc-banner-close:hover {
    color: #fff;
}

/* ── Error state ─────────────────────────────────────────────────────────────── */
.bc-msg-bubble.bc-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── Mobile responsive ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #betternship-chatbot-wrapper {
        bottom: 16px;
        right: 16px;
    }

    #betternship-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 90vh;
        border-radius: var(--bc-radius) var(--bc-radius) 0 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    #betternship-chat-toggle {
        z-index: calc(var(--bc-z) + 1);
    }
}
