/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
}

.chat-widget .back-to-top,
.chat-widget .chat-button,
.chat-widget .chat-box {
    pointer-events: auto;
}

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #1e3a8a;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9998;
    position: relative;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: #1e40af;
    transform: translateY(-2px);
}

.chat-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.3);
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0);
    z-index: 9997;
}

.chat-button.show {
    opacity: 1;
    transform: scale(1);
    animation: chatButtonEntrance 0.6s ease-out;
}

.chat-button.shake {
    animation: shake 0.5s ease-in-out;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(30, 58, 138, 0.4);
}

.chat-button i {
    color: white;
    font-size: 24px;
}

.progress-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    width: 56px;
    height: 56px;
    transform: rotate(-90deg);
    z-index: -1;
}

.progress-ring-circle {
    fill: none;
    stroke: #3b82f6;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 150.8;
    stroke-dashoffset: 150.8;
    transition: stroke-dashoffset 0.1s linear;
}

.chat-notification {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.chat-notification.show {
    opacity: 1;
    transform: scale(1);
    animation: notificationPulse 2s infinite;
}

.chat-box {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 550px;
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-box.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-header {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-status {
    display: flex;
    flex-direction: column;
}

.chat-title {
    font-weight: 600;
    font-size: 14px;
}

.chat-online {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.online-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.online-dot.away {
    background: #FF9800;
    animation: pulse-away 2s infinite;
}

@keyframes pulse-away {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 152, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 152, 0, 0);
    }
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: rgba(248, 250, 252, 0.8);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    min-height: 350px;
    max-height: 400px;
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.user-message {
    justify-content: flex-end;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1e3a8a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message-content {
    background: white;
    color: black;
    padding: 10px 14px;
    border-radius: 8px;
    max-width: 80%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    font-size: 13px;
}

.message-content::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid white;
}

.user-message-content {
    background: #e3f2fd;
    color: black;
}

.user-message-content::before {
    display: none;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

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

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

.chat-input {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    border-top: 1px solid rgba(226, 232, 240, 0.5);
}

.input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background-color: white;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.chat-textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 10px 14px;
    resize: none;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    max-height: 70px;
    min-height: 40px;
    transition: border-color 0.3s ease;
    background-color: white;
}

.chat-textarea:focus {
    outline: none;
    border-color: #3b82f6;
}

.chat-send {
    width: 40px;
    height: 40px;
    background: #3b82f6;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(30, 58, 138, 0.3);
}

.whatsapp-transfer {
    background: #25d366;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.whatsapp-transfer:hover {
    background: #128c7e;
    transform: translateY(-1px);
}

.whatsapp-transfer i {
    font-size: 14px;
}

.auto-reply {
    background: white;
    padding: 10px 14px;
    margin: 10px 0;
    border-radius: 8px;
    font-size: 13px;
    color: black;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 80%;
.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-box {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        right: 20px;
        left: 20px;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .chat-messages {
        min-height: calc(100vh - 300px);
        max-height: calc(100vh - 250px);
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-input {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .chat-box {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: 10px;
        left: 10px;
    }
    
    .chat-textarea {
         font-size: 16px; /* Prevents zoom on iOS */
     }
 }

/* Animations */
@keyframes chatButtonEntrance {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(90deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes notificationPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .chat-box {
        width: 300px;
        height: 400px;
    }
    
    .back-to-top {
        bottom: 20px;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .chat-box {
        width: calc(100vw - 40px);
        right: -10px;
    }
}