/* chatbot */

.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* toggle button */
.chatbot-toggle--hidden {
    display: none;
}

.chatbot-toggle {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #0a0a0a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    transition: background 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
    margin-top: 10px;
}

.chatbot-toggle:hover {
    background: #262626;
    transform: scale(1.05);
}

.chatbot-toggle:focus-visible {
    outline: 2px solid #1e3a5f;
    outline-offset: 2px;
}

/* unread badge */
.chatbot-unread {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    pointer-events: none;
}

/* chat window */
.chatbot-window {
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e5e5e5;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 10px;
    animation: chatbot-slide-in 0.2s ease;
}

@keyframes chatbot-slide-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* header */
.chatbot-header {
    background: #0a0a0a;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

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

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

/* messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #e5e5e5; border-radius: 4px; }

/* individual message */
.chatbot-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

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

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

.chatbot-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
}

.chatbot-msg--bot .chatbot-msg-bubble {
    background: #f5f5f5;
    color: #171717;
    border-bottom-left-radius: 4px;
}

.chatbot-msg--user .chatbot-msg-bubble {
    background: #0a0a0a;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-msg-time {
    font-size: 10px;
    color: #a3a3a3;
    margin-top: 3px;
    padding: 0 4px;
}

/* panel (actions/forms below messages) */
.chatbot-panel {
    padding: 10px 14px 14px;
    border-top: 1px solid #e5e5e5;
    flex-shrink: 0;
    max-height: 220px;
    overflow-y: auto;
}

.chatbot-panel::-webkit-scrollbar {
    width: 4px;
}
.chatbot-panel::-webkit-scrollbar-track { background: transparent; }
.chatbot-panel::-webkit-scrollbar-thumb { background: #e5e5e5; border-radius: 4px; }

/* order list (welcome phase) */
.chatbot-order-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.chatbot-order-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.chatbot-order-card:hover {
    border-color: #171717;
    background: #fafafa;
}

.chatbot-order-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chatbot-order-card-id {
    font-size: 13px;
    font-weight: 600;
    color: #171717;
}

.chatbot-order-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: #525252;
    font-weight: 500;
}

.chatbot-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chatbot-order-card-meta {
    display: flex;
    gap: 10px;
    font-size: 11.5px;
    color: #a3a3a3;
    margin-top: 3px;
}

/* selected order banner */
.chatbot-selected-order {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
    border-radius: 8px;
    padding: 7px 10px;
    margin-bottom: 8px;
    border-left: 3px solid #0a0a0a;
}

.chatbot-selected-order-id {
    font-size: 12.5px;
    font-weight: 600;
    color: #171717;
}

/* action buttons */
.chatbot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chatbot-action-btn {
    background: transparent;
    border: 1px solid #e5e5e5;
    color: #171717;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    line-height: 1.3;
}

.chatbot-action-btn:hover {
    background: #fafafa;
    border-color: #171717;
}

.chatbot-action-btn--highlight {
    background: #0a0a0a;
    border-color: #0a0a0a;
    color: #fff;
}

.chatbot-action-btn--highlight:hover {
    background: #262626;
    border-color: #262626;
}

/* escalation note */
.chatbot-escalation-note {
    font-size: 12.5px;
    color: #525252;
    line-height: 1.5;
    margin-bottom: 10px;
}

/* escalation form */
.chatbot-escalation-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* text input */
.chatbot-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    color: #171717;
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.chatbot-input:focus {
    border-color: #171717;
}

.chatbot-input::placeholder { color: #a3a3a3; }

/* textarea */
.chatbot-textarea {
    resize: vertical;
    min-height: 72px;
    line-height: 1.5;
}

/* submit button */
.chatbot-submit-btn {
    background: #0a0a0a;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chatbot-submit-btn:hover:not(:disabled) {
    background: #262626;
}

.chatbot-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* disabled order card (cancellation requested) */
.chatbot-order-card--disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* cancellation notice */
.chatbot-cancellation-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    color: #c2410c;
    font-size: 0.8rem;
    line-height: 1.45;
    padding: 10px 12px;
    margin-bottom: 4px;
}

/* change order button */
.chatbot-change-order-btn {
    background: none;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    color: #525252;
    font-size: 0.72rem;
    font-family: inherit;
    padding: 2px 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.chatbot-change-order-btn:hover {
    border-color: #171717;
    color: #171717;
}

/* back button */
.chatbot-back-btn {
    background: none;
    border: none;
    color: #a3a3a3;
    font-size: 0.8rem;
    font-family: inherit;
    padding: 6px 0;
    margin-top: 4px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: color 0.15s ease;
}

.chatbot-back-btn:hover {
    color: #171717;
}

/* submitted state */
.chatbot-submitted {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 28px 20px;
    flex-shrink: 0;
    border-top: 1px solid #e5e5e5;
}

.chatbot-submitted-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #f0fdf4;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #16a34a;
    margin-bottom: 12px;
}

.chatbot-submitted h3 {
    font-size: 15px;
    font-weight: 700;
    color: #171717;
    margin: 0 0 6px;
}

.chatbot-submitted p {
    font-size: 13px;
    color: #525252;
    line-height: 1.55;
    margin: 0;
}

/* responsive */
@media (max-width: 440px) {
    .chatbot-widget {
        bottom: 12px;
        right: 8px;
        left: 8px;
        align-items: flex-end;
    }

    .chatbot-window {
        width: calc(100vw - 16px);
        height: 480px;
        border-radius: 14px;
    }

    .chatbot-toggle {
        width: 48px;
        height: 48px;
    }
}
