/* UniMax Widgets — Popups, Chat, Floating CTA */

/* === POPUP BASE === */
.unimax-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.unimax-popup__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}
.unimax-popup__content {
    position: relative;
    background: var(--unimax-background, #fff);
    border-radius: 16px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: unimaxPopupIn 0.3s ease;
}
@keyframes unimaxPopupIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.unimax-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--unimax-muted, #6b7280);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.unimax-popup__close:hover {
    color: var(--unimax-foreground, #1e1b4b);
}
.unimax-popup__title {
    font-family: var(--unimax-heading-font, inherit);
    font-size: 22px;
    font-weight: 700;
    color: var(--unimax-foreground, #1e1b4b);
    margin-bottom: 8px;
}
.unimax-popup__desc {
    color: var(--unimax-muted, #6b7280);
    font-size: 15px;
    margin-bottom: 20px;
}
.unimax-popup__form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.unimax-popup__submit {
    width: 100%;
}

/* Popup image */
.unimax-popup__image {
    margin: -32px -32px 20px -32px;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
}
.unimax-popup__image img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

/* Popup CTA link (no form mode) */
.unimax-popup__cta-link {
    display: block;
    text-align: center;
    margin-top: 8px;
    text-decoration: none;
}

/* === PRIVACY CHECKBOX === */
.unimax-form__privacy {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--unimax-muted, #6b7280);
    cursor: pointer;
    line-height: 1.4;
}
.unimax-form__privacy input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--unimax-primary, #8b5cf6);
}
.unimax-form__privacy a {
    color: var(--unimax-primary, #8b5cf6);
    text-decoration: underline;
}
.unimax-form__privacy a:hover {
    color: var(--unimax-foreground, #1e1b4b);
}

/* === SUPPORT CHAT === */
.unimax-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99998;
}
.unimax-chat__toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--unimax-primary, #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s;
}
.unimax-chat__toggle:hover {
    transform: scale(1.05);
}
.unimax-chat__window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-height: 500px;
    background: var(--unimax-background, #fff);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: unimaxChatIn 0.25s ease;
    display: flex;
    flex-direction: column;
}
@keyframes unimaxChatIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.unimax-chat__header {
    background: var(--unimax-primary, #8b5cf6);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.unimax-chat__header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.unimax-chat__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}
.unimax-chat__title {
    font-weight: 600;
    font-size: 14px;
    display: block;
}
.unimax-chat__operator {
    font-size: 11px;
    opacity: 0.8;
    display: block;
}
.unimax-chat__close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}
.unimax-chat__body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.unimax-chat__messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.unimax-chat__message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.unimax-chat__message p {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    max-width: 85%;
    margin: 0;
}
.unimax-chat__message--bot p {
    background: var(--unimax-card-bg, #f3f4f6);
    color: var(--unimax-foreground, #1e1b4b);
    border-bottom-left-radius: 4px;
}
.unimax-chat__message--user p {
    background: var(--unimax-primary, #8b5cf6);
    color: #fff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}
.unimax-chat__msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
@keyframes unimaxChatMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
/* Chat input bar */
.unimax-chat__input-bar {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 8px;
}
.unimax-chat__input-bar .unimax-chat__input {
    flex: 1;
    resize: none !important;
    min-height: 38px;
    max-height: 80px;
    border: 1px solid var(--unimax-border, #e5e7eb) !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    background: var(--unimax-background, #fff);
    color: var(--unimax-foreground, #1e1b4b);
    font-family: var(--unimax-body-font, inherit);
    outline: none;
    box-sizing: border-box;
    width: auto;
}
.unimax-chat__input-bar .unimax-chat__input:focus {
    border-color: var(--unimax-primary, #8b5cf6) !important;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.unimax-chat__send {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50% !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.unimax-chat__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* Typing indicator */
.unimax-chat__typing p {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}
.unimax-chat__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--unimax-muted, #6b7280);
    animation: unimaxDotBounce 1.4s infinite ease-in-out both;
}
.unimax-chat__dot:nth-child(1) { animation-delay: -0.32s; }
.unimax-chat__dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes unimaxDotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
.unimax-chat__tg-link {
    display: block;
    margin-top: 12px;
    text-align: center;
    color: var(--unimax-primary, #8b5cf6);
    font-size: 13px;
    text-decoration: none;
}
.unimax-chat__tg-link:hover {
    text-decoration: underline;
}

/* === FLOATING CTA === */
.unimax-floating-cta {
    position: fixed;
    z-index: 99997;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--unimax-primary, #8b5cf6);
    color: #fff;
    border-radius: 50px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s;
}
.unimax-floating-cta:hover {
    transform: scale(1.05);
    color: #fff;
}
.unimax-floating-cta--bottom-right {
    bottom: 24px;
    right: 24px;
}
.unimax-floating-cta--bottom-left {
    bottom: 24px;
    left: 24px;
}

/* Multiple CTAs group */
.unimax-floating-cta-group {
    position: fixed;
    z-index: 99997;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.unimax-floating-cta-group--bottom-right {
    bottom: 24px;
    right: 24px;
}
.unimax-floating-cta-group--bottom-left {
    bottom: 24px;
    left: 24px;
}
.unimax-floating-cta-group .unimax-floating-cta {
    position: static;
}

/* Move floating CTA up when chat is also present */
.unimax-chat + .unimax-floating-cta--bottom-right,
.unimax-chat ~ .unimax-floating-cta--bottom-right,
.unimax-chat + .unimax-floating-cta-group--bottom-right,
.unimax-chat ~ .unimax-floating-cta-group--bottom-right {
    bottom: 92px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .unimax-popup__content {
        padding: 24px;
        margin: 16px;
    }
    .unimax-popup__image {
        margin: -24px -24px 16px -24px;
    }
    .unimax-chat__window {
        width: calc(100vw - 32px);
        right: -8px;
        max-height: 70vh;
    }
    .unimax-floating-cta__text {
        display: none;
    }
    .unimax-floating-cta {
        padding: 14px;
        border-radius: 50%;
    }
}
