/* AI chat assistant widget — Sub Delivery */
#sd-ai-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #B8722E;
    color: #fff;
    border: none;
    box-shadow: 0 8px 24px rgba(20, 23, 28, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.18s ease, background 0.18s ease;
}
#sd-ai-launcher:hover { background: #8F5822; transform: scale(1.05); }
#sd-ai-launcher .sd-ai-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2ECC71;
    border: 2px solid #fff;
}

#sd-ai-panel {
    position: fixed;
    right: 24px;
    bottom: 96px;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(20, 23, 28, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
#sd-ai-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.sd-ai-header {
    background: #14171C;
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sd-ai-header__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #B8722E;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.sd-ai-header__info { flex: 1; min-width: 0; }
.sd-ai-header__name { font-weight: 700; font-size: 0.9rem; }
.sd-ai-header__status { font-size: 0.7rem; color: rgba(255,255,255,0.6); display: flex; align-items: center; gap: 5px; }
.sd-ai-header__status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #2ECC71; display: inline-block; }
.sd-ai-header__close { background: none; border: none; color: rgba(255,255,255,0.75); font-size: 1.1rem; cursor: pointer; padding: 4px; }
.sd-ai-header__close:hover { color: #fff; }

.sd-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #F7F5F1;
}
.sd-ai-msg { max-width: 84%; font-size: 0.8125rem; line-height: 1.5; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.sd-ai-msg--assistant { align-self: flex-start; background: #fff; color: #14171C; border: 1px solid #E5E1D9; border-bottom-left-radius: 4px; }
.sd-ai-msg--user { align-self: flex-end; background: #B8722E; color: #fff; border-bottom-right-radius: 4px; }
.sd-ai-msg--system { align-self: center; background: transparent; color: #6B7280; font-size: 0.7rem; text-align: center; max-width: 100%; }

.sd-ai-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid #E5E1D9; border-radius: 14px; border-bottom-left-radius: 4px; }
.sd-ai-typing span { width: 6px; height: 6px; border-radius: 50%; background: #B8B2A2; animation: sd-ai-bounce 1.2s infinite ease-in-out; }
.sd-ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.sd-ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sd-ai-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.sd-ai-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; flex-shrink: 0; background: #F7F5F1; }
.sd-ai-quick button {
    background: #fff;
    border: 1px solid #E5E1D9;
    color: #3A3F47;
    font-size: 0.7rem;
    padding: 6px 10px;
    border-radius: 100px;
    cursor: pointer;
    font-family: inherit;
}
.sd-ai-quick button:hover { border-color: #B8722E; color: #B8722E; }

.sd-ai-input-row { display: flex; align-items: center; gap: 8px; padding: 12px; border-top: 1px solid #E5E1D9; flex-shrink: 0; background: #fff; }
.sd-ai-input-row textarea {
    flex: 1;
    resize: none;
    border: 1px solid #D8D3C8;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 0.8125rem;
    font-family: inherit;
    max-height: 80px;
    line-height: 1.4;
}
.sd-ai-input-row textarea:focus { outline: none; border-color: #B8722E; }
.sd-ai-send {
    background: #B8722E;
    color: #fff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sd-ai-send:hover { background: #8F5822; }
.sd-ai-send:disabled { opacity: 0.5; cursor: default; }

.sd-ai-callback-link { text-align: center; padding: 8px 16px 0; flex-shrink: 0; background: #F7F5F1; }
.sd-ai-callback-link button { background: none; border: none; color: #B8722E; font-size: 0.75rem; font-weight: 600; cursor: pointer; text-decoration: underline; font-family: inherit; }

.sd-ai-callback-form { padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; }
.sd-ai-callback-form h4 { margin: 0 0 2px; font-size: 0.9rem; }
.sd-ai-callback-form p { margin: 0 0 6px; font-size: 0.75rem; color: #6B7280; }
.sd-ai-callback-form input, .sd-ai-callback-form textarea {
    border: 1px solid #D8D3C8;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.8125rem;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}
.sd-ai-callback-form input:focus, .sd-ai-callback-form textarea:focus { outline: none; border-color: #B8722E; }
.sd-ai-callback-actions { display: flex; gap: 8px; margin-top: 4px; }
.sd-ai-callback-actions button { flex: 1; padding: 10px; border-radius: 8px; font-size: 0.8125rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-family: inherit; }
.sd-ai-btn-primary { background: #B8722E; color: #fff; }
.sd-ai-btn-primary:hover { background: #8F5822; }
.sd-ai-btn-outline { background: #fff; border-color: #D8D3C8 !important; color: #14171C; }
.sd-ai-callback-note { font-size: 0.75rem; color: #166534; background: #DCFCE7; padding: 10px 12px; border-radius: 8px; }
.sd-ai-callback-error { font-size: 0.75rem; color: #991B1B; background: #FEE2E2; padding: 10px 12px; border-radius: 8px; }

@media (max-width: 480px) {
    #sd-ai-panel { right: 12px; left: 12px; width: auto; bottom: 88px; }
    #sd-ai-launcher { right: 16px; bottom: 16px; }
}
