/* ══════════════════════════════════════
   AI Chat Bubble — /createquotation
   ══════════════════════════════════════ */

/* ── Container ── */
.ai-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Toggle Button ── */
.ai-chat__toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f97316;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
    transition: all 0.2s ease;
    position: relative;
}

.ai-chat__toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.5);
}

.ai-chat__icon {
    width: 24px;
    height: 24px;
    color: white;
}

.ai-chat__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* ── Chat Panel ── */
.ai-chat__panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 400px;
    max-height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

/* ── Header ── */
.ai-chat__header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    gap: 8px;
}

.ai-chat__header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.ai-chat__header-info {
    font-size: 11px;
    opacity: 0.85;
}

.ai-chat__close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.ai-chat__close:hover {
    opacity: 1;
}

/* ── Messages Area ── */
.ai-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 340px;
    min-height: 200px;
}

.ai-chat__message {
    max-width: 88%;
    animation: ai-msg-in 0.2s ease-out;
}

@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-chat__message--user {
    align-self: flex-end;
}

.ai-chat__message--assistant {
    align-self: flex-start;
}

.ai-chat__message--user .ai-chat__message-content {
    background: #f97316;
    color: white;
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

.ai-chat__message--assistant .ai-chat__message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-radius: 16px 16px 16px 4px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

/* Table inside assistant message */
.ai-chat__message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 11px;
}

.ai-chat__message-content th {
    background: #e5e7eb;
    padding: 4px 6px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.ai-chat__message-content td {
    padding: 4px 6px;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

/* ── Typing indicator ── */
.ai-chat__typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 16px 16px 16px 4px;
    width: fit-content;
}

.ai-chat__typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: ai-typing 1.2s ease-in-out infinite;
}

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

@keyframes ai-typing {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* ── Apply Bar ── */
.ai-chat__apply-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: #f0fdf4;
    border-top: 1px solid #bbf7d0;
}

.ai-chat__apply-btn {
    flex: 1;
    padding: 8px 16px;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-chat__apply-btn:hover {
    background: #15803d;
}

.ai-chat__edit-btn {
    padding: 8px 16px;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-chat__edit-btn:hover {
    background: #f9fafb;
}

/* ── Input Area ── */
.ai-chat__input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.ai-chat__input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: 'Roboto', sans-serif;
    resize: none;
    line-height: 1.4;
    max-height: 80px;
    outline: none;
    transition: border-color 0.15s;
}

.ai-chat__input:focus {
    border-color: #f97316;
}

.ai-chat__send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f97316;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    transition: all 0.15s;
}

.ai-chat__send:hover {
    background: #ea580c;
}

.ai-chat__send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* ── Generated Part — Add to Quote button ── */
.ai-chat__add-part-btn {
    transition: background 0.15s, color 0.15s;
}

.ai-chat__add-part-btn:hover:not(:disabled) {
    background: #15803d !important;
}

.ai-chat__add-part-btn:disabled {
    cursor: default;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
    .ai-chat__panel {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 68px;
        max-height: 70vh;
    }
}
