/**
 * Teams Chat Widget Styles
 *
 * Privacy-first floating chat button with smooth animations.
 * No external resources loaded until user interaction.
 *
 * @package WP_Profis
 * @since 1.0.0
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --wpprofis-teams-primary: #5558af;
    --wpprofis-teams-primary-hover: #464899;
    --wpprofis-teams-button-size: 56px;
    --wpprofis-teams-button-size-mobile: 48px;
    --wpprofis-teams-offset: 24px;
    --wpprofis-teams-offset-mobile: 16px;
    --wpprofis-teams-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    --wpprofis-teams-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.12);
    --wpprofis-teams-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Widget Container
   ========================================================================== */

.wpprofis-teams-chat {
    position: fixed;
    bottom: var(--wpprofis-teams-offset);
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
}

.wpprofis-teams-chat--right {
    right: var(--wpprofis-teams-offset);
}

.wpprofis-teams-chat--left {
    left: var(--wpprofis-teams-offset);
}

/* ==========================================================================
   Chat Button
   ========================================================================== */

.wpprofis-teams-chat__button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--wpprofis-teams-button-size);
    height: var(--wpprofis-teams-button-size);
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--wpprofis-teams-primary);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--wpprofis-teams-shadow);
    transition: transform var(--wpprofis-teams-transition),
        background-color var(--wpprofis-teams-transition),
        box-shadow var(--wpprofis-teams-transition);
}

.wpprofis-teams-chat__button:hover,
.wpprofis-teams-chat__button:focus-visible {
    background: var(--wpprofis-teams-primary-hover);
    box-shadow: var(--wpprofis-teams-shadow-hover);
    transform: scale(1.05);
}

.wpprofis-teams-chat__button:focus-visible {
    outline: 3px solid var(--wpprofis-teams-primary);
    outline-offset: 3px;
}

.wpprofis-teams-chat__button:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Icon
   ========================================================================== */

.wpprofis-teams-chat__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--wpprofis-teams-transition);
}

.wpprofis-teams-chat__icon svg {
    display: block;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.wpprofis-teams-chat__loading {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.wpprofis-teams-chat__spinner {
    display: block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wpprofis-teams-spin 0.8s linear infinite;
}

@keyframes wpprofis-teams-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Loading active state */
.wpprofis-teams-chat--loading .wpprofis-teams-chat__icon {
    opacity: 0;
}

.wpprofis-teams-chat--loading .wpprofis-teams-chat__loading {
    display: block;
}

.wpprofis-teams-chat--loading .wpprofis-teams-chat__button {
    pointer-events: none;
}

/* ==========================================================================
   Tooltip
   ========================================================================== */

.wpprofis-teams-chat__tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 50%;
    transform: translateX(50%);
    padding: 6px 12px;
    background: #1f1f1f;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--wpprofis-teams-transition),
        visibility var(--wpprofis-teams-transition);
    pointer-events: none;
}

.wpprofis-teams-chat__tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f1f1f;
}

.wpprofis-teams-chat__button:hover+.wpprofis-teams-chat__tooltip,
.wpprofis-teams-chat__button:focus-visible+.wpprofis-teams-chat__tooltip {
    opacity: 1;
    visibility: visible;
}

/* Left position tooltip adjustment */
.wpprofis-teams-chat--left .wpprofis-teams-chat__tooltip {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

/* ==========================================================================
   Hidden State (after consent, Microsoft widget takes over)
   ========================================================================== */

.wpprofis-teams-chat--hidden {
    display: none !important;
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .wpprofis-teams-chat {
        bottom: var(--wpprofis-teams-offset-mobile);
    }

    .wpprofis-teams-chat--right {
        right: var(--wpprofis-teams-offset-mobile);
    }

    .wpprofis-teams-chat--left {
        left: var(--wpprofis-teams-offset-mobile);
    }

    .wpprofis-teams-chat__button {
        width: var(--wpprofis-teams-button-size-mobile);
        height: var(--wpprofis-teams-button-size-mobile);
    }

    .wpprofis-teams-chat__icon svg {
        width: 24px;
        height: 24px;
    }

    /* Hide tooltip on mobile (use title attribute instead) */
    .wpprofis-teams-chat__tooltip {
        display: none;
    }
}

/* ==========================================================================
   Consent Popup
   ========================================================================== */

.wpprofis-teams-chat__popup {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity var(--wpprofis-teams-transition),
        visibility var(--wpprofis-teams-transition),
        transform var(--wpprofis-teams-transition);
    z-index: 10000;
}

.wpprofis-teams-chat--popup-visible .wpprofis-teams-chat__popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Left position popup adjustment */
.wpprofis-teams-chat--left .wpprofis-teams-chat__popup {
    right: auto;
    left: 0;
}

.wpprofis-teams-chat__popup-content {
    padding: 20px;
}

.wpprofis-teams-chat__popup-title {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
    color: #1f1f1f;
    line-height: 1.3;
}

.wpprofis-teams-chat__popup-text {
    margin: 0 0 16px;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.wpprofis-teams-chat__popup-links {
    margin-bottom: 20px;
}

.wpprofis-teams-chat__popup-links a {
    font-size: 13px;
    color: var(--wpprofis-teams-primary);
    text-decoration: none;
}

.wpprofis-teams-chat__popup-links a:hover {
    text-decoration: underline;
}

.wpprofis-teams-chat__popup-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.wpprofis-teams-chat__popup-decline,
.wpprofis-teams-chat__popup-accept {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color var(--wpprofis-teams-transition),
        transform 100ms ease;
}

.wpprofis-teams-chat__popup-decline {
    background: transparent;
    border: 1px solid #ccc;
    color: #555;
}

.wpprofis-teams-chat__popup-decline:hover {
    background: #f5f5f5;
}

.wpprofis-teams-chat__popup-accept {
    background: var(--wpprofis-teams-primary);
    border: none;
    color: #fff;
}

.wpprofis-teams-chat__popup-accept:hover {
    background: var(--wpprofis-teams-primary-hover);
}

.wpprofis-teams-chat__popup-decline:active,
.wpprofis-teams-chat__popup-accept:active {
    transform: scale(0.97);
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    .wpprofis-teams-chat__button,
    .wpprofis-teams-chat__popup {
        transition: none;
    }

    .wpprofis-teams-chat__spinner {
        animation: none;
    }
}

/* ==========================================================================
   Mobile Responsive Popup
   ========================================================================== */

@media (max-width: 768px) {
    .wpprofis-teams-chat__popup {
        position: fixed;
        bottom: 80px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
    }

    .wpprofis-teams-chat--left .wpprofis-teams-chat__popup {
        right: 16px;
        left: 16px;
    }

    .wpprofis-teams-chat__popup-actions {
        flex-direction: column;
    }

    .wpprofis-teams-chat__popup-decline,
    .wpprofis-teams-chat__popup-accept {
        width: 100%;
        text-align: center;
    }
}