/* ========================================
   WA LEAD TRACKER - FRONTEND STYLES
   Version 1.6.0 - INTL Tel Input Fixed
   ======================================== */

/* ========== RESET AND VARIABLES ========== */
:root {
    --walt-primary: #25D366;
    --walt-primary-dark: #128C7E;
    --walt-bg-chat: #E5DDD5;
    --walt-bubble-received: #FFFFFF;
    --walt-bubble-sent: #DCF8C6;
    --walt-text-dark: #303030;
    --walt-text-light: #667781;
    --walt-border: #D1D7DB;
    --walt-shadow: rgba(0, 0, 0, 0.1);
}

/* ========== FLOATING BUTTON ========== */
#walt-floating-button {
    position: fixed;
    z-index: 999998;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    padding: 0;
    animation: waltSlideUp 0.5s ease 0.8s backwards;
}

#walt-floating-button svg {
    width: 60%;
    height: 60%;
    pointer-events: none;
}

#walt-floating-button:hover {
    transform: scale(1.1);
}

#walt-floating-button:active {
    transform: scale(0.95);
}

/* ========== BUTTON TOOLTIP ========== */
.walt-button-tooltip {
    position: absolute;
    right: calc(100% + 15px);
    top: 50%;
    transform: translateY(-50%);
    background: #303030;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.walt-button-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #303030;
}

#walt-floating-button:hover .walt-button-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Tooltip on the left if the button is on the left */
#walt-floating-button[style*="left"] .walt-button-tooltip {
    right: auto;
    left: calc(100% + 15px);
}

#walt-floating-button[style*="left"] .walt-button-tooltip::after {
    left: auto;
    right: 100%;
    border-left-color: transparent;
    border-right-color: #303030;
}

/* ========== ANIMATIONS ========== */
@keyframes waltSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes messageIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ========== MODAL OVERLAY ========== */
.walt-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    animation: fadeIn 0.3s ease;
}

.walt-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== CHAT STYLE MODAL ========== */
.walt-chat-modal {
    position: relative;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

/* ========== CLOSE BUTTON ========== */
.walt-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit !important;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0.8;
}

.walt-modal-close:hover,
.walt-modal-close:focus,
.walt-modal-close:active {
    opacity: 1;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    transform: none;
}

/* ========== CHAT STYLE HEADER ========== */
.walt-chat-header {
    background: var(--walt-primary);
    color: #fff;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.walt-chat-avatar {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.walt-chat-avatar img {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: cover;
    border: 3px solid #FFFFFF;
    display: block;
}

.walt-chat-status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #00E676;
    border: 2px solid var(--walt-primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.walt-chat-agent-info {
    flex: 1;
    min-width: 0;
}

.walt-chat-agent-name {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.walt-chat-agent-status {
    margin: 2px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

/* ========== CHAT BODY ========== */
.walt-chat-body {
    flex: 1;
    background: var(--walt-bg-chat);
    background-image:
        repeating-linear-gradient(45deg, transparent, transparent 35px,
        rgba(255, 255, 255, 0.05) 35px, rgba(255, 255, 255, 0.05) 70px);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========== MESSAGES ========== */
.walt-chat-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(10px);
    animation: messageIn 0.3s ease forwards;
}

.walt-chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--walt-bubble-received);
    box-shadow: 0 1px 2px var(--walt-shadow);
    color: var(--walt-text-dark);
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.walt-chat-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    border: 8px solid transparent;
    border-right-color: var(--walt-bubble-received);
    border-top-color: var(--walt-bubble-received);
}

.walt-chat-time {
    font-size: 11px;
    color: var(--walt-text-light);
    margin-top: 4px;
    padding-left: 10px;
}

/* ========== TYPING EFFECT ========== */
.walt-chat-typing {
    display: flex;
    align-items: center;
    opacity: 0;
    animation: messageIn 0.3s ease forwards;
    margin-bottom: 12px;
}

.walt-typing-dots {
    display: flex;
    gap: 4px;
    background: var(--walt-bubble-received);
    padding: 12px 18px;
    border-radius: 18px;
    box-shadow: 0 1px 2px var(--walt-shadow);
}

.walt-typing-dots span {
    width: 8px;
    height: 8px;
    background: #90949C;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.walt-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.walt-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ========== FORM ========== */
.walt-chat-form-wrapper {
    opacity: 0;
    animation: messageIn 0.3s ease forwards;
    overflow: visible;
}

.walt-chat-form {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--walt-shadow);
    overflow: visible;
}

.walt-form-group {
    position: relative;
    margin-bottom: 12px;
}

/* ========== STANDARD INPUTS (Name, etc) ========== */
.walt-form-input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--walt-border);
    border-radius: 8px;
    font-size: 15px;
    color: var(--walt-text-dark);
    transition: all 0.2s ease;
    background: #fff;
    box-sizing: border-box;
}

.walt-form-input:focus {
    outline: none;
    border-color: var(--walt-primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.walt-form-input::placeholder {
    color: var(--walt-text-light);
}

/* Old icon/label classes - hidden */
.walt-form-label,
.walt-form-icon {
    display: none;
}

/* ========== LGPD CHECKBOX ========== */
.walt-checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px 0;
    font-size: 13px;
    color: var(--walt-text-dark);
    line-height: 1.4;
}

.walt-checkbox-group input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

.walt-checkbox-group a {
    color: var(--walt-primary);
    text-decoration: none;
}

.walt-checkbox-group a:hover {
    text-decoration: underline;
}

/* ========== SUBMIT BUTTON (ISOLATED) ========== */
.walt-chat-form .walt-chat-submit-btn,
#walt-lead-form .walt-chat-submit-btn,
.walt-chat-submit-btn.walt-submit-btn {
    width: 100% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;

    min-height: 56px !important;
    padding: 14px 24px !important;
    box-sizing: border-box !important;

    border: none !important;
    border-radius: 8px !important;
    background-color: var(--walt-primary-dark) !important;
    color: #fff !important;

    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    text-align: center !important;
    text-transform: none !important;
    white-space: normal !important;

    cursor: pointer !important;
    transition: all 0.2s ease !important;

    margin-top: 4px !important;
}

/* remove any pseudo-element or icon injected by the theme */
.walt-chat-submit-btn::before,
.walt-chat-submit-btn::after {
    content: none !important;
}

/* internal plugin icon */
.walt-chat-submit-btn .walt-submit-icon {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    flex-shrink: 0 !important;
    fill: currentColor !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* internal text */
.walt-chat-submit-btn span {
    display: inline-block !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* hover/active/disabled states, ignoring the theme */
.walt-chat-submit-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3) !important;
    filter: brightness(0.95) !important;
}

.walt-chat-submit-btn:active {
    transform: translateY(0) !important;
    box-shadow: none !important;
}

.walt-chat-submit-btn:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* ========== FEEDBACK ========== */
.walt-feedback {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    display: none;
}

.walt-feedback.success {
    background: #D4EDDA;
    color: #155724;
    border: 1px solid #C3E6CB;
    display: block;
}

.walt-feedback.error {
    background: #F8D7DA;
    color: #721C24;
    border: 1px solid #F5C6CB;
    display: block;
}

/* ========== HIDDEN FIELDS ========== */
.walt-hidden-fields {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ========================================
   INTL TEL INPUT - VERSION 2.0 FIXED
   ======================================== */

/* ⭐ INTL main container */
.walt-form-group .iti {
    display: block !important;
    width: 100% !important;
    position: relative !important;
    margin: 0 !important;
}

/* ⭐ Phone input (WITH flag) */
.walt-form-group .iti .iti__tel-input,
.walt-form-group .iti input[type="tel"],
.walt-form-group input#walt-phone {
    width: 100% !important;
    padding: 14px 16px 14px 62px !important;
    border: 1.5px solid var(--walt-border) !important;
    border-radius: 8px !important;
    font-size: 15px !important;
    color: var(--walt-text-dark) !important;
    background: #fff !important;
    box-sizing: border-box !important;
    height: 48px !important;
    line-height: 1.5 !important;
    margin: 0 !important;
    transition: all 0.2s ease !important;
}

/* Focus state */
.walt-form-group input#walt-phone:focus,
.walt-form-group .iti__tel-input:focus {
    outline: none !important;
    border-color: var(--walt-primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1) !important;
}

/* Placeholder */
.walt-form-group input#walt-phone::placeholder,
.walt-form-group .iti__tel-input::placeholder {
    color: var(--walt-text-light) !important;
}

/* Error state */
.walt-form-group input#walt-phone.walt-error,
.walt-form-group .iti__tel-input.walt-error {
    border-color: #dc3545 !important;
}

/* ⭐ Flag and code container */
.walt-form-group .iti__flag-container {
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 56px !important;
    padding: 0 !important;
}

/* ⭐ Selector button (flag + arrow) */
.walt-form-group .iti__selected-flag {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 8px !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    outline: none !important;
}

.walt-form-group .iti__selected-flag:hover {
    background: rgba(0, 0, 0, 0.03) !important;
}

/* ⭐ Flag (sprite) */
.walt-form-group .iti__flag {
    width: 20px !important;
    height: 15px !important;
    box-shadow: none !important;
    margin-right: 0 !important;
}

/* ⭐ Dropdown arrow */
.walt-form-group .iti__arrow {
    margin-left: 6px !important;
    border-left: 3px solid transparent !important;
    border-right: 3px solid transparent !important;
    border-top: 4px solid #999 !important;
    width: 0 !important;
    height: 0 !important;
}

/* ⭐ Country dropdown */
.walt-form-group .iti__country-list {
    position: absolute !important;
    z-index: 999999 !important;
    max-height: 200px !important;
    width: 300px !important;
    overflow-y: auto !important;
    background: #fff !important;
    border: 1px solid var(--walt-border) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

/* ⭐ Dropdown item */
.walt-form-group .iti__country {
    padding: 10px 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    transition: background 0.2s ease !important;
}

.walt-form-group .iti__country:hover {
    background: rgba(37, 211, 102, 0.08) !important;
}

.walt-form-group .iti__country.iti__highlight {
    background: rgba(37, 211, 102, 0.12) !important;
}

/* Country name */
.walt-form-group .iti__country-name {
    flex: 1 !important;
    color: var(--walt-text-dark) !important;
}

/* Dial code */
.walt-form-group .iti__dial-code {
    color: var(--walt-text-light) !important;
}

/* ⭐ Validation error message */
.walt-field-error {
    display: block;
    color: #dc3545;
    font-size: 13px;
    margin-top: 5px;
    padding-left: 16px;
}

/* ⭐ Ensure overflow is visible for dropdown */
.walt-chat-form-wrapper,
.walt-chat-form {
    overflow: visible !important;
}

/* ========== RESPONSIVO ========== */
@media (max-width: 768px) {
    .walt-chat-modal {
        width: 95%;
        max-width: 95%;
        max-height: 95vh;
    }

    .walt-chat-header {
        padding: 16px;
    }

    .walt-chat-body {
        padding: 16px;
    }

    .walt-button-tooltip {
        display: none;
    }
    
    /* Prevents zoom on iOS */
    .walt-form-group input#walt-phone,
    .walt-form-group .iti__tel-input {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .walt-chat-modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .walt-chat-bubble {
        max-width: 90%;
    }

    .walt-chat-submit-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
}
