/* =============================================
   SGV CHAT WIDGET - ISOLATED EMBED STYLES
   All classes prefixed with "sgv-chat-" to avoid conflicts
   ============================================= */

/* Reset and Container Isolation */
.sgv-chat-widget,
.sgv-chat-widget *,
.sgv-chat-widget *::before,
.sgv-chat-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.sgv-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* CSS Variables for theming */
.sgv-chat-widget {
    --sgv-primary: #005E54;
    --sgv-primary-hover: #007A6E;
    --sgv-bg-chat: #E5DDD5;
    --sgv-bg-input: #F0F0F0;
    --sgv-user-bubble: #DCF8C6;
    --sgv-bot-bubble: #FFFFFF;
    --sgv-text-dark: #303030;
    --sgv-text-gray: #8A9A9E;
    --sgv-shadow: rgba(0, 0, 0, 0.1);
}

/* =============================================
   DOCK CONTAINER STYLES
   ============================================= */
.sgv-chat-dock-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    z-index: 999999;
    display: flex;
    justify-content: flex-end;
}

.sgv-chat-dock {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: auto;
    padding-bottom: 10px;
    width: auto;
    background-color: transparent;
}

.sgv-chat-dock-item {
    position: relative;
    cursor: pointer;
    margin: 0;
    margin-left: -25px;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sgv-chat-dock-item:first-child {
    margin-left: 0;
}

.sgv-chat-dock-item.sgv-chat-contracting {
    transform: scale(0);
    opacity: 0;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    pointer-events: none;
}

.sgv-chat-dock-item.sgv-chat-selected {
    z-index: 10;
    cursor: pointer;
    margin-left: 0 !important;
    margin-right: 15px !important;
}

.sgv-chat-dock-item img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 4px 6px var(--sgv-shadow);
    display: block;
    transition: all 0.3s ease;
}

.sgv-chat-info-popup {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sgv-chat-info-popup strong {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.sgv-chat-dock-item:hover .sgv-chat-info-popup {
    opacity: 1;
    visibility: visible;
}

.sgv-chat-dock-item:first-child .sgv-chat-info-popup {
    left: 0;
    transform: translateX(0);
}

.sgv-chat-dock-item:last-child .sgv-chat-info-popup,
.sgv-chat-dock-item.sgv-chat-selected .sgv-chat-info-popup {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.sgv-chat-dock-container-open .sgv-chat-dock-item.sgv-chat-selected .sgv-chat-info-popup {
    display: none !important;
}

/* =============================================
   CHAT CONTAINER STYLES
   ============================================= */
.sgv-chat-container {
    position: fixed;
    bottom: 100px;
    right: 16px;
    width: 384px;
    height: 600px;
    max-height: 80vh;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    z-index: 99999998;
    display: flex;
    flex-direction: column;
}

.sgv-chat-container.sgv-chat-hidden {
    display: none !important;
}

/* Header */
.sgv-chat-header {
    background-color: var(--sgv-primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px var(--sgv-shadow);
}

.sgv-chat-header-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.sgv-chat-header img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    border: 2px solid white;
}

.sgv-chat-header-info {
    min-width: 0;
}

.sgv-chat-header-name {
	color: white;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.sgv-chat-header-desc {
    font-size: 12px;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.sgv-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sgv-chat-header-btn {
    background: transparent;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.sgv-chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Area */
.sgv-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: var(--sgv-bg-chat);
    background-image: url('../images/fundo-chat.jpg');
    background-repeat: round;
}

/* Message Bubbles */
.sgv-chat-message {
    display: flex;
    margin-bottom: 16px;
    animation: sgv-chat-fadeIn 0.5s ease-in-out;
}

.sgv-chat-message-user {
    justify-content: flex-end;
}

.sgv-chat-message-bot {
    justify-content: flex-start;
}

.sgv-chat-bubble {
    padding: 6px 10px;
    border-radius: 7.5px;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
    line-height: 1.4;
    position: relative;
    font-size: 1.15rem;
}

.sgv-chat-bubble-user {
    background-color: var(--sgv-user-bubble);
    color: var(--sgv-text-dark);
    margin-right: 8px;
    border-radius: 7.5px 0 7.5px 7.5px;
}

.sgv-chat-bubble-user::after {
    content: '';
    position: absolute;
    top: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 10px 10px;
    border-color: transparent transparent transparent var(--sgv-user-bubble);
}

.sgv-chat-bubble-bot {
    background-color: var(--sgv-bot-bubble);
    color: var(--sgv-text-dark);
    margin-left: 8px;
    border-radius: 0 7.5px 7.5px 7.5px;
}

.sgv-chat-bubble-bot::after {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 10px 10px 0;
    border-color: transparent var(--sgv-bot-bubble) transparent transparent;
}

.sgv-chat-bubble img {
    border-radius: 5px;
    display: block;
    width: 100%;
    max-width: 250px;
}

.sgv-chat-timestamp {
    font-size: 11px;
    color: var(--sgv-text-gray);
    margin-top: 4px;
    display: block;
    opacity: 0;
    transition: opacity 0.2s;
}

.sgv-chat-message:hover .sgv-chat-timestamp {
    opacity: 1;
}

.sgv-chat-message-user .sgv-chat-timestamp {
    text-align: right;
    margin-right: 10px;
}

.sgv-chat-message-bot .sgv-chat-timestamp {
    margin-left: 10px;
}

/* Typing Indicator */
.sgv-chat-typing {
    padding: 8px 24px;
    background: var(--sgv-bg-input);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sgv-chat-typing.sgv-chat-hidden {
    display: none;
}

.sgv-chat-typing-dots {
    display: flex;
    gap: 4px;
}

.sgv-chat-typing-dots span {
    width: 8px;
    height: 8px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: sgv-chat-bounce 1.4s infinite ease-in-out;
}

.sgv-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.sgv-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.sgv-chat-typing-text {
    font-size: 14px;
    color: #6b7280;
}

/* Input Area */
.sgv-chat-input-area {
    padding: 8px 12px;
    background: var(--sgv-bg-input);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sgv-chat-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    border-radius: 25px;
    overflow: hidden;
    background: white;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px var(--sgv-shadow);
}

.sgv-chat-input-wrapper label {
    cursor: pointer;
    padding: 0 8px 0 12px;
    color: #6b7280;
}

.sgv-chat-input-wrapper input[type="file"] {
    display: none;
}

.sgv-chat-input-wrapper input[type="text"] {
    flex: 1;
    padding: 8px 4px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    min-width: 0;
}

.sgv-chat-input-wrapper button {
    background: transparent;
    border: none;
    padding: 0 12px 0 8px;
    color: #6b7280;
    cursor: pointer;
}

.sgv-chat-send-btn {
    background-color: var(--sgv-primary) !important;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 6px var(--sgv-shadow);
    transition: background 0.3s;
}

.sgv-chat-send-btn:hover {
    background-color: var(--sgv-primary-hover) !important;
}

.sgv-chat-send-btn i,
.sgv-chat-send-btn svg {
    color: white;
    font-size: 14px;
}

/* =============================================
   CALL OVERLAYS
   ============================================= */
.sgv-chat-calling-overlay,
.sgv-chat-call-interface {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(4px);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sgv-chat-calling-overlay.sgv-chat-hidden,
.sgv-chat-call-interface.sgv-chat-hidden {
    display: none;
}

.sgv-chat-calling-content {
    text-align: center;
    color: white;
    margin-bottom: 64px;
}

.sgv-chat-calling-content img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    margin: 0 auto 24px;
    border: 4px solid white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.sgv-chat-calling-content h2 {
    font-size: 30px;
    font-weight: 700;
    margin: 0 0 8px;
}

.sgv-chat-calling-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.sgv-chat-calling-dots span {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: sgv-chat-calling-pulse 1.4s infinite ease-in-out;
}

.sgv-chat-calling-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.sgv-chat-calling-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.sgv-chat-calling-content p {
    font-size: 20px;
    margin-top: 16px;
}

.sgv-chat-end-call-btn {
    background-color: #dc2626;
    color: white;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

.sgv-chat-end-call-btn:hover {
    background-color: #b91c1c;
    transform: scale(1.05);
}

/* Call Interface */
.sgv-chat-call-interface {
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
}

.sgv-chat-call-header {
    text-align: center;
    color: white;
    padding: 40px 24px 24px;
}

.sgv-chat-call-header img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    margin: 0 auto 16px;
    border: 4px solid white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.sgv-chat-call-header h2 {
    font-size: 30px;
    font-weight: 700;
    margin: 0;
}

.sgv-chat-call-status {
    color: #4ade80;
    font-size: 18px;
    font-weight: 500;
    margin: 4px 0;
}

.sgv-chat-call-timer {
    font-size: 18px;
    color: #d1d5db;
    margin: 0;
}

.sgv-chat-call-transcript {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sgv-chat-call-actions {
    padding: 24px;
    display: flex;
    justify-content: center;
}

/* =============================================
   RATING MODAL
   ============================================= */
.sgv-chat-rating-overlay,
.sgv-chat-thankyou-overlay {
    position: fixed;
    inset: 0;
    backdrop-filter: blur(4px);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.sgv-chat-rating-overlay.sgv-chat-hidden,
.sgv-chat-thankyou-overlay.sgv-chat-hidden {
    display: none;
}

.sgv-chat-rating-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 384px;
    padding: 24px;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.3s;
}

.sgv-chat-rating-modal.sgv-chat-show {
    transform: scale(1);
    opacity: 1;
}

.sgv-chat-rating-header {
    text-align: center;
    margin-bottom: 24px;
}

.sgv-chat-rating-icon {
    width: 64px;
    height: 64px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.sgv-chat-rating-icon i {
    color: #16a34a;
    font-size: 24px;
}

.sgv-chat-rating-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px;
}

.sgv-chat-rating-header p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

.sgv-chat-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.sgv-chat-star-btn {
    background: transparent;
    border: none;
    font-size: 30px;
    color: #d1d5db;
    cursor: pointer;
    transition: transform 0.15s, color 0.15s;
}

.sgv-chat-star-btn:hover {
    transform: scale(1.15);
    color: #fbbf24;
}

.sgv-chat-star-btn.sgv-chat-selected {
    color: #fbbf24;
}

.sgv-chat-rating-comment {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    resize: none;
    margin-bottom: 16px;
    font-family: inherit;
}

.sgv-chat-rating-comment:focus {
    outline: none;
    border-color: var(--sgv-primary);
    box-shadow: 0 0 0 2px rgba(0, 94, 84, 0.2);
}

.sgv-chat-rating-actions {
    display: flex;
    gap: 12px;
}

.sgv-chat-rating-skip,
.sgv-chat-rating-submit {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
}

.sgv-chat-rating-skip {
    background: transparent;
    color: #6b7280;
}

.sgv-chat-rating-skip:hover {
    background: #f3f4f6;
}

.sgv-chat-rating-submit {
    background: var(--sgv-primary);
    color: white;
}

.sgv-chat-rating-submit:hover {
    background: var(--sgv-primary-hover);
}

.sgv-chat-rating-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Thank You Modal */
.sgv-chat-thankyou-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 384px;
    padding: 32px;
    text-align: center;
    animation: sgv-chat-bounceIn 0.4s ease;
}

.sgv-chat-thankyou-icon {
    width: 80px;
    height: 80px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.sgv-chat-thankyou-icon i {
    color: #16a34a;
    font-size: 30px;
}

.sgv-chat-thankyou-modal h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px;
}

.sgv-chat-thankyou-modal p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes sgv-chat-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sgv-chat-bounce {
    0%, 80%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.3);
        opacity: 1;
    }
}

@keyframes sgv-chat-calling-pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes sgv-chat-bounceIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Recording pulse */
.sgv-chat-recording-pulse {
    animation: sgv-chat-pulse 1.5s infinite;
}

@keyframes sgv-chat-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* =============================================
   RESPONSIVE STYLES
   ============================================= */
@media (max-width: 500px) {
    .sgv-chat-dock-container {
        width: 95vw;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        right: auto;
    }

    .sgv-chat-dock {
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .sgv-chat-dock::-webkit-scrollbar {
        display: none;
    }

    .sgv-chat-container {
        width: calc(100vw - 16px);
        right: 8px;
        left: 8px;
        bottom: 80px;
        height: 80vh;
    }

    .sgv-chat-bubble {
        max-width: 85%;
    }
}

/* Utility class for text color */
.sgv-chat-text-red {
    color: #ef4444 !important;
}
