/* =============================================
   Chat Online Widget v2.1 — Full CSS
   ============================================= */

.chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Container only as big as the button */
    width: 60px;
    height: 60px;
}

/* ===== Desktop hint label (base - always shown) ===== */
.chat-desktop-label {
    position: absolute;
    bottom: 72px;
    right: 0;
    background: #1f2937;
    color: #fff;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.4s ease;
}
.chat-desktop-label::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 22px;
    width: 0; height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #1f2937;
}

/* Hide labels on mobile/tablet - REMOVED, now shown everywhere */

/* ===== Promo label (flashy - shown by JS timer) ===== */
.chat-promo-label {
    position: absolute;
    bottom: 72px;
    right: 0;
    color: #fff;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 18px rgba(0,0,0,0.2);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: none;
}
.chat-promo-label::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 22px;
    width: 0; height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #ef4444;
}
.chat-promo-label.show {
    opacity: 1;
    animation: promo-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes promo-pulse {
    from { box-shadow: 0 0 20px rgba(0,0,0,0.2), 0 4px 14px rgba(0,0,0,0.15); }
    to   { box-shadow: 0 0 36px rgba(0,0,0,0.3), 0 6px 22px rgba(0,0,0,0.25); }
}

/* Promo color classes */
.chat-promo-label.promo-red {
    background: linear-gradient(135deg, #f97316, #ef4444, #ec4899);
    box-shadow: 0 0 24px rgba(239,68,68,0.5), 0 4px 18px rgba(0,0,0,0.2);
}
.chat-promo-label.promo-red::after { border-top-color: #ef4444; }
.chat-promo-label.promo-red.show {
    animation: promo-pulse-red 0.8s ease-in-out infinite alternate;
}
@keyframes promo-pulse-red {
    from { box-shadow: 0 0 20px rgba(239,68,68,0.5), 0 4px 14px rgba(0,0,0,0.15); }
    to   { box-shadow: 0 0 36px rgba(239,68,68,0.7), 0 6px 22px rgba(0,0,0,0.25); }
}

.chat-promo-label.promo-green {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 0 24px rgba(16,185,129,0.5), 0 4px 18px rgba(0,0,0,0.2);
}
.chat-promo-label.promo-green::after { border-top-color: #059669; }
.chat-promo-label.promo-green.show {
    animation: promo-pulse-green 0.8s ease-in-out infinite alternate;
}
@keyframes promo-pulse-green {
    from { box-shadow: 0 0 20px rgba(16,185,129,0.5), 0 4px 14px rgba(0,0,0,0.15); }
    to   { box-shadow: 0 0 36px rgba(16,185,129,0.7), 0 6px 22px rgba(0,0,0,0.25); }
}

.chat-promo-label.promo-blue {
    background: linear-gradient(135deg, #3b82f6, #7c3aed);
    box-shadow: 0 0 24px rgba(59,130,246,0.5), 0 4px 18px rgba(0,0,0,0.2);
}
.chat-promo-label.promo-blue::after { border-top-color: #7c3aed; }
.chat-promo-label.promo-blue.show {
    animation: promo-pulse-blue 0.8s ease-in-out infinite alternate;
}
@keyframes promo-pulse-blue {
    from { box-shadow: 0 0 20px rgba(59,130,246,0.5), 0 4px 14px rgba(0,0,0,0.15); }
    to   { box-shadow: 0 0 36px rgba(59,130,246,0.7), 0 6px 22px rgba(0,0,0,0.25); }
}

.chat-promo-label.promo-gold {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #1f2937;
    box-shadow: 0 0 24px rgba(245,158,11,0.5), 0 4px 18px rgba(0,0,0,0.2);
}
.chat-promo-label.promo-gold::after { border-top-color: #f59e0b; }
.chat-promo-label.promo-gold.show {
    animation: promo-pulse-gold 0.8s ease-in-out infinite alternate;
}
@keyframes promo-pulse-gold {
    from { box-shadow: 0 0 20px rgba(245,158,11,0.5), 0 4px 14px rgba(0,0,0,0.15); }
    to   { box-shadow: 0 0 36px rgba(245,158,11,0.7), 0 6px 22px rgba(0,0,0,0.25); }
}

.chat-promo-label.promo-purple {
    background: linear-gradient(135deg, #a855f7, #d946ef);
    box-shadow: 0 0 24px rgba(168,85,247,0.5), 0 4px 18px rgba(0,0,0,0.2);
}
.chat-promo-label.promo-purple::after { border-top-color: #a855f7; }
.chat-promo-label.promo-purple.show {
    animation: promo-pulse-purple 0.8s ease-in-out infinite alternate;
}
@keyframes promo-pulse-purple {
    from { box-shadow: 0 0 20px rgba(168,85,247,0.5), 0 4px 14px rgba(0,0,0,0.15); }
    to   { box-shadow: 0 0 36px rgba(168,85,247,0.7), 0 6px 22px rgba(0,0,0,0.25); }
}

/* Custom color (set via JS inline style) */
.chat-promo-label.promo-custom::after { border-top-color: #888; }

/* Show labels on mobile too */
@media (max-width: 768px) {
    .chat-desktop-label {
        font-size: 11px;
        padding: 7px 12px;
        bottom: 62px;
    }
    .chat-desktop-label::after { right: 20px; bottom: -5px; }
    .chat-promo-label {
        font-size: 11px;
        padding: 8px 14px;
        bottom: 62px;
        white-space: normal;
        max-width: 180px;
        text-align: center;
        line-height: 1.4;
    }
    .chat-promo-label::after { right: 20px; bottom: -5px; }
}

/* ===== Pulse rings ===== */
.chat-pulse-ring {
    position: absolute;
    bottom: 0; right: 0;
    width: 60px; height: 60px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}
.chat-pulse-ring-1 {
    border: 3px solid rgba(124,58,237,0.45);
    animation: pulse-expand 3s ease-out infinite;
}
.chat-pulse-ring-2 {
    border: 3px solid rgba(124,58,237,0.25);
    animation: pulse-expand 3s ease-out 1.5s infinite;
}
@keyframes pulse-expand {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

/* ===== Main floating button ===== */
.chat-main-button {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(79,70,229,0.45);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    position: absolute;
    bottom: 0; right: 0;
    z-index: 10;
    border: none;
    outline: none;
    animation: btn-glow 3s ease-in-out infinite;
}
@keyframes btn-glow {
    0%, 100% { box-shadow: 0 4px 20px rgba(79,70,229,0.45); }
    50% { box-shadow: 0 6px 36px rgba(124,58,237,0.65), 0 0 0 12px rgba(124,58,237,0.06); }
}
.chat-main-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(124,58,237,0.6);
    animation: none;
}
.chat-main-button.active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 20px rgba(239,68,68,0.5);
    animation: none;
}
.chat-main-button svg { transition: transform 0.3s ease; }
.chat-main-button:active svg { transform: scale(0.9); }

/* ===== Action buttons panel ===== */
.chat-buttons-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(24px) scale(0.85);
    transform-origin: bottom center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-buttons-panel.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

.chat-action-btn {
    width: 50px; height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    position: relative;
    box-shadow: 0 3px 14px rgba(0,0,0,0.22);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border: none;
    outline: none;
}
.chat-action-btn:hover { transform: scale(1.12); }
.chat-action-btn:active { transform: scale(0.92); }

/* Tooltip */
.chat-tooltip {
    position: absolute;
    right: 62px;
    background: #1f2937;
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.chat-action-btn:hover .chat-tooltip {
    opacity: 1;
    transform: translateX(0);
}

/* Button colors */
.chat-custom-btn { background: linear-gradient(135deg, #f472b6, #e11d48); }
.chat-custom-icon-wrap { display: flex; align-items: center; justify-content: center; }
.chat-custom-icon-wrap img, .chat-custom-icon-wrap svg { width: 22px; height: 22px; }
.chat-telegram-btn { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.chat-email-btn { background: linear-gradient(135deg, #f59e0b, #d97706); }
.chat-online-btn { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }

/* ===== Chat window ===== */
.chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 370px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 5;
    animation: window-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-window.open { display: flex; }
@keyframes window-in {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.chat-window-header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-window-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.chat-status-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #34d399;
    animation: dot-pulse 2s infinite;
}
@keyframes dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.75); }
}
.chat-window-close {
    background: rgba(255,255,255,0.2);
    border: none; color: #fff;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.chat-window-close:hover { background: rgba(255,255,255,0.35); }

/* ===== Pre-chat form ===== */
.chat-prechat-form {
    flex: 1;
    display: flex; flex-direction: column;
    padding: 28px 22px; gap: 14px;
    background: #f9fafb; overflow-y: auto;
}
.chat-prechat-title {
    font-size: 17px; font-weight: 700;
    color: #1f2937; text-align: center;
}
.chat-prechat-subtitle {
    font-size: 13.5px; color: #6b7280;
    text-align: center; margin-bottom: 10px;
}
.chat-prechat-input {
    width: 100%; padding: 13px 15px;
    border: 1.5px solid #d1d5db;
    border-radius: 12px;
    font-size: 16px; outline: none;
    font-family: inherit; transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}
.chat-prechat-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 4px rgba(124,58,237,0.1);
}
.chat-prechat-error {
    color: #ef4444; font-size: 13px;
    display: none; text-align: center;
    background: #fef2f2; padding: 8px 12px;
    border-radius: 8px;
}
.chat-prechat-submit {
    width: 100%; padding: 14px; border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff; font-size: 16px; font-weight: 600;
    cursor: pointer; transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.chat-prechat-submit:hover { box-shadow: 0 6px 18px rgba(79,70,229,0.45); transform: translateY(-1px); }
.chat-prechat-submit:active { transform: translateY(0); }
.chat-prechat-submit:disabled { opacity: 0.65; cursor: not-allowed; }

/* ===== Chat body ===== */
#chat-body { overflow: hidden; }

.chat-window-messages {
    flex: 1; overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
    background: #f9fafb;
}
.chat-window-messages::-webkit-scrollbar { width: 4px; }
.chat-window-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* Message bubbles */
.chat-message {
    display: flex; flex-direction: column;
    max-width: 85%;
    animation: msg-pop 0.3s ease-out;
}
@keyframes msg-pop {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-message-user { align-self: flex-end; }
.chat-message-admin { align-self: flex-start; }

.chat-message-bubble {
    padding: 10px 15px; border-radius: 18px;
    font-size: 13.5px; line-height: 1.5; word-wrap: break-word;
}
.chat-message-user .chat-message-bubble {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff; border-bottom-right-radius: 4px;
}
.chat-message-admin .chat-message-bubble {
    background: #e5e7eb; color: #1f2937; border-bottom-left-radius: 4px;
}
.chat-manager-name {
    font-size: 10px;
    color: #6d28d9;
    margin-top: 2px;
    padding: 0 6px;
    font-weight: 500;
}
.chat-message-time { font-size: 10px; color: #9ca3af; margin-top: 1px; padding: 0 6px; }
.chat-message-user .chat-message-time { text-align: right; }

/* ===== Input area ===== */
.chat-window-input-area {
    padding: 10px 14px;
    border-top: 1px solid #e5e7eb;
    display: flex; gap: 8px; align-items: flex-end;
    background: #fff; flex-shrink: 0;
}
.chat-input {
    flex: 1;
    border: 1.5px solid #d1d5db;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 16px;
    resize: none; outline: none;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}
.chat-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.chat-send-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 6px rgba(79,70,229,0.3);
}
.chat-send-btn:hover { transform: scale(1.08); box-shadow: 0 4px 14px rgba(79,70,229,0.45); }
.chat-send-btn:active { transform: scale(0.93); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .chat-pulse-ring { display: none; }
}

@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 14px;
        right: 14px;
        width: 54px;
        height: 54px;
    }
    .chat-window {
        width: calc(100vw - 28px);
        height: 460px;
        max-height: calc(100vh - 100px);
        bottom: 66px;
        right: 0;
    }
    .chat-main-button { width: 54px; height: 54px; }
    .chat-action-btn { width: 46px; height: 46px; }
    .chat-pulse-ring-1,
    .chat-pulse-ring-2 { width: 54px; height: 54px; }
    .chat-prechat-form { padding: 20px 16px; }
}
