/* Widget de chat da ISA na ficha de empresa (hotsite). Extraído de
   components/isa-hotsite-chat-widget.blade.php (<style> @once, 8-523).
   Prefixado .isa-company- pra não conflitar. Estático, sem Blade. */

        /* =========================================
           ESTILOS - Baseado na versão GERAL (Refinado)
           Prefixado com .isa-company- para não conflitar
           ========================================= */
        
        .isa-company-widget {
            position: fixed !important;
            bottom: 20px !important;
            right: 20px !important;
            z-index: 9999;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

        /* --- CARD FECHADO --- */
        .isa-company-card {
            background: white;
            border-radius: 20px;
            box-shadow: 0 6px 30px rgba(0, 0, 0, 0.12);
            overflow: hidden;
            width: 300px;
            animation: cardIn 0.4s ease-out;
        }

        .isa-company-card.hidden { display: none; }

        .isa-company-card-header {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 16px 16px 12px;
        }

        .isa-company-card-avatar {
            width: 44px;
            height: 44px;
            border-radius: 50%;
            background: #C41E3A;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            box-shadow: 0 3px 10px rgba(196, 30, 58, 0.25);
            overflow: hidden;
        }

        .isa-company-card-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .isa-company-card-info { flex: 1; min-width: 0; }

        .isa-company-card-greeting {
            font-size: 15px;
            font-weight: 600;
            color: #1a1a1a;
            margin-bottom: 2px;
        }

        .isa-company-card-context {
            font-size: 13px;
            color: #666;
            white-space: normal;
            line-height: 1.25;
        }

        .isa-company-card-close {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            border: none;
            background: #f5f5f5;
            color: #999;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            flex-shrink: 0;
        }

        .isa-company-card-close:hover { background: #eee; color: #666; }

        .isa-company-card-input-area { padding: 0 16px 16px; }

        .isa-company-card-input-wrapper {
            display: flex;
            align-items: center;
            gap: 8px;
            background: #f8f8f8;
            border: 2px solid #f0f0f0;
            border-radius: 14px;
            padding: 6px 6px 6px 16px;
            transition: all 0.2s;
        }

        .isa-company-card-input-wrapper:focus-within {
            border-color: #C41E3A;
            background: white;
            box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.08);
        }

        .isa-company-card-input {
            flex: 1;
            border: none;
            background: none;
            font-size: 14px;
            outline: none;
            color: #333;
            min-width: 0;
        }

        .isa-company-card-input::placeholder { color: #aaa; }

        .isa-company-card-send {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            border: none;
            background: #C41E3A;
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            flex-shrink: 0;
        }

        .isa-company-card-send:hover { background: #a8182f; transform: scale(1.05); }

        /* --- AVATAR MINI --- */
        .isa-company-mini { display: none; cursor: pointer; }
        .isa-company-mini.visible { display: block; }

        .isa-company-mini-avatar {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: #fff;
            border: 2px solid #C41E3A;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 20px rgba(196, 30, 58, 0.35);
            transition: transform 0.2s;
            position: relative;
            overflow: hidden;
        }
        
        .isa-company-mini-avatar:hover { transform: scale(1.08); }

        /* --- EXPANDIDO (CHAT COMPLETO) --- */
        .isa-company-expanded {
            display: none;
            flex-direction: column;
            background: white;
            border-radius: 20px;
            box-shadow: 0 10px 50px rgba(0, 0, 0, 0.18);
            overflow: hidden;
            animation: expandIn 0.35s ease-out;
            min-height: 0;
        }

        .isa-company-expanded.visible { display: flex; }

        @media (min-width: 481px) {
            .isa-company-expanded {
                width: 380px;
                height: 540px;
                max-height: calc(100vh - 100px);
            }
        }

        @media (max-width: 480px) {
            .isa-company-widget { bottom: 0; right: 0; left: 0; }
            .isa-company-card {
                position: fixed; bottom: 20px; right: 20px;
                width: calc(100% - 40px); max-width: 300px;
            }
            .isa-company-mini { position: fixed; bottom: 20px; right: 20px; }
            .isa-company-expanded {
                position: fixed; top: 0; left: 0; right: 0; bottom: 0;
                width: 100vw; height: 100vh; height: 100dvh;
                border-radius: 0; min-height: 0;
            }
        }

        /* Header */
        .isa-company-header {
            background: linear-gradient(135deg, #C41E3A 0%, #a8182f 100%);
            padding: 18px 20px;
            display: flex;
            align-items: center;
            gap: 14px;
        }

        .isa-company-header-avatar {
            width: 46px; height: 46px; border-radius: 50%;
            background: white; overflow: hidden;
            display: flex; align-items: center; justify-content: center;
            box-shadow: 0 3px 10px rgba(0,0,0,0.1);
        }

        .isa-company-header-info { flex: 1; }
        .isa-company-header-name { color: white; font-weight: 600; font-size: 16px; }
        .isa-company-header-status { color: rgba(255,255,255,0.85); font-size: 12px; display: flex; align-items: center; gap: 5px; }
        .isa-company-header-status::before { content: ''; width: 7px; height: 7px; background: #4ADE80; border-radius: 50%; }

        .isa-company-header-close {
            background: rgba(255,255,255,0.15); border: none; color: white;
            cursor: pointer; padding: 10px; margin: -10px; border-radius: 12px;
            transition: background 0.2s;
        }
        .isa-company-header-close:hover { background: rgba(255,255,255,0.25); }

        /* Mensagens */
        .isa-company-messages {
            flex: 1; padding: 20px;
            overflow-y: auto; overflow-x: hidden;
            background: linear-gradient(180deg, #FFFAFA 0%, #FFF5F5 100%);
            display: flex; flex-direction: column; gap: 16px;
            min-height: 0;
            -webkit-overflow-scrolling: touch;
            overscroll-behavior: contain;
        }

        .isa-company-message { display: flex; gap: 10px; max-width: 88%; animation: messageIn 0.3s ease-out; }
        .isa-company-message.user { flex-direction: row-reverse; align-self: flex-end; }
        
        .isa-company-message-avatar {
            width: 32px; height: 32px; border-radius: 50%;
            background: #fff; border: 2px solid #C41E3A; flex-shrink: 0;
            display: flex; align-items: center; justify-content: center; overflow: hidden;
        }
        
        .isa-company-message.user .isa-company-message-avatar { background: #E8E8E8; border: none; }
        
        .isa-company-message-content {
            background: white; padding: 14px 18px;
            border-radius: 6px 20px 20px 20px; font-size: 14px;
            line-height: 1.55; color: #333; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        }
        
        .isa-company-message.user .isa-company-message-content {
            background: #C41E3A; color: white; border-radius: 20px 6px 20px 20px;
        }

        /* Área de Input e Previews */
        .isa-company-input-area { padding: 16px 20px 20px; background: white; border-top: 1px solid #f0f0f0; }

        .isa-company-input-wrapper {
            display: flex; gap: 12px; align-items: center;
            background: #f8f8f8; border: 2px solid transparent;
            border-radius: 18px; padding: 8px 8px 8px 20px; transition: all 0.2s;
        }

        .isa-company-input-wrapper:focus-within {
            border-color: #C41E3A; background: white; box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.08);
        }

        .isa-company-input { 
            flex: 1; border: none; background: none; font-size: 14px; outline: none; color: #333; 
            min-width: 0;
        }
        .isa-company-input::placeholder { color: #aaa; }

        .isa-company-send-btn {
            width: 44px; height: 44px; border-radius: 14px;
            background: #C41E3A; border: none; cursor: pointer;
            display: flex; align-items: center; justify-content: center; transition: all 0.2s;
            flex-shrink: 0;
        }

        .isa-company-send-btn:hover { background: #a8182f; transform: scale(1.05); }
        .isa-company-send-btn:disabled { opacity: 0.65; cursor: not-allowed; }

        /* Botões de Ação (Mic/Img) */
        .isa-company-action-buttons { display: flex; gap: 4px; align-items: center; }

        .isa-company-action-btn {
            background: transparent; border: none; color: #888;
            width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
            display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0;
        }

        .isa-company-action-btn:hover { background: #F0F0F0; color: #C41E3A; }

        .isa-company-action-btn.recording {
            background: #FFE4E4; color: #C41E3A; animation: recordingPulse 1.5s infinite; position: relative;
        }
        
        .isa-company-action-btn.recording::after {
            content: '●'; position: absolute; top: 2px; right: 2px;
            color: #C41E3A; font-size: 8px; animation: blink 1s infinite;
        }

        /* Previews */
        .isa-company-image-preview {
            display: none; flex-direction: column; align-items: center; width: 100px;
            background: #fff; border-radius: 10px; border: 1px solid #E5E5E5;
            overflow: hidden; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); position: relative;
        }
        .isa-company-image-preview.active { display: flex; }
        .isa-company-image-preview img { width: 100%; height: 70px; object-fit: cover; }
        .isa-company-image-preview .preview-filename {
            font-size: 10px; color: #666; padding: 6px; text-align: center; width: 100%;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #FAFAFA;
        }
        .isa-company-image-preview .remove-image {
            position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.5);
            border: none; color: white; cursor: pointer; padding: 2px; border-radius: 50%;
            width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; opacity: 0;
        }
        .isa-company-image-preview:hover .remove-image { opacity: 1; }

        .isa-company-recording-preview {
            display: none; align-items: center; justify-content: space-between;
            background: #fff; border-radius: 10px; border: 1px solid #E5E5E5;
            padding: 8px 12px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
            animation: slideUp 0.3s ease;
        }
        .isa-company-recording-preview.active { display: flex; }
        
        .isa-company-recording-info { display: flex; align-items: center; gap: 8px; color: #C41E3A; font-weight: 600; font-size: 12px; }
        .isa-company-recording-actions { display: flex; gap: 6px; }

        .isa-btn-audio-action {
            padding: 5px 10px; border-radius: 100px; font-size: 11px; font-weight: 600;
            cursor: pointer; transition: all 0.2s; border: 1px solid transparent;
        }
        .isa-btn-audio-cancel { background: #F8F9FA; color: #666; border-color: #E5E5E5; }
        .isa-btn-audio-send { background: #C41E3A; color: white; }

        .isa-hidden-input { display: none; }
        .isa-message-image {
            max-width: 100%; width: auto; height: auto; max-height: 200px;
            border-radius: 10px; margin-bottom: 6px; display: block; object-fit: contain;
        }

        /* Animações */
        @keyframes cardIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
        @keyframes expandIn { from { opacity: 0; transform: translateY(30px) scale(0.92); } to { opacity: 1; transform: translateY(0) scale(1); } }
        @keyframes messageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }
        @keyframes recordingPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(196, 30, 58, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(196, 30, 58, 0); } }
        @keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

        /* Typing indicator */
        .isa-company-typing { display: flex; gap: 4px; padding: 8px 0; }
        .isa-company-typing span { width: 8px; height: 8px; background: #ccc; border-radius: 50%; animation: typing 1.4s infinite; }
        .isa-company-typing span:nth-child(2) { animation-delay: 0.2s; }
        .isa-company-typing span:nth-child(3) { animation-delay: 0.4s; }

        /* Offers cards - improved */
        .isa-offers-wrapper { 
            display: flex; 
            flex-direction: column; 
            gap: 12px; 
            width: 100%; 
            box-sizing: border-box;
            background: transparent;
        }

        .isa-company-message:has(.isa-offers-wrapper) .isa-company-message-content {
            background: transparent !important;
            box-shadow: none !important;
            padding: 0 !important;
            max-width: 100%;
            width: 100%;
        }

        .isa-offer-card { 
            display: flex; 
            gap: 12px; 
            align-items: stretch; 
            border-radius: 12px; 
            border: 1px solid #e2e8f0; 
            padding: 12px; 
            background: #fff; 
            box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
            width: 100%; 
            box-sizing: border-box;
            overflow: hidden; 
        }

        .isa-offer-card .offer-media { 
            flex: 0 0 90px; 
            display: flex;
            align-items: center;
        }

        .isa-offer-card img { 
            width: 100%; 
            height: 70px; 
            object-fit: cover; 
            display: block; 
            border-radius: 8px; 
        }

        .isa-offer-card .offer-body { 
            flex: 1 1 auto; 
            display: flex; 
            flex-direction: column; 
            min-width: 0; 
            justify-content: center;
        }

        .isa-offer-card .offer-title { 
            font-weight: 700; 
            font-size: 13px; 
            color: #111; 
            margin-bottom: 4px; 
            line-height: 1.3; 
            white-space: nowrap; 
            overflow: hidden; 
            text-overflow: ellipsis; 
        }

        .isa-offer-card .offer-desc { 
            font-size: 11px; 
            color: #666; 
            margin-bottom: 2px; 
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .isa-offer-card .offer-address { 
            font-size: 11px; 
            color: #4a5568; 
            margin-bottom: 6px; 
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .isa-offer-card .offer-footer { 
            display: flex; 
            flex-direction: column-reverse; 
            align-items: flex-start; 
            gap: 8px; 
            margin-top: 6px;
            width: 100%;
        }

        .isa-offer-card .offer-actions { 
            display: flex; 
            gap: 8px; 
            align-items: center; 
            width: 100%; 
        }

        .isa-offer-card .offer-actions a { 
            flex: 1; 
            text-align: center;
            padding: 8px 6px; 
            border-radius: 8px; 
            font-size: 11px; 
            font-weight: 600; 
            text-decoration: none; 
            cursor: pointer; 
            white-space: nowrap;
            color: #fff;
            overflow: hidden;
            text-overflow: ellipsis; 
        }

        .isa-offer-card .offer-actions .btn-link { background: #C41E3A; }
        .isa-offer-card .offer-actions .btn-wa { background: #25D366; }

        .isa-offer-card .offer-price { 
            font-weight: 900; 
            color: #C41E3A; 
            font-size: 15px; 
            line-height: 1;
            white-space: nowrap; 
        }

        @media (max-width: 480px) {
            .isa-company-widget { bottom: 0; right: 0; left: 0; }
            .isa-company-card {
                position: fixed; bottom: 20px; right: 20px;
                width: calc(100% - 40px); max-width: 300px;
            }
            .isa-company-mini { position: fixed; bottom: 20px; right: 20px; }
            .isa-company-expanded {
                position: fixed; top: 0; left: 0; right: 0; bottom: 0;
                width: 100vw; height: 100vh; height: 100dvh;
                border-radius: 0; min-height: 0;
            }
            .isa-company-message {
                max-width: 95%;
            }

            .isa-company-input-area { padding: 10px 12px 12px; }
            .isa-company-input-wrapper { padding: 4px 4px 4px 12px; gap: 6px; }
            .isa-company-action-buttons { gap: 2px; }
            .isa-company-action-btn { width: 32px; height: 32px; }
            .isa-company-send-btn { 
                width: 38px; height: 38px; 
                min-width: 38px;
                flex-shrink: 0; 
            }
            
            .isa-offer-card { padding: 10px; gap: 8px; }
            .isa-offer-card .offer-media { flex: 0 0 70px; }
            .isa-offer-card img { height: 60px; }
            .isa-offer-card .offer-actions a { font-size: 11px; padding: 7px 4px; }
            .isa-offer-card .offer-price { font-size: 14px; }
        }
