* {
    box-sizing: border-box;
}

#clinivance-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    font-family: 'Manrope', sans-serif;
    z-index: 2147483647 !important; /* Absolute maximum z-index to cover WhatsApp/other plugins */
}

/* Floating Chat Button */
#clinivance-chat-btn {
    position: relative;
    cursor: pointer;
}

.chat-btn-inner {
    background: linear-gradient(135deg, #10437c, #26cad3);
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 13px;
    box-shadow: 0 4px 12px rgba(16, 67, 124, 0.4);
    color: white;
    z-index: 2;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    width: 50px;
    height: 50px;
}

.chat-btn-inner:hover {
    width: 140px;
    transform: translateY(-2px);
}

.chat-btn-text {
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
    opacity: 0;
    width: 0;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chat-btn-inner:hover .chat-btn-text {
    opacity: 1;
    width: auto;
    margin-left: 8px;
}

/* Chat Input Protection */
#clinivance-chat-input {
    background-color: white !important;
    color: #333 !important;
    box-shadow: none !important;
    font-size: 16px !important; /* Prevents iOS Safari zoom */
    margin-bottom: 0 !important;
}

.online-dot-launcher {
    position: absolute;
    top: -2px;
    right: -4px;
    width: 10px;
    height: 10px;
    background-color: #22c55e;
    border-radius: 50%;
    border: 2px solid #10437c;
}

/* Chat Window */
#clinivance-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
    border: 1px solid #e5e7eb;
}

#clinivance-chat-window.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #10437c, #26cad3);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header-left {
    display: flex;
    gap: 12px;
}

.header-logo {
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-text h3 {
    margin: 0 0 2px 0 !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: white !important;
    line-height: 1.2 !important;
}

.header-text p {
    margin: 0 0 6px 0 !important;
    font-size: 12px !important;
    opacity: 0.9 !important;
    color: white !important;
    line-height: 1.4 !important;
}

.status-online {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    background: rgba(0,0,0,0.15);
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
}

#clinivance-close-btn {
    cursor: pointer;
    opacity: 0.8;
}

#clinivance-close-btn:hover {
    opacity: 1;
}

/* Trust Strip */
.trust-strip {
    background: #f8fafc;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Progress Bar */
.progress-bar-container {
    height: 2px;
    background: #f1f5f9;
    width: 100%;
}

.progress-bar {
    height: 100%;
    background: #10437c;
    width: 0%;
    transition: width 0.3s ease;
}

/* Chat Body */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #F0F4F5;
    display: flex;
    flex-direction: column;
}

/* Chat Messages */
.chat-message {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.bot {
    background: white;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.chat-message.user {
    background: #10437c;
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Options Container (2x2 Grid or Flex) */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
}

.options-flex {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 90%;
}

.quick-reply-btn {
    background: white;
    border: 1.5px solid #10437c;
    color: #10437c;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-reply-btn:hover {
    background: #10437c;
    color: white;
}

/* Free Text Form & Submit Button */
.free-text-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
}

.free-text-form .ui-input {
    flex: 1;
    margin-bottom: 0;
}

.free-text-form .ui-btn-primary {
    width: auto !important;
    padding: 12px 20px !important;
    white-space: nowrap;
}

.free-text-submit {
    background: #10437c;
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.free-text-submit:hover {
    background: #086370;
}

/* Forms & UI Cards */
.ui-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.ui-card h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #334155;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
}

.ui-input {
    width: 100% !important;
    padding: 12px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    outline: none !important;
    font-family: inherit !important;
    transition: border-color 0.2s !important;
    background-color: white !important;
    color: #333 !important;
    box-shadow: none !important;
    margin-bottom: 0 !important;
}

.ui-input:focus {
    border-color: #10437c;
}

.ui-btn-primary {
    width: 100% !important;
    background: #10437c !important;
    color: white !important;
    border: none !important;
    padding: 14px !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    cursor: pointer !important;
    font-family: inherit !important;
    transition: background 0.2s !important;
}

.ui-btn-primary:hover {
    background: #086370;
}

.ui-btn-secondary {
    width: 100%;
    background: #f1f5f9;
    color: #475569;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    margin-top: 8px;
}

/* Textareas */
.ui-textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    resize: vertical;
    min-height: 80px;
}

.ui-textarea:focus {
    border-color: #10437c;
}

/* File Upload Zone */
.file-upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
}

.file-upload-zone:hover {
    border-color: #10437c;
    background: #f1f8f9;
}

.file-upload-zone i {
    color: #64748b;
    margin-bottom: 8px;
}

.file-upload-zone p {
    font-size: 13px;
    color: #475569;
    margin: 0;
    font-weight: 500;
}

.file-upload-zone small {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* Step Indicator */
.step-indicator {
    font-size: 11px;
    font-weight: 700;
    color: #10437c;
    background: #e0f2f1;
    padding: 4px 8px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Smart Autocomplete Dropdown */
.smart-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 10;
    margin-top: 4px;
}

.dropdown-category {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    background: #f8fafc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    padding: 10px 12px;
    font-size: 13.5px;
    color: #334155;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

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

.dropdown-item:hover {
    background: #f0f9fa;
    color: #10437c;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #clinivance-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100dvh !important;
        max-height: none !important;
        border-radius: 0 !important;
        border: none !important;
        z-index: 99999 !important;
    }
    
    /* Hide floating close button on mobile so it doesn't block the input field */
    #clinivance-chat-window:not(.hidden) ~ #clinivance-chat-btn {
        display: none !important;
    }
    .chat-header {
        padding: 12px 16px;
    }
    .header-text h3 {
        font-size: 14.5px !important;
        margin-bottom: 2px;
    }
    .header-text p {
        font-size: 11.5px !important;
    }
    .chat-body {
        padding: 16px;
    }
    .clinivance-message {
        font-size: 13.5px !important;
        padding: 10px 14px !important;
        max-width: 90% !important;
    }
    .clinivance-options {
        gap: 6px !important;
    }
    .clinivance-option {
        font-size: 13px !important;
        padding: 10px 14px !important;
    }
    #clinivance-chat-input {
        font-size: 16px !important;
    }
}


/* Multi-Product Search List Builder */
.mp-search-container {
    position: relative;
    margin-bottom: 12px;
}

.mp-selected-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 180px;
    overflow-y: auto;
}

.mp-selected-item {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    border-radius: 6px;
    padding: 8px 12px;
    gap: 12px;
}

.mp-item-name {
    flex: 1;
    font-size: 13px;
    color: #1e293b;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-item-qty {
    width: 140px !important;
    padding: 6px 12px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    text-align: center !important;
    outline: none !important;
    flex: none !important;
}
.mp-item-qty:focus {
    border-color: #10437c;
}

.mp-item-remove {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}
.mp-item-remove:hover {
    background: #fee2e2;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #f4f4f5;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 12px;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #10437c;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
