/* Widget da Isa */
.isa-widget {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Estado colapsado - Card com input */
.isa-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-card.hidden {
    display: none;
}

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

.isa-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);
}

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

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

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

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

.isa-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-card-close:hover {
    background: #eee;
    color: #666;
}

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

.isa-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-card-input-wrapper:focus-within {
    border-color: #C41E3A;
    background: white;
    box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.08);
}

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

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

.isa-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-card-send:hover {
    background: #a8182f;
    transform: scale(1.05);
}

.isa-card-send:active {
    transform: scale(0.98);
}

/* Avatar minimizado */
.isa-mini {
    display: none;
    cursor: pointer;
}

.isa-mini.visible {
    display: block;
}

.isa-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-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.isa-mini-avatar:hover {
    transform: scale(1.08);
}

.isa-mini-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #FFD700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #333;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Estado expandido */
.isa-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-expanded.visible {
    display: flex;
}

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

@media (max-width: 480px) {
    .isa-widget {
        bottom: 0;
        right: 0;
        left: 0;
    }

    .isa-card {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: calc(100% - 40px);
        max-width: 300px;
    }

    .isa-mini {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }

    .isa-expanded {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        min-height: 0;
    }

    .isa-expanded.visible {
        display: flex;
        flex-direction: column;
    }

    .isa-header {
        flex-shrink: 0;
    }

    .isa-input-area {
        flex-shrink: 0;
    }

    .isa-messages {
        flex: 1 1 0;
        height: 0;
        min-height: 0;
        max-height: none;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior-y: contain;
    }
}

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

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

.isa-header-info {
    flex: 1;
}

.isa-header-name {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.isa-header-status {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.isa-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #4ADE80;
    border-radius: 50%;
}

.isa-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-header-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.isa-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;
    touch-action: pan-y pinch-zoom;
}

.isa-message {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: messageIn 0.3s ease-out;
}

.isa-message.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.isa-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-message.user .isa-message-avatar {
    background: #E8E8E8;
    border: none;
}

.isa-message-content {
    background: white;
    padding: 14px 18px;
    border-radius: 6px 20px 20px 20px;
    font-size: 14px;
    line-height: 1.55;
    min-height: 0;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.isa-message.user .isa-message-content {
    background: #C41E3A;
    color: white;
    border-radius: 20px 6px 20px 20px;
}

.isa-input-area {
    padding: 16px 20px 20px;
    background: white;
    border-top: 1px solid #f0f0f0;
}

.isa-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-input-wrapper:focus-within {
    border-color: #C41E3A;
    background: white;
    box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.08);
}

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

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

.isa-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-send-btn:hover {
    background: #a8182f;
    transform: scale(1.05);
}

.isa-card-send:disabled,
.isa-send-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.isa-card-input:disabled,
.isa-input:disabled {
    opacity: 0.85;
    cursor: not-allowed;
}

/* ========== 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);
    }
}

/* Typing indicator */
.isa-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.isa-typing span {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Botões de ação (mic, camera) */
.isa-action-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}

.isa-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-action-btn:hover {
    background: #F0F0F0;
    color: #C41E3A;
}

.isa-action-btn.recording {
    background: #FFE4E4;
    color: #C41E3A;
    animation: recordingPulse 1.5s infinite;
    position: relative;
}

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

@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 blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.isa-action-btn svg {
    width: 20px;
    height: 20px;
}

/* Preview de imagem */
.isa-image-preview {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100px;
    background: #ffffff;
    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-image-preview.active {
    display: flex;
}

.isa-image-preview .clip-icon {
    background: #F0F0F0;
    width: 100%;
    padding: 4px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #888;
}

.isa-image-preview .clip-icon svg {
    width: 14px;
    height: 14px;
}

.isa-image-preview img {
    width: 100%;
    height: 70px;
    object-fit: cover;
}

.isa-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-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;
    transition: opacity 0.2s;
}

.isa-image-preview:hover .remove-image {
    opacity: 1;
}

.isa-image-preview .remove-image:hover {
    background: #C41E3A;
}

.isa-image-preview .remove-image svg {
    width: 10px;
    height: 10px;
}

/* Preview de Áudio */
.isa-recording-preview {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    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;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.isa-recording-preview.active {
    display: flex;
}

.isa-recording-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #C41E3A;
    font-weight: 600;
    font-size: 12px;
}

.isa-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-cancel:hover {
    background: #f0f0f0;
    border-color: #d0d0d0;
}

.isa-btn-audio-send {
    background: #C41E3A;
    color: white;
}

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

/* Input file hidden */
.isa-hidden-input {
    display: none;
}

/* Imagem na mensagem */
.isa-message-image {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 200px;
    border-radius: 10px;
    margin-bottom: 6px;
    display: block;
    object-fit: contain;
}
