/* Chat Widget — Modern Messenger Style */

/* Floating bubble */
.chat-bubble {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a68b3c 0%, #c4a44a 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(166, 139, 60, 0.4), 0 0 0 0 rgba(166, 139, 60, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 9999;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
    animation: bubblePulse 3s ease-in-out infinite;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(166, 139, 60, 0.5);
    animation: none;
}

@keyframes bubblePulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(166, 139, 60, 0.4), 0 0 0 0 rgba(166, 139, 60, 0.3); }
    50% { box-shadow: 0 4px 20px rgba(166, 139, 60, 0.4), 0 0 0 8px rgba(166, 139, 60, 0); }
}

.chat-bubble .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
    animation: badgeBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgeBounce {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Panel */
.chat-panel {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.05);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.chat-panel-header {
    background: linear-gradient(135deg, #a68b3c 0%, #c4a44a 100%);
    color: #fff;
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-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: 1.2rem;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.chat-header-status {
    font-size: 0.72rem;
    opacity: 0.85;
    margin-top: 0.1rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-header-status .online-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

.chat-panel-header .chat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-panel-header .chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Welcome / intro screen */
.chat-intro {
    padding: 1.5rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-welcome-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 0.25rem;
}

.chat-intro-text {
    color: #6b7280;
    font-size: 0.88rem;
    text-align: center;
    line-height: 1.5;
    margin: 0;
}

.chat-intro-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-intro-form input,
.chat-intro-form textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafafa;
    color: #1a1d23;
    resize: none;
}

.chat-intro-form input:focus,
.chat-intro-form textarea:focus {
    border-color: #a68b3c;
    box-shadow: 0 0 0 3px rgba(166, 139, 60, 0.1);
    background: #fff;
}

.chat-intro-form input::placeholder,
.chat-intro-form textarea::placeholder {
    color: #9ca3af;
}

.chat-start-btn {
    background: linear-gradient(135deg, #a68b3c 0%, #c4a44a 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.25rem;
}

.chat-start-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(166, 139, 60, 0.3);
}

.chat-start-btn:active {
    transform: translateY(0);
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    min-height: 220px;
    max-height: 320px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.chat-msg {
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    animation: msgFadeIn 0.25s ease-out;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.visitor {
    align-items: flex-end;
}

.chat-msg.admin {
    align-items: flex-start;
}

.chat-msg-bubble {
    max-width: 78%;
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.chat-msg.visitor .chat-msg-bubble {
    background: linear-gradient(135deg, #a68b3c 0%, #b8993f 100%);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 1px 3px rgba(166, 139, 60, 0.2);
}

.chat-msg.admin .chat-msg-bubble {
    background: #fff;
    color: #1a1d23;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f0;
}

.chat-msg-time {
    font-size: 0.66rem;
    color: #9ca3af;
    margin-top: 0.2rem;
    padding: 0 0.35rem;
}

/* Input area */
.chat-input-area {
    padding: 0.65rem 0.75rem;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: #fff;
}

.chat-input-area textarea {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    padding: 0.55rem 0.9rem;
    font-size: 0.88rem;
    resize: none;
    outline: none;
    max-height: 80px;
    font-family: inherit;
    line-height: 1.4;
    background: #fafafa;
    color: #1a1d23;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.chat-input-area textarea:focus {
    border-color: #a68b3c;
    box-shadow: 0 0 0 3px rgba(166, 139, 60, 0.08);
    background: #fff;
}

.chat-input-area textarea::placeholder {
    color: #9ca3af;
}

.chat-send-btn {
    background: linear-gradient(135deg, #a68b3c 0%, #c4a44a 100%);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.2s;
    font-size: 0.95rem;
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 10px rgba(166, 139, 60, 0.3);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* End chat footer */
.chat-footer-bar {
    text-align: center;
    padding: 0.4rem 0.75rem;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}

.chat-end-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: inherit;
    transition: color 0.2s, background 0.2s;
}

.chat-end-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

/* Contact info toggle */
.chat-contact-toggle {
    color: #a68b3c;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
}

.chat-contact-toggle:hover {
    background: rgba(166, 139, 60, 0.08);
    color: #8a7232;
}

/* Contact info form */
.chat-contact-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0;
}

.chat-contact-form input {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafafa;
    color: #1a1d23;
}

.chat-contact-form input:focus {
    border-color: #a68b3c;
    box-shadow: 0 0 0 3px rgba(166, 139, 60, 0.1);
    background: #fff;
}

.chat-contact-form input::placeholder {
    color: #9ca3af;
}

.chat-contact-save-btn {
    background: linear-gradient(135deg, #a68b3c 0%, #c4a44a 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-contact-save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(166, 139, 60, 0.25);
}

.chat-contact-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Contact saved confirmation */
.chat-contact-saved {
    color: #22c55e;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.3rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-panel {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
    }

    .chat-bubble {
        bottom: 1rem;
        right: 1rem;
        width: 54px;
        height: 54px;
        font-size: 1.3rem;
    }

    .chat-messages {
        max-height: calc(100vh - 240px);
    }
}
