/**
 * CONMARET AI Bilingual Sales Assistant Stylesheet
 * Optimized for mobile viewports, high contrast, and smooth animations.
 */

:root {
    --cm-primary: #0f172a;
    --cm-primary-light: #1e293b;
    --cm-accent: #f59e0b;
    --cm-accent-hover: #d97706;
    --cm-bg-light: #f8fafc;
    --cm-card-bg: #ffffff;
    --cm-border: #e2e8f0;
    --cm-text-dark: #0f172a;
    --cm-text-muted: #64748b;
    --cm-green: #10b981;
    --cm-red: #ef4444;
    --cm-shadow: 0 12px 36px rgba(15, 23, 42, 0.16);
    --cm-radius: 14px;
}

/* Chat Root Wrapper */
.conmaret-chat-wrapper {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99990;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Ethiopic", sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

/* Floating Launcher Button */
.cm-chat-launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--cm-primary);
    color: #ffffff;
    border: 2px solid var(--cm-accent);
    padding: 12px 20px 12px 16px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    outline: none;
}
.cm-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
    background: #020617;
}
.cm-launcher-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.cm-launcher-badge {
    background: var(--cm-accent);
    color: var(--cm-primary);
    font-size: 11px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}
.cm-launcher-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

/* Chat Panel */
.cm-chat-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    box-shadow: var(--cm-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99991;
    animation: cmSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Header */
.cm-chat-header {
    background: var(--cm-primary);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid var(--cm-accent);
}
.cm-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cm-avatar {
    width: 36px;
    height: 36px;
    background: var(--cm-primary-light);
    border: 1.5px solid var(--cm-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.cm-header-title {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.3px;
}
.cm-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #94a3b8;
}
.cm-status-dot {
    width: 7px;
    height: 7px;
    background: var(--cm-green);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--cm-green);
}
.cm-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cm-btn-lang, .cm-btn-call, .cm-btn-close {
    background: rgba(255, 255, 255, 0.1);
    border: 0;
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    text-decoration: none;
}
.cm-btn-lang:hover, .cm-btn-call:hover, .cm-btn-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Quotation Tray Bar */
.cm-quote-tray {
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: #92400e;
}
.cm-tray-content {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cm-btn-tray-action {
    background: #d97706;
    color: #ffffff;
    border: 0;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s ease;
}
.cm-btn-tray-action:hover {
    background: #b45309;
}

/* Messages Scroll Container */
.cm-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--cm-bg-light);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.cm-msg-row {
    display: flex;
    width: 100%;
}
.cm-msg-bot {
    justify-content: flex-start;
}
.cm-msg-user {
    justify-content: flex-end;
}
.cm-msg-bubble {
    max-width: 86%;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.cm-msg-bot .cm-msg-bubble {
    background: #ffffff;
    color: var(--cm-text-dark);
    border: 1px solid var(--cm-border);
    border-bottom-left-radius: 3px;
}
.cm-msg-user .cm-msg-bubble {
    background: var(--cm-primary);
    color: #ffffff;
    border-bottom-right-radius: 3px;
}
.cm-msg-bubble p {
    margin: 0 0 6px;
}
.cm-msg-bubble p:last-child {
    margin-bottom: 0;
}

/* Quick Action Chips */
.cm-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.cm-chip {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.cm-chip:hover {
    background: var(--cm-primary);
    color: #ffffff;
    border-color: var(--cm-primary);
}

/* Product Cards Container in Chat */
.cm-products-carousel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}
.cm-product-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    transition: border-color 0.15s ease;
}
.cm-product-card:hover {
    border-color: var(--cm-accent);
}
.cm-card-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    flex-shrink: 0;
}
.cm-card-body {
    flex: 1;
    min-width: 0;
}
.cm-card-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--cm-text-dark);
    margin: 0 0 6px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.45;
}
.cm-card-price {
    font-size: 14.5px;
    font-weight: 800;
    color: #b45309;
    margin: 0 0 4px;
    line-height: 1.35;
}
.cm-card-unit {
    display: inline-block;
    font-size: 11.5px;
    color: #475569;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 6px;
}
.cm-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}
.cm-btn-card-add, .cm-btn-card-view {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    border: 0;
    transition: background 0.15s ease;
}
.cm-btn-card-add {
    background: var(--cm-primary);
    color: #ffffff;
}
.cm-btn-card-add:hover {
    background: #1e293b;
}
.cm-btn-card-view {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}
.cm-btn-card-view:hover {
    background: #e2e8f0;
}

/* Quote Modal Overlay */
.cm-quote-modal {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.cm-quote-card {
    background: #ffffff;
    border-top: 3px solid var(--cm-accent);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    padding: 16px;
    max-height: 85%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
}
.cm-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cm-modal-head h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    color: var(--cm-text-dark);
}
.cm-btn-icon {
    background: transparent;
    border: 0;
    font-size: 22px;
    cursor: pointer;
    color: var(--cm-text-muted);
}
.cm-modal-items {
    background: #f8fafc;
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 14px;
    max-height: 120px;
    overflow-y: auto;
}
.cm-modal-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
}
.cm-modal-item-row:last-child {
    border-bottom: 0;
}
.cm-form-group {
    margin-bottom: 10px;
}
.cm-form-group label {
    display: block;
    font-size: 11.5px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #334155;
}
.cm-form-group input, .cm-form-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
}
.cm-consent-box {
    margin: 10px 0;
}
.cm-checkbox-label {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: #475569;
    cursor: pointer;
}
.cm-checkbox-label input {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}
.cm-btn-submit {
    width: 100%;
    background: var(--cm-primary);
    color: #ffffff;
    border: 0;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.15s ease;
}
.cm-btn-submit:hover {
    background: #020617;
}
.cm-error-msg {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 8px;
    border-radius: 6px;
    font-size: 11.5px;
    margin-bottom: 10px;
    font-weight: 600;
}

/* Chat Input Bar */
.cm-chat-footer {
    background: #ffffff;
    border-top: 1px solid var(--cm-border);
    padding: 10px 14px 8px;
}
.cm-chat-form {
    display: flex;
    gap: 8px;
    align-items: center;
}
.cm-chat-input {
    flex: 1;
    border: 1px solid var(--cm-border);
    border-radius: 24px;
    padding: 9px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}
.cm-chat-input:focus {
    border-color: var(--cm-primary);
}
.cm-btn-send {
    background: var(--cm-primary);
    color: #ffffff;
    border: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.cm-btn-send:hover {
    background: #1e293b;
}
.cm-footer-disclaimer {
    font-size: 10px;
    color: var(--cm-text-muted);
    text-align: center;
    margin-top: 6px;
    letter-spacing: 0.2px;
}

/* Typing Indicator */
.cm-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
}
.cm-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: cmBounce 1.2s infinite ease-in-out;
}
.cm-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cm-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cmBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
}

/* Mobile Usability (Samsung Galaxy M16, 320px, 360px, 390px, 430px Viewports) */
@media (max-width: 640px) {
    .conmaret-chat-wrapper {
        right: 14px;
        bottom: 74px; /* Position cleanly above Woodmart mobile bottom nav */
        z-index: 99990;
    }
    .cm-chat-launcher {
        padding: 10px 14px;
        border-radius: 50px;
        box-shadow: 0 6px 20px rgba(15, 23, 42, 0.3);
    }
    .cm-launcher-label {
        display: none; /* Keep clean icon and badge when closed on mobile */
    }

    /* Full-screen responsive app panel on mobile */
    .cm-chat-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        z-index: 999999 !important;
        display: flex;
        flex-direction: column;
    }

    .cm-chat-header {
        padding: 12px 14px !important;
        border-radius: 0 !important;
        flex-shrink: 0 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    .cm-header-title {
        font-size: 13.5px !important;
    }
    .cm-btn-close {
        width: 38px !important;
        height: 38px !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .cm-btn-close:active {
        background: rgba(255, 255, 255, 0.3) !important;
    }

    .cm-messages-container {
        padding: 14px 12px 16px !important;
        font-size: 14px !important;
        line-height: 1.6 !important;
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .cm-msg-bubble {
        max-width: 92% !important;
        font-size: 13.5px !important;
        line-height: 1.6 !important;
    }

    /* Single-column product cards on narrow screens */
    .cm-product-card {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 12px !important;
        gap: 8px !important;
        background: #ffffff !important;
        border: 1.5px solid #e2e8f0 !important;
        border-radius: 10px !important;
    }
    .cm-card-thumb {
        width: 100% !important;
        height: 110px !important;
        object-fit: contain !important;
        background: #f8fafc !important;
        border-radius: 6px !important;
    }
    .cm-card-body {
        width: 100% !important;
    }
    .cm-card-title {
        white-space: normal !important;
        font-size: 13.5px !important;
        line-height: 1.45 !important;
        margin-bottom: 6px !important;
    }
    .cm-card-price {
        font-size: 15px !important;
        margin-bottom: 4px !important;
    }
    .cm-card-unit {
        display: inline-block !important;
        font-size: 12px !important;
        padding: 3px 8px !important;
        margin-bottom: 8px !important;
    }
    .cm-card-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        margin-top: 6px !important;
    }
    .cm-btn-card-add, .cm-btn-card-view {
        height: 42px !important;
        font-size: 13px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
    }

    /* Input pinned above keyboard */
    .cm-chat-footer {
        padding: 10px 12px max(12px, env(safe-area-inset-bottom)) !important;
        background: #ffffff !important;
        border-top: 1px solid #e2e8f0 !important;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.06) !important;
        flex-shrink: 0 !important;
    }
    .cm-chat-input {
        font-size: 14.5px !important;
        padding: 11px 16px !important;
        height: 44px !important;
        box-sizing: border-box !important;
    }
    .cm-btn-send {
        width: 44px !important;
        height: 44px !important;
        flex-shrink: 0 !important;
    }

    /* Quote Modal Full Screen on Mobile */
    .cm-quote-modal {
        position: fixed !important;
        inset: 0 !important;
        z-index: 9999999 !important;
    }
    .cm-quote-card {
        max-height: 90% !important;
        border-radius: 16px 16px 0 0 !important;
        padding: 16px !important;
    }
}
