.sprm-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--sprm-color, #6366f1);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--sprm-color, #6366f1) 40%, transparent);
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.sprm-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--sprm-color, #6366f1) 50%, transparent);
}

.sprm-chat-btn svg {
    width: 36px;
    height: 36px;
    fill: currentColor;
}

.sprm-chat-btn .sprm-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sprm-chat-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 500px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 99990;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.sprm-chat-window.sprm-chat-open {
    display: flex;
}

.sprm-chat-header {
    padding: 16px;
    background: var(--sprm-color, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sprm-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

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

.sprm-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.sprm-chat-header-status {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.sprm-chat-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
}

.sprm-chat-close:hover {
    opacity: 1;
}

.sprm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.sprm-chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
    margin-bottom: 8px;
}

.sprm-chat-msg-visitor {
    align-self: flex-end;
    background: var(--sprm-color, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.sprm-chat-msg-manager {
    align-self: flex-start;
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 4px;
}

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

.sprm-chat-typing {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    flex-shrink: 0;
}

.sprm-chat-typing.sprm-chat-visible {
    max-height: 40px;
    padding: 6px 16px;
}

.sprm-chat-typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    background: #f3f4f6;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 8px 14px;
}

.sprm-chat-typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: sprm-chat-bounce 1.4s ease-in-out infinite;
}

.sprm-chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.sprm-chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

.sprm-chat-input-area {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.sprm-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 16px;
    outline: none;
    font-family: inherit;
}

.sprm-chat-input:focus {
    border-color: var(--sprm-color, #6366f1);
}

.sprm-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sprm-color, #6366f1);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.sprm-chat-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sprm-chat-attach {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #9ca3af;
    transition: color 0.2s;
}

.sprm-chat-attach:hover {
    color: var(--sprm-color, #6366f1);
}

.sprm-chat-photo-preview {
    display: none;
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.sprm-chat-photo-thumb {
    position: relative;
    display: inline-block;
}

.sprm-chat-photo-thumb img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.sprm-chat-photo-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Name form */
.sprm-chat-name-form {
    padding: 12px 16px;
    background: #f0f4ff;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.sprm-chat-name-label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin: 0 0 8px 0;
}

.sprm-chat-name-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
    margin-bottom: 8px;
}

.sprm-chat-name-input:focus {
    border-color: var(--sprm-color, #6366f1);
}

.sprm-chat-name-buttons {
    display: flex;
    gap: 8px;
}

.sprm-chat-name-submit {
    flex: 1;
    padding: 6px 12px;
    background: var(--sprm-color, #6366f1);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.sprm-chat-name-submit:hover {
    opacity: 0.9;
}

.sprm-chat-name-skip {
    padding: 6px 12px;
    background: none;
    color: #9ca3af;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}

.sprm-chat-name-skip:hover {
    color: #6b7280;
    border-color: #9ca3af;
}

.sprm-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 14px;
    text-align: center;
    padding: 24px;
}

.fancybox__container {
    z-index: 999999 !important;
}

/* Button sizes */
.sprm-chat-btn.sprm-chat-size-small {
    width: 56px;
    height: 56px;

    svg {
        width: 28px;
        height: 28px;
    }
}

.sprm-chat-btn.sprm-chat-size-large {
    width: 84px;
    height: 84px;

    svg {
        width: 44px;
        height: 44px;
    }
}

/* Left position */
.sprm-chat-btn.sprm-chat-left {
    right: auto;
    left: 24px;
}

.sprm-chat-window.sprm-chat-left {
    right: auto;
    left: 24px;
}

/* Greeting bubble */
.sprm-chat-greeting {
    position: fixed;
    bottom: 90px;
    right: 24px;
    max-width: 280px;
    padding: 12px 36px 12px 16px;
    background: #fff;
    color: #111827;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    z-index: 99991;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
}

.sprm-chat-greeting.sprm-chat-greeting-visible {
    opacity: 1;
    transform: translateY(0);
}

.sprm-chat-greeting-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
}

.sprm-chat-greeting-close:hover {
    color: #111827;
}

.sprm-chat-greeting::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
}

.sprm-chat-greeting.sprm-chat-left {
    right: auto;
    left: 24px;
}

.sprm-chat-greeting.sprm-chat-left::after {
    right: auto;
    left: 20px;
}

@media (max-width: 480px) {
    .sprm-chat-window,
    .sprm-chat-window.sprm-chat-left {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .sprm-chat-btn {
        bottom: 16px;
        right: 16px;
    }

    .sprm-chat-btn.sprm-chat-left {
        right: auto;
        left: 16px;
    }
}
