/* ============================================================
   YF Natural Care Wax - Live Chat Widget
   ============================================================ */

/* === Chat Launcher Button === */
.chat-launcher {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--color-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(45, 74, 62, 0.4);
    z-index: 10000;
    transition: all 0.3s ease;
    animation: chat-pulse 2s infinite;
}

.chat-launcher:hover {
    transform: scale(1.1);
    background: var(--color-green-dark);
}

.chat-launcher i {
    font-size: 1.5rem;
    color: white;
}

.chat-launcher .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #EF4444;
    border-radius: 10px;
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    display: none;
}

.chat-launcher .chat-badge.visible {
    display: flex;
}

@keyframes chat-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(45, 74, 62, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(45, 74, 62, 0.6); }
}

/* === Chat Window === */
.chat-window {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 380px;
    max-width: calc(100vw - 60px);
    height: 560px;
    max-height: calc(100vh - 60px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chat-slide-in 0.3s ease;
}

#chatBody {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.chat-window.visible {
    display: flex;
}

@keyframes chat-slide-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Chat Header === */
.chat-header {
    background: linear-gradient(135deg, var(--color-green-dark), var(--color-green));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: var(--color-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    color: white;
    flex-shrink: 0;
}

.chat-header-info {
    flex-grow: 1;
}

.chat-header-info h4 {
    color: white;
    font-size: 0.9375rem;
    margin: 0;
    font-weight: 600;
}

.chat-header-info .chat-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.chat-status-dot.offline {
    background: #94a3b8;
}

.chat-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.chat-close-btn:hover {
    color: white;
}

/* === Chat Messages Area === */
.chat-messages {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: var(--color-ivory);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-gray-dark);
    border-radius: 2px;
}

.chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msg-fade-in 0.3s ease;
}

@keyframes msg-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.admin {
    align-self: flex-start;
    background: white;
    color: var(--color-charcoal);
    border: 1px solid var(--color-gray);
    border-bottom-left-radius: 4px;
}

.chat-msg.customer {
    align-self: flex-end;
    background: var(--color-green);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg .msg-time {
    font-size: 0.6875rem;
    opacity: 0.6;
    margin-top: 4px;
}

.chat-typing-indicator {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--color-gray);
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: none;
}

.chat-typing-indicator.visible {
    display: flex;
    gap: 4px;
}

.chat-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--color-gray-dark);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

.chat-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* === Chat Input Area === */
.chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--color-gray);
    display: flex;
    gap: 6px;
    align-items: center;
    background: white;
    flex-shrink: 0;
}

.chat-input-toolbar {
    display: flex;
    gap: 4px;
    align-items: center;
}

.chat-tool-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-gray-light);
    color: var(--color-gray-dark);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-tool-btn:hover {
    background: var(--color-green);
    color: white;
}

.chat-tool-btn.active {
    background: var(--color-green);
    color: white;
}

.chat-translate-preview {
    padding: 8px 12px;
    background: #f0fdf4;
    border-top: 1px solid #bbf7d0;
    font-size: 0.8125rem;
    color: var(--color-charcoal);
    display: none;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.chat-translate-preview.visible {
    display: flex;
}

.chat-translate-preview .translate-label {
    font-size: 0.6875rem;
    color: var(--color-gray-dark);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-translate-preview .translate-text {
    color: var(--color-green-dark);
}

.chat-translate-preview .translate-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.chat-translate-preview .translate-actions button {
    font-size: 0.6875rem;
    border: none;
    background: var(--color-green);
    color: white;
    padding: 3px 10px;
    border-radius: 10px;
    cursor: pointer;
}

.chat-translate-preview .translate-actions button:hover {
    background: var(--color-green-dark);
}

.chat-translate-preview .translate-actions .btn-cancel {
    background: var(--color-gray-dark);
}

.chat-translate-preview .translate-actions .btn-cancel:hover {
    background: var(--color-charcoal);
}

.chat-lang-selector {
    padding: 6px 12px;
    border-top: 1px solid var(--color-gray);
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 0.6875rem;
    color: var(--color-gray-dark);
    background: var(--color-gray-light);
    flex-shrink: 0;
}

.chat-lang-selector.visible {
    display: flex;
}

.chat-lang-selector select {
    font-size: 0.6875rem;
    border: 1px solid var(--color-gray);
    border-radius: 3px;
    padding: 2px 4px;
}

.chat-input {
    flex-grow: 1;
    border: 1px solid var(--color-gray);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-family: var(--font-body);
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--color-green);
}

.chat-input::placeholder {
    color: var(--color-gray-dark);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: var(--color-green);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--color-green-dark);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Chat Pre-Chat Form === */
.chat-pre-form {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 30px 24px;
    background: var(--color-ivory);
}

.chat-pre-form .chat-welcome-icon {
    text-align: center;
    margin-bottom: 20px;
}

.chat-pre-form .chat-welcome-icon i {
    font-size: 3rem;
    color: var(--color-green);
    opacity: 0.3;
}

.chat-pre-form h3 {
    font-size: 1.125rem;
    text-align: center;
    margin-bottom: 8px;
    color: var(--color-dark);
}

.chat-pre-form p {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--color-gray-dark);
    margin-bottom: 24px;
}

.chat-pre-form .form-group {
    margin-bottom: 14px;
}

.chat-pre-form .form-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-charcoal);
    margin-bottom: 4px;
    display: block;
}

.chat-pre-form .form-group input {
    width: 100%;
    border: 1px solid var(--color-gray);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: var(--font-body);
    outline: none;
    transition: border-color 0.2s;
}

.chat-pre-form .form-group input:focus {
    border-color: var(--color-green);
}

.chat-pre-form .btn-start-chat {
    width: 100%;
    background: var(--color-green);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-pre-form .btn-start-chat:hover {
    background: var(--color-green-dark);
}

.chat-pre-form .chat-disclaimer {
    font-size: 0.6875rem;
    color: var(--color-gray-dark);
    text-align: center;
    margin-top: 12px;
}

.chat-pre-form .chat-disclaimer a {
    color: var(--color-green);
}

/* === Offline Contact Card === */
.chat-contact-card {
    align-self: center;
    max-width: 92%;
    background: white;
    border: 1px solid var(--color-gold);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(200, 169, 81, 0.15);
    animation: msg-fade-in 0.4s ease;
    margin-top: 8px;
}

.chat-contact-card .contact-card-icon {
    font-size: 2rem;
    color: var(--color-gold);
    margin-bottom: 10px;
}

.chat-contact-card .contact-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-dark);
    margin-bottom: 4px;
}

.chat-contact-card .contact-card-desc {
    font-size: 0.75rem;
    color: var(--color-gray-dark);
    margin-bottom: 14px;
}

.chat-contact-card .contact-card-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-contact-card .contact-field {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--color-gray);
    border-radius: 8px;
    padding: 8px 12px;
    transition: border-color 0.2s;
}

.chat-contact-card .contact-field:focus-within {
    border-color: var(--color-green);
}

.chat-contact-card .contact-field i {
    color: var(--color-gray-dark);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.chat-contact-card .contact-field .fa-whatsapp {
    color: #25D366;
}

.chat-contact-card .contact-field input {
    flex-grow: 1;
    border: none;
    outline: none;
    font-size: 0.8125rem;
    font-family: var(--font-body);
    background: transparent;
    min-width: 0;
}

.chat-contact-card .contact-submit-btn {
    background: var(--color-green);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.chat-contact-card .contact-submit-btn:hover {
    background: var(--color-green-dark);
}

.chat-contact-card .contact-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-contact-card .contact-skip-btn {
    background: none;
    border: none;
    color: var(--color-gray-dark);
    font-size: 0.6875rem;
    cursor: pointer;
    padding: 4px;
    text-decoration: underline;
}

.chat-contact-card .contact-skip-btn:hover {
    color: var(--color-charcoal);
}

.chat-contact-card.submitted {
    border-color: var(--color-green);
}

.chat-contact-card.submitted .contact-card-form {
    display: none;
}

.chat-contact-card .contact-card-success {
    display: none;
    color: var(--color-green);
    font-size: 0.8125rem;
    padding: 8px 0;
}

.chat-contact-card.submitted .contact-card-success {
    display: block;
}

/* === Chat Closed Banner === */
.chat-closed-banner {
    background: #fef3c7;
    color: #92400e;
    padding: 8px 16px;
    font-size: 0.75rem;
    text-align: center;
    border-bottom: 1px solid #fde68a;
    display: none;
}

.chat-closed-banner.visible {
    display: block;
}

/* === Responsive === */
@media (max-width: 767px) {
    .chat-launcher {
        bottom: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
    }
    
    .chat-launcher i {
        font-size: 1.25rem;
    }
    
    .chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }
}
