/**
 * CRYS Chatbot — Widget frontend
 * Variables :root injectées dynamiquement par le plugin
 */

.crys-chatbot-root {
    position: fixed;
    z-index: 999997;
    font-family: var(--cc-font, inherit);
    font-size: 14px;
    line-height: 1.5;
}
.crys-chatbot-root *,
.crys-chatbot-root *::before,
.crys-chatbot-root *::after { box-sizing: border-box; }

/* ============================ LAUNCHER ============================ */
.cc-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(14, 19, 32, .25);
    transition: transform .25s ease, box-shadow .25s ease;
    position: relative;
    z-index: 2;
}
.cc-launcher:hover { transform: scale(1.08); box-shadow: 0 12px 40px rgba(14, 19, 32, .35); }
.cc-launcher svg { display: block; }
.cc-launcher-close {
    display: none;
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
}
.crys-chatbot-root.is-open .cc-launcher-open { display: none; }
.crys-chatbot-root.is-open .cc-launcher-close { display: block; }

/* Teaser bubble */
.cc-teaser {
    position: absolute;
    bottom: 68px;
    right: 0;
    background: #fff;
    color: var(--cc-dark);
    padding: 10px 36px 10px 14px;
    border-radius: var(--cc-radius);
    box-shadow: 0 8px 30px rgba(14, 19, 32, .15);
    font-size: 13px;
    white-space: nowrap;
    animation: ccTeaserIn .35s ease;
    min-width: 150px;
    white-space: normal;
}
.crys-chatbot-root.cc-rtl .cc-teaser { right: auto; left: 0; padding: 10px 14px 10px 36px; }
.cc-teaser-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #999;
    padding: 2px 6px;
    line-height: 1;
}
.crys-chatbot-root.cc-rtl .cc-teaser-close { right: auto; left: 6px; }
.cc-teaser-close:hover { color: var(--cc-primary); }
@keyframes ccTeaserIn {
    from { opacity: 0; transform: translateY(10px) scale(.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================ WINDOW ============================ */
.cc-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: var(--cc-width);
    max-width: calc(100vw - 32px);
    height: var(--cc-height);
    max-height: calc(100vh - 100px);
    background: var(--cc-bg);
    border-radius: var(--cc-radius);
    box-shadow: 0 20px 60px rgba(14, 19, 32, .25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ccWinIn .3s ease;
}
.crys-chatbot-root.cc-rtl .cc-window { right: auto; left: 0; direction: rtl; }
@keyframes ccWinIn {
    from { opacity: 0; transform: translateY(20px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================ HEADER ============================ */
.cc-header {
    background: var(--cc-dark);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.cc-header-info { display: flex; align-items: center; gap: 12px; }
.cc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--cc-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cc-avatar-default svg { width: 20px; height: 20px; }
.cc-header-name {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: .3px;
}
.cc-header-status {
    font-size: 11px;
    opacity: .7;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.cc-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: ccPulse 2s infinite;
}
@keyframes ccPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
.cc-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    opacity: .7;
    padding: 4px 8px;
    line-height: 1;
    transition: opacity .2s;
}
.cc-close:hover { opacity: 1; }

/* ============================ MESSAGES ============================ */
.cc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--cc-primary) transparent;
}
.cc-messages::-webkit-scrollbar { width: 6px; }
.cc-messages::-webkit-scrollbar-track { background: transparent; }
.cc-messages::-webkit-scrollbar-thumb { background: var(--cc-primary); border-radius: 3px; }

.cc-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: ccMsgIn .25s ease;
}
@keyframes ccMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cc-msg-bot {
    background: var(--cc-bg-bot);
    color: var(--cc-text-bot);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.cc-msg-user {
    background: var(--cc-bg-user);
    color: var(--cc-text-user);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.crys-chatbot-root.cc-rtl .cc-msg-bot {
    align-self: flex-end;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}
.crys-chatbot-root.cc-rtl .cc-msg-user {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 14px;
}
.cc-msg a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}
.cc-msg-bot a { color: var(--cc-primary); }

/* Typing indicator */
.cc-typing {
    padding: 10px 16px 0;
    display: flex;
    gap: 4px;
    align-self: flex-start;
}
.cc-typing span {
    width: 8px;
    height: 8px;
    background: var(--cc-primary);
    border-radius: 50%;
    animation: ccTypingBounce 1.4s infinite ease-in-out both;
}
.cc-typing span:nth-child(1) { animation-delay: -0.32s; }
.cc-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ccTypingBounce {
    0%, 80%, 100% { transform: scale(0); opacity: .5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ============================ LEAD FORM ============================ */
.cc-lead-form {
    background: var(--cc-bg-bot);
    padding: 14px;
    border-radius: 12px;
    margin: 4px 0;
    align-self: stretch;
}
.cc-lead-form h4 {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--cc-dark);
}
.cc-lead-form input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid rgba(0,0,0,.1);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
    background: #fff;
}
.cc-lead-form input:focus {
    outline: none;
    border-color: var(--cc-primary);
}
.cc-lead-form .cc-lead-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.cc-lead-form button {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity .2s;
}
.cc-lead-form button.primary {
    background: var(--cc-primary);
    color: #fff;
}
.cc-lead-form button.secondary {
    background: transparent;
    color: var(--cc-dark);
    border: 1px solid rgba(0,0,0,.15);
}
.cc-lead-form button:hover { opacity: .85; }
.cc-lead-form button:disabled { opacity: .5; cursor: wait; }

/* ============================ INPUT ============================ */
.cc-input {
    border-top: 1px solid rgba(0,0,0,.06);
    padding: 10px 10px 10px 14px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--cc-bg);
}
.cc-input-field {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    padding: 8px 0;
    background: transparent;
    color: var(--cc-text-bot);
    max-height: 100px;
    line-height: 1.4;
}
.cc-send {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--cc-primary);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s;
    flex-shrink: 0;
}
.cc-send:hover { transform: scale(1.05); }
.cc-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.crys-chatbot-root.cc-rtl .cc-send svg { transform: scaleX(-1); }

.cc-footer {
    padding: 6px 14px 10px;
    text-align: center;
    font-size: 10px;
    color: #999;
    background: var(--cc-bg);
}
.cc-footer a { color: var(--cc-primary); text-decoration: none; }

/* ============================ RESPONSIVE ============================ */
@media (max-width: 480px) {
    .cc-window {
        position: fixed;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
