:root {
    --orange: #FF5900;
    --dark: #121212;
    --light-bg: #F5F7FA;
}

/* Global body styles removed to prevent main site conflict. They are now inline in chat.php for standalone use. */

.chat-main-container {
    width: 100%;
    height: 100%;
    max-width: 500px;
    background: white;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    overflow: visible !important; /* Allow children (like DDI dropdown) to exceed boundaries */
}

@media (min-width: 768px) {
    .chat-main-container {
        height: 90vh;
        border-radius: 20px;
        overflow: visible !important; 
    }
}

#leadCaptureOverlay,
#leadCaptureForm,
.capture-card,
.mb-4,
.iti {
    overflow: visible !important;
}

.chat-header {
    background-color: var(--dark);
    color: white;
    padding: 12px 60px 12px 18px; /* 60px right padding ensures overlap safety on both desktop and mobile */
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-height: 70px;
    /* Flex layout! No absolute positioning */
    flex: 0 0 auto;
    width: 100%;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar-wrapper {
    position: relative;
    width: 42px;
    height: 42px;
}

.chat-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background-color: white;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.chat-header-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.chat-header-name {
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.verified-badge {
    color: #2096f3;
    font-size: 13px;
}

.chat-header-status {
    font-size: 11px;
    color: #4ade80;
    font-weight: 500;
}

.chat-header-actions {
    display: flex;
    gap: 20px;
    font-size: 18px;
    opacity: 0.8;
}

.chat-window {
    /* Takes remaining space naturally */
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Background fixes for mobile */
    background-image: linear-gradient(rgb(255 255 255 / 72%), rgb(255 255 255 / 75%)), url(../img/back-chat2.jpg);
    background-attachment: scroll;
    /* Scroll is more stable on iOS */
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

/* Message Bubbles - More WhatsApp-like */
.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    position: relative;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-lead {
    align-self: flex-end;
    background: #dcf8c6;
    /* WhatsApp inbound green */
    color: #333;
    border-top-right-radius: 2px;
}

.message-ia,
.message-admin {
    align-self: flex-start;
    background-color: #ffffff;
    color: #333;
    border-top-left-radius: 2px;
}

.message-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.5;
    display: block;
    text-align: right;
}

.chat-footer {
    background: #f0f0f0;
    padding: 12px 15px;
    border-top: none;
    z-index: 10;
    flex-shrink: 0;
    /* Important so footer never shrinks */
    width: 100%;
}

.input-group-chat {
    background: var(--light-bg);
    border-radius: 30px;
    padding: 5px 15px;
    border: 1px solid #E1E8ED;
    display: flex;
    align-items: center;
}

.input-group-chat input {
    border: none;
    background: transparent;
    padding: 10px;
    box-shadow: none !important;
    flex: 1;
}

.send-btn {
    color: var(--orange);
    background: transparent;
    border: none;
    font-size: 20px;
}

/* Lead Capture Overlay */
#leadCaptureOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 0 !important; /* No rounded corners for full-screen overlay */
}

.capture-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: visible !important; /* Crucial for DDI dropdown */
}

/* Modal Product Details Styling */
#mProdTitles h1,
#mProdDesc h1 {
    font-size: 1.5rem;
    margin-top: 15px;
    font-weight: bold;
    color: var(--orange);
}

#mProdTitles h2,
#mProdDesc h2 {
    font-size: 1.3rem;
    margin-top: 12px;
    font-weight: bold;
}

#mProdTitles h3,
#mProdDesc h3 {
    font-size: 1.1rem;
    margin-top: 10px;
    font-weight: bold;
}

#mProdDesc ul,
#mProdDesc ol {
    padding-left: 20px;
    margin-bottom: 15px;
}

#mProdDesc p {
    margin-bottom: 10px;
    line-height: 1.5;
}

#mProdDesc table {
    width: 100% !important;
    border-collapse: collapse;
    margin-bottom: 15px;
}

#mProdDesc td,
#mProdDesc th {
    border: 1px solid #dee2e6;
    padding: 8px;
    font-size: 0.9rem;
}

#mProdDesc img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
}

.capture-card h4 {
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 20px;
}

/* --- INT-TEL-INPUT OVERRIDES --- */
.iti {
    width: 100%;
    text-align: left;
    position: relative !important;
    overflow: visible !important;
    display: block !important;
}

/* Fix for overlapping text and flags */
.iti--separate-dial-code .iti__selected-flag {
    background-color: transparent !important;
    border-top-left-radius: 30px;
    border-bottom-left-radius: 30px;
    padding-left: 15px;
}

#leadWhatsapp {
    padding-left: 100px !important; /* Adjust based on flag + code width */
    height: 48px; /* Standardize height */
    background-color: #f8f9fa !important;
}

/* Ensure dropdown is anchored below and NEVER behind chat */
.iti__country-list {
    z-index: 10000000 !important; /* Extremely high to ensure top layer */
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: auto !important;
    min-width: 280px !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    background-color: #fff !important;
    border: 1px solid #ccc !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2) !important;
    margin-top: 5px !important;
}

.btn-orange {
    background-color: var(--orange);
    color: white;
}

.btn-orange:hover {
    background-color: #e65000;
    color: white;
}

/* Typing Indicator dots */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 5px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #FF5900;
    /* Use theme orange for better visibility */
    border-radius: 50%;
    animation: bounce 0.6s infinite alternate;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    to {
        transform: translateY(-4px);
        opacity: 0.4;
    }
}

/* Carousel & Cards */
.chat-carousel-wrapper {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding: 5px 20px 15px 20px;
    /* Padding inside scroll to align with text */
    margin: 10px -20px;
    /* Break message padding to look full-width */
    width: calc(100% + 90px);
    scrollbar-width: thin;
    scrollbar-color: var(--orange) #f0f0f0;
    -webkit-overflow-scrolling: touch;
}

.chat-carousel-wrapper::-webkit-scrollbar {
    height: 4px;
}

.chat-carousel-wrapper::-webkit-scrollbar-thumb {
    background: var(--orange);
    border-radius: 10px;
}

.chat-card-produto {
    flex: 0 0 240px;
    /* Wider cards */
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
    transition: transform 0.2s;
    margin-bottom: 5px;
}

.chat-card-produto:hover {
    transform: translateY(-3px);
}

.chat-card-produto .card-img {
    height: 150px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #fff;
    border-bottom: 1px solid #f5f5f5;
    padding: 10px;
}

.chat-card-produto .card-body {
    padding: 12px;
}

.chat-card-produto .card-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #222;
    margin-bottom: 8px;
    height: 38px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.chat-card-produto .card-prices {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-card-produto .price-usd {
    color: #2e7d32;
    font-weight: 800;
    font-size: 15px;
    display: block;
}

.chat-card-produto .price-brl,
.chat-card-produto .price-pyg {
    font-size: 11.5px;
    color: #777;
    display: block;
    white-space: nowrap;
}

.chat-texto-ia {
    font-size: 14.5px;
    line-height: 1.5;
    color: #444;
}

/* WhatsApp Card [CARD_WHATSAPP] */
.chat-whatsapp-card {
    background: #e7ffdb;
    border: 1px solid #d0f0bb;
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.lang-selector {
    display: flex;
    align-items: center;
}

.lang-selector .lang-link img {
    width: 28px; /* Enlarged from 20px */
    height: auto;
    border-radius: 4px; /* Slightly rounder edges */
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.lang-selector .lang-link:hover img {
    opacity: 1;
    transform: scale(1.1);
}

.whatsapp-cta-btn {
    background: #25d366;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
    word-break: break-word; /* Prevents long text from breaking layout */
    white-space: normal;
    height: auto;
    min-height: 50px;
}

.whatsapp-cta-btn:hover {
    background: #128c7e;
    color: white;
    transform: scale(1.05);
}

/* Product Detail Modal */
#productModal .modal-content {
    border-radius: 20px;
    border: none;
    overflow: hidden;
}

#productModal .modal-header {
    border-bottom: 1px solid #f0f0f0;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

#productModal .btn-close {
    margin: 0;
    padding: 0.5rem;
    font-size: 0.8rem;
}

#productModal .modal-title {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
}

#productModal .modal-body {
    padding: 0 20px 20px 20px;
}

.modal-product-img {
    width: 100%;
    height: 250px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #f9f9f9;
    border-radius: 15px;
    margin-bottom: 20px;
}

.modal-price-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.modal-price-usd {
    font-size: 24px;
    font-weight: 800;
    color: #2e7d32;
}

.modal-desc {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
}

.btn-checkout {
    background: var(--orange);
    color: white;
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    margin-top: 20px;
    border: none;
}

.btn-checkout:hover {
    background: #e65000;
    color: white;
}
/* Assistance Card [CARD_ASSISTENCIA] */
.chat-assistencia-card {
    background: #fdfdfd;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    margin: 10px 0;
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
}

.assistencia-header {
    background: #334155;
    color: white;
    padding: 10px 15px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.assistencia-body {
    padding: 15px;
}

.assistencia-body p {
    font-size: 13.5px;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 12px;
}

.assistencia-btn {
    background: #0ea5e9;
    color: white !important;
    display: block;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: background 0.2s;
    word-break: break-word;
    white-space: normal;
    height: auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistencia-btn:hover {
    background: #0284c7;
}

/* Premium WhatsApp Card Themes */
.wa-standard .assistencia-header {
    background: #25D366; /* WhatsApp Green */
}

.wa-reserva .assistencia-header {
    background: #FF5900; /* HB Orange */
}

.wa-human .assistencia-header {
    background: #1e293b; /* Formal Deep Blue/Slate */
}

.btn-whatsapp {
    background: #25D366 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-whatsapp:hover {
    background: #128c7e !important;
}

.btn-reserva {
    background: #FF5900 !important;
}

.btn-reserva:hover {
    background: #e65000 !important;
}

.btn-human {
    background: #334155 !important;
}

.btn-human:hover {
    background: #1e293b !important;
}

/* Location Card Themes */
.map-header {
    background: #4285F4 !important; /* Maps Blue */
}

.btn-waze {
    background: #33ccff !important; /* Waze Blue */
    color: white !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-waze:hover {
    background: #00bfff !important;
}

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

/* Wholesale Card [CARD_ATACADO] */
.chat-wholesale-card {
    background: #fff;
    border: 1px solid #e0e6ed;
    border-radius: 12px;
    margin: 10px 0;
    overflow: hidden;
    animation: fadeIn 0.4s ease-out;
}

.wholesale-header {
    background: #FF5900;
    color: white;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 700;
}

.wholesale-body {
    padding: 15px;
}

.w-input {
    width: 100%;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}

.w-input:focus {
    border-color: #FF5900;
}

.w-submit-btn {
    width: 100%;
    background: #121212;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.w-submit-btn:hover {
    opacity: 0.9;
}

/* Product Card Status Badge */
.card-img {
    position: relative;
}

.product-status-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.badge-disponivel {
    background: #22c55e; /* Green */
}

.badge-reserva {
    background: #f97316; /* Orange */
}

/* Suggestion Buttons */
.suggestion-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 20px;
    padding: 0 10px;
    justify-content: flex-end;
    width: 100%;
}

.suggestion-btn {
    background: white;
    border: 1px solid var(--orange);
    color: var(--orange) !important;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    display: inline-block;
    max-width: 90%;
    margin-bottom: 2px;
}

.suggestion-btn:hover {
    background: var(--orange);
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 89, 0, 0.2);
}
