/**
 * Moore Truck Parts AI Assistant - Front-End CSS (Perfection Edition)
 */

:root {
    --mtp-red: #c8102e;
    --mtp-red-hover: #b00d27;
    --mtp-dark: #1d2327;
    --mtp-gray-bg: #f5f6f8;
    --mtp-border: #e2e4e8;
    --mtp-text: #2c3338;
    --mtp-green: #107c41;
    --mtp-green-bg: #e6f7eb;
    --mtp-orange: #d97706;
    --mtp-orange-bg: #fffbeb;
}

.mtp-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Floating Action Button (FAB) */
.mtp-chat-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--mtp-red);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(200, 16, 46, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.mtp-chat-fab:hover {
    transform: scale(1.06);
    background-color: var(--mtp-red-hover);
    box-shadow: 0 6px 20px rgba(200, 16, 46, 0.5);
}

.mtp-chat-fab svg {
    width: 28px;
    height: 28px;
}

.mtp-fab-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #111;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 8px;
    border: 2px solid #fff;
    letter-spacing: 0.5px;
}

/* Chat Window */
.mtp-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 400px;
    height: 610px;
    max-height: calc(100vh - 90px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--mtp-border);
    animation: mtpSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mtpSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.mtp-chat-header {
    background: var(--mtp-red);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.mtp-header-avatar {
    width: 36px;
    height: 36px;
    background: #fff;
    color: var(--mtp-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.mtp-header-info {
    flex: 1;
    overflow: hidden;
}

.mtp-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.mtp-header-info h3 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.mtp-active-vehicle-badge {
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 140px;
}

.mtp-header-status {
    font-size: 11px;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.mtp-online-indicator {
    width: 7px;
    height: 7px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}

.mtp-header-reset {
    background: transparent;
    border: none;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    opacity: 0.85;
    transition: opacity 0.15s ease, transform 0.2s ease;
}

.mtp-header-reset:hover {
    opacity: 1;
    transform: rotate(180deg);
}

.mtp-header-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.8;
}

.mtp-header-close:hover {
    opacity: 1;
}

/* Messages Body */
.mtp-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--mtp-gray-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mtp-msg {
    display: flex;
    flex-direction: column;
    max-width: 90%;
}

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

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

.mtp-msg-bubble {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.48;
    word-break: break-word;
}

.mtp-msg-user .mtp-msg-bubble {
    background: var(--mtp-red);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.mtp-msg-bot .mtp-msg-bubble {
    background: #fff;
    color: var(--mtp-text);
    border: 1px solid var(--mtp-border);
    border-bottom-left-radius: 2px;
}

.mtp-msg-bubble p {
    margin: 0 0 6px 0;
}

.mtp-msg-bubble p:last-child {
    margin-bottom: 0;
}

.mtp-inline-link {
    color: var(--mtp-red);
    font-weight: 600;
    text-decoration: underline;
}

.mtp-inline-link:hover {
    color: var(--mtp-red-hover);
}

.mtp-msg-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.mtp-link-btn {
    display: inline-block;
    background: #fff;
    border: 1px solid var(--mtp-red);
    color: var(--mtp-red);
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 14px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.mtp-link-btn:hover {
    background: var(--mtp-red);
    color: #fff;
}

/* Product Card in Chat */
.mtp-card-product {
    background: #fff;
    border: 1px solid var(--mtp-border);
    border-left: 4px solid var(--mtp-red);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 12.5px;
}

.mtp-recommended-part {
    border-left-color: var(--mtp-green) !important;
    background: #fcfdfc;
}

.mtp-card-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}

.mtp-card-header strong {
    font-size: 13px;
    color: #111;
}

.mtp-stock-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
}

.mtp-stock-in {
    background: var(--mtp-green-bg);
    color: var(--mtp-green);
}

.mtp-stock-out {
    background: var(--mtp-orange-bg);
    color: var(--mtp-orange);
}

.mtp-card-sku {
    color: #555;
    font-size: 11.5px;
    margin: 4px 0 8px 0;
}

.mtp-card-actions {
    margin-top: 6px;
}

.mtp-view-part-btn {
    display: inline-block;
    background: var(--mtp-dark);
    color: #fff !important;
    font-size: 11.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.mtp-view-part-btn:hover {
    background: var(--mtp-red);
}

.mtp-backorder-btn {
    background: var(--mtp-orange) !important;
    color: #fff !important;
}

.mtp-backorder-btn:hover {
    background: #b45309 !important;
}

.mtp-truck-action {
    margin-top: 10px;
}

.mtp-primary-truck-btn {
    display: block;
    text-align: center;
    background: var(--mtp-red);
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.mtp-primary-truck-btn:hover {
    background: var(--mtp-red-hover);
}

/* Quick Suggestion Chips */
.mtp-chat-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid var(--mtp-border);
    scrollbar-width: none;
}

.mtp-chat-chips::-webkit-scrollbar {
    display: none;
}

.mtp-chip-btn {
    flex-shrink: 0;
    background: var(--mtp-gray-bg);
    border: 1px solid var(--mtp-border);
    color: var(--mtp-text);
    padding: 5px 10px;
    border-radius: 14px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.mtp-chip-btn:hover {
    background: var(--mtp-red);
    border-color: var(--mtp-red);
    color: #fff;
}

/* Input Form */
.mtp-chat-input-area {
    background: #fff;
    padding: 10px 12px;
    border-top: 1px solid var(--mtp-border);
}

.mtp-chat-form {
    display: flex;
    gap: 8px;
}

.mtp-chat-input {
    flex: 1;
    border: 1px solid var(--mtp-border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s ease;
}

.mtp-chat-input:focus {
    border-color: var(--mtp-red);
}

.mtp-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--mtp-red);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.mtp-chat-send-btn:hover {
    background: var(--mtp-red-hover);
}

/* Inline Lead / Backorder Modal */
.mtp-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: mtpFadeIn 0.2s ease;
}

@keyframes mtpFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mtp-modal-content {
    background: #fff;
    border-radius: 10px;
    width: 100%;
    max-height: 94%;
    overflow-y: auto;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.mtp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--mtp-border);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.mtp-modal-header h4 {
    margin: 0;
    font-size: 15px;
    color: var(--mtp-dark);
}

.mtp-modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.mtp-modal-sub {
    font-size: 12px;
    color: #666;
    margin: 0 0 14px 0;
    line-height: 1.4;
}

.mtp-form-group {
    margin-bottom: 10px;
}

.mtp-form-group label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: #444;
    margin-bottom: 4px;
}

.mtp-form-group input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--mtp-border);
    border-radius: 4px;
    font-size: 12.5px;
    outline: none;
}

.mtp-form-group input:focus {
    border-color: var(--mtp-red);
}

.mtp-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mtp-enq-status {
    color: var(--mtp-red);
    font-size: 12px;
    margin: 6px 0;
}

.mtp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.mtp-btn-cancel {
    background: #f0f0f1;
    border: 1px solid #dcdcde;
    padding: 7px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.mtp-btn-submit {
    background: var(--mtp-red);
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.mtp-btn-submit:hover {
    background: var(--mtp-red-hover);
}

/* Live Sydney Business Hours Banner */
.mtp-hours-banner {
    padding: 7px 12px;
    font-size: 11px;
    line-height: 1.35;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.mtp-banner-cutoff {
    background: #fffbeb;
    color: #92400e;
    border-bottom: 1px solid #fde68a;
}

.mtp-banner-open {
    background: #ecfdf5;
    color: #065f46;
    border-bottom: 1px solid #a7f3d0;
}

.mtp-banner-closed {
    background: #f3f4f6;
    color: #4b5563;
    border-bottom: 1px solid #e5e7eb;
}

.mtp-banner-dot {
    margin-right: 2px;
}

.mtp-hours-banner a {
    color: var(--mtp-red);
    font-weight: 700;
    text-decoration: underline;
}

/* Compliance and Warranty Badges */
.mtp-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0;
}

.mtp-compliance-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    letter-spacing: 0.2px;
}

.mtp-fups-badge {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.mtp-warranty-badge {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* Add to Cart in Chat */
.mtp-cart-btn {
    background: #107c41;
    color: #fff;
    border: none;
    padding: 7px 12px;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mtp-cart-btn:hover {
    background: #0b6a36;
}

.mtp-cart-btn-success {
    background: #047857 !important;
}

.mtp-checkout-shortcut {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    font-weight: 700;
    color: #107c41;
    text-decoration: underline;
}

/* Front-End Crash Kit Recommender */
.mtp-crash-kit-card {
    background: #fff;
    border: 1.5px solid #d97706;
    border-radius: 8px;
    margin-top: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
}

.mtp-crash-kit-header {
    background: #fffbeb;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #fde68a;
}

.mtp-crash-kit-title {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mtp-crash-icon {
    font-size: 18px;
}

.mtp-crash-kit-title h4 {
    margin: 0;
    font-size: 12.5px;
    color: #92400e;
    font-weight: 800;
}

.mtp-crash-subtitle {
    margin: 0;
    font-size: 10px;
    color: #b45309;
}

.mtp-kit-badge {
    background: #b45309;
    color: #fff;
    font-size: 9.5px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.mtp-crash-kit-list {
    padding: 6px 10px;
    max-height: 200px;
    overflow-y: auto;
}

.mtp-crash-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #e5e7eb;
}

.mtp-crash-item:last-child {
    border-bottom: none;
}

.mtp-crash-item-active {
    background: #fffbeb;
    border-radius: 4px;
    padding: 6px 4px;
}

.mtp-crash-item-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-width: 72%;
}

.mtp-crash-role {
    font-size: 9.5px;
    font-weight: 800;
    color: var(--mtp-red);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.mtp-crash-name {
    font-size: 11.5px;
    font-weight: 600;
    color: #111;
    text-decoration: none;
    line-height: 1.25;
}

.mtp-crash-name:hover {
    text-decoration: underline;
    color: var(--mtp-red);
}

.mtp-crash-meta {
    font-size: 10px;
    color: #6b7280;
}

.mtp-crash-item-action {
    display: flex;
    align-items: center;
}

.mtp-kit-cart-btn {
    background: #107c41;
    color: #fff;
    border: none;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
}

.mtp-kit-cart-btn:hover {
    background: #0b6a36;
}

.mtp-kit-backorder-btn {
    background: #f59e0b;
    color: #fff;
    border: none;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
}

.mtp-crash-kit-footer {
    background: #f9fafb;
    padding: 7px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f3f4f6;
}

.mtp-kit-guarantee {
    font-size: 9.5px;
    color: #4b5563;
    font-weight: 600;
}

.mtp-enq-full-kit-btn {
    background: var(--mtp-red);
    color: #fff;
    border: none;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 3px;
    cursor: pointer;
}

.mtp-enq-full-kit-btn:hover {
    background: var(--mtp-red-hover);
}

/* Photo Upload and Preview */
.mtp-file-input-wrapper {
    margin-top: 4px;
}

.mtp-file-input {
    font-size: 11px;
    padding: 3px 0 !important;
    border: none !important;
}

.mtp-file-preview-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    background: #f9fafb;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid var(--mtp-border);
}

.mtp-file-preview-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #d1d5db;
}

.mtp-file-remove-btn {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 3px;
    font-size: 10.5px;
    font-weight: 600;
    padding: 3px 8px;
    cursor: pointer;
}

.mtp-file-remove-btn:hover {
    background: #fecaca;
}

.mtp-field-hint {
    display: block;
    font-size: 10px;
    color: #6b7280;
    margin-top: 3px;
    line-height: 1.3;
}

/* Typing Indicator Animation */
.mtp-typing-indicator .mtp-msg-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
}

.mtp-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: mtpBounce 1.3s infinite;
}

.mtp-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.mtp-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes mtpBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .mtp-chat-container {
        bottom: 16px;
        right: 16px;
    }

    .mtp-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .mtp-form-row {
        grid-template-columns: 1fr;
    }
}
