/**
 * Styles front-end du Copilot Chat
 */

:root {
    --copilot-launcher-bg: #215524;
    --copilot-launcher-icon: #FFFFFF;
    --copilot-launcher-size: 60px;
    --copilot-launcher-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --copilot-z-index: 9999999;
    --animation-duration: 300ms;
}

/* Réinitialisation pour éviter les conflits avec le thème */
.copilot-launcher,
.copilot-chat-window,
.copilot-chat-window * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========================================
   LANCEUR
   ======================================== */

.copilot-launcher {
    position: fixed;
    z-index: var(--copilot-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--copilot-launcher-bg);
    color: var(--copilot-launcher-icon);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--copilot-launcher-shadow);
    outline: none;
}

.copilot-launcher--bubble {
    width: var(--copilot-launcher-size);
    height: var(--copilot-launcher-size);
}

.copilot-launcher--button {
    padding: 12px 24px;
    border-radius: 24px;
    width: auto;
    height: auto;
}

/* Positions du lanceur */
.copilot-launcher--bottom-right {
    bottom: 20px;
    right: 20px;
}

.copilot-launcher--bottom-left {
    bottom: 20px;
    left: 20px;
}

.copilot-launcher--top-right {
    top: 20px;
    right: 20px;
}

.copilot-launcher--top-left {
    top: 20px;
    left: 20px;
}

.copilot-launcher--bottom-center {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.copilot-launcher--top-center {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.copilot-launcher--center-left {
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
}

.copilot-launcher--center-right {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
}

.copilot-launcher--center-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Effets hover et focus */
.copilot-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.copilot-launcher:focus {
    outline: 3px solid rgba(0, 120, 212, 0.5);
    outline-offset: 2px;
}

.copilot-launcher:active {
    transform: scale(0.95);
}

/* Icône du lanceur */
.copilot-launcher__icon {
    width: 60%;
    height: 60%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copilot-launcher__icon svg {
    width: 100%;
    height: 100%;
    color: var(--copilot-launcher-icon);
}

.copilot-launcher--button .copilot-launcher__icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
}

/* Texte du bouton */
.copilot-launcher__text {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Animation pulsée d'attention */
@keyframes copilot-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: var(--copilot-launcher-shadow);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25),
                    0 0 0 8px rgba(33, 85, 36, 0.3);
    }
}

.copilot-launcher--pulse {
    animation: copilot-pulse 2s ease-in-out infinite;
}

/* Arrêter l'animation au hover et focus */
.copilot-launcher--pulse:hover,
.copilot-launcher--pulse:focus {
    animation: none;
}

/* Adaptations pour positions centrées */
.copilot-launcher--bottom-center.copilot-launcher--pulse,
.copilot-launcher--top-center.copilot-launcher--pulse {
    animation: copilot-pulse-centered 2s ease-in-out infinite;
}

.copilot-launcher--center-left.copilot-launcher--pulse,
.copilot-launcher--center-right.copilot-launcher--pulse {
    animation: copilot-pulse-vertical 2s ease-in-out infinite;
}

.copilot-launcher--center-center.copilot-launcher--pulse {
    animation: copilot-pulse 2s ease-in-out infinite;
}

@keyframes copilot-pulse-centered {
    0%, 100% {
        transform: translateX(-50%) scale(1);
        box-shadow: var(--copilot-launcher-shadow);
    }
    50% {
        transform: translateX(-50%) scale(1.1);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25),
                    0 0 0 8px rgba(33, 85, 36, 0.3);
    }
}

@keyframes copilot-pulse-vertical {
    0%, 100% {
        transform: translateY(-50%) scale(1);
        box-shadow: var(--copilot-launcher-shadow);
    }
    50% {
        transform: translateY(-50%) scale(1.1);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25),
                    0 0 0 8px rgba(33, 85, 36, 0.3);
    }
}

/* Désactiver l'animation pulsée en mode réduit */
@media (prefers-reduced-motion: reduce) {
    .copilot-launcher--pulse {
        animation: none;
    }
}

/* ========================================
   FENÊTRE DE CHAT
   ======================================== */

.copilot-chat-window {
    position: fixed;
    z-index: var(--copilot-z-index);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity var(--animation-duration) ease,
                transform var(--animation-duration) ease,
                visibility var(--animation-duration);
}

/* États de visibilité */
.copilot-chat-window--hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.copilot-chat-window--visible {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Animations d'ouverture */
.copilot-chat-window[data-animation="slide"].copilot-chat-window--hidden {
    transform: translateY(20px);
}

.copilot-chat-window[data-animation="fade"].copilot-chat-window--hidden {
    transform: none;
}

.copilot-chat-window[data-animation="scale"].copilot-chat-window--hidden {
    transform: scale(0.9);
}

.copilot-chat-window[data-animation="none"] {
    transition: none;
}

/* Header */
.copilot-chat-window__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--copilot-launcher-bg);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.copilot-chat-window__title {
    font-size: 16px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.copilot-chat-window__close {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    outline: none;
}

.copilot-chat-window__close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.copilot-chat-window__close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.copilot-chat-window__close svg {
    width: 20px;
    height: 20px;
}

/* Container de l'iframe */
.copilot-chat-window__iframe-container {
    flex: 1;
    position: relative;
    background: #f5f5f5;
    overflow: hidden;
}

.copilot-chat-window__iframe-container iframe {
    border: none;
    display: block;
}

/* Loading state */
.copilot-chat-window__iframe-container:not(.copilot-chat-iframe--loaded)::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(0, 120, 212, 0.2);
    border-top-color: var(--copilot-launcher-bg);
    border-radius: 50%;
    animation: copilot-spin 0.8s linear infinite;
}

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

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .copilot-chat-window--mobile-fullscreen {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
    }

    .copilot-launcher {
        bottom: 15px;
        right: 15px;
    }

    .copilot-launcher--bottom-left {
        left: 15px;
    }

    .copilot-launcher--top-right {
        top: 15px;
        right: 15px;
    }

    .copilot-launcher--top-left {
        top: 15px;
        left: 15px;
    }
}

/* ========================================
   ACCESSIBILITÉ
   ======================================== */

/* Mode réduit (préférence utilisateur) */
@media (prefers-reduced-motion: reduce) {
    .copilot-launcher,
    .copilot-chat-window {
        transition: none;
    }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    .copilot-chat-window {
        background: #1e1e1e;
        color: #ffffff;
    }

    .copilot-chat-window__iframe-container {
        background: #2d2d2d;
    }
}

/* Contraste élevé */
@media (prefers-contrast: high) {
    .copilot-launcher:focus {
        outline-width: 4px;
    }

    .copilot-chat-window {
        border: 2px solid currentColor;
    }
}
