/* Yoda Support Widget - Etnadetox */

.yoda-support {
    --ys-green-dark: #29421D;
    --ys-green: #598930;
    --ys-green-light: #6fa33a;
    --ys-text: #1d2b14;
    --ys-text-muted: #5b6b52;
    --ys-surface: #ffffff;
    --ys-border: rgba(41, 66, 29, 0.12);
    --ys-shadow: 0 24px 60px -12px rgba(20, 33, 12, 0.35);
    --ys-fab-size: 60px;
    --ys-z: 2147483000;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: var(--ys-z);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ys-text);
}

/* Reposition back-to-top to avoid overlap */
#back-to-top {
    right: 24px !important;
    bottom: 96px !important;
    z-index: calc(var(--ys-z) - 1);
}

/* Scrim (mobile) */
.yoda-support__scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 33, 12, 0.45);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.yoda-support[data-state="open"] .yoda-support__scrim {
    display: block;
    opacity: 1;
}

/* FAB */
.yoda-support__fab {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ys-fab-size);
    height: var(--ys-fab-size);
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #2f5322, var(--ys-green-dark));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(41, 66, 29, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    opacity: 0;
    transform: scale(0.8);
    animation: ys-fab-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s forwards;
}

.yoda-support__fab:hover {
    transform: translateY(-2px) scale(1);
    box-shadow: 0 14px 36px rgba(41, 66, 29, 0.42);
}

.yoda-support__fab:focus-visible {
    box-shadow: 0 0 0 3px rgba(89, 137, 48, 0.4), 0 10px 30px rgba(41, 66, 29, 0.35);
}

.yoda-support[data-state="open"] .yoda-support__fab {
    background: var(--ys-green-dark);
}

.yoda-support__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--ys-green);
    opacity: 0;
    pointer-events: none;
}

.yoda-support__ring.is-pulsing {
    animation: ys-ring-pulse 2s ease-out 3;
}

.yoda-support__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--ys-green-light);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(41, 66, 29, 0.3);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s, transform 0.3s;
}

.yoda-support__badge.is-visible {
    opacity: 1;
    transform: scale(1);
}

.yoda-support__fab-icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.yoda-support__fab-icon--chat {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.yoda-support__fab-icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.yoda-support[data-state="open"] .yoda-support__fab-icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.yoda-support[data-state="open"] .yoda-support__fab-icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Nudge bubble */
.yoda-support__nudge {
    position: absolute;
    right: calc(var(--ys-fab-size) + 16px);
    bottom: 8px;
    max-width: 220px;
    opacity: 0;
    transform: translateX(12px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.yoda-support__nudge.is-visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.yoda-support__nudge-inner {
    position: relative;
    padding: 12px 36px 12px 16px;
    background: var(--ys-surface);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(20, 33, 12, 0.18);
    border: 1px solid var(--ys-border);
    cursor: pointer;
}

.yoda-support__nudge-inner::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 18px;
    width: 12px;
    height: 12px;
    background: var(--ys-surface);
    border-right: 1px solid var(--ys-border);
    border-bottom: 1px solid var(--ys-border);
    transform: rotate(-45deg);
}

.yoda-support__nudge-title {
    display: block;
    font-family: "Lora", Georgia, serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--ys-green-dark);
    margin-bottom: 2px;
}

.yoda-support__nudge-text {
    display: block;
    font-size: 13px;
    color: var(--ys-text-muted);
}

.yoda-support__nudge-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ys-text-muted);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.yoda-support__nudge-close:hover {
    background: rgba(41, 66, 29, 0.08);
    color: var(--ys-text);
}

/* Panel */
.yoda-support__panel {
    position: absolute;
    right: 0;
    bottom: calc(var(--ys-fab-size) + 16px);
    width: 380px;
    max-height: min(620px, calc(100vh - 120px));
    background: var(--ys-surface);
    border-radius: 20px;
    box-shadow: var(--ys-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.yoda-support__panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.yoda-support__panel.is-closing {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition-duration: 0.2s;
}

/* Header */
.yoda-support__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 20px 16px;
    background: linear-gradient(135deg, #2f5322, var(--ys-green-dark));
    color: #fff;
}

.yoda-support__header-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.yoda-support__avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.yoda-support__title {
    margin: 0 0 4px;
    font-family: "Lora", Georgia, serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: #fff;
}

.yoda-support__subtitle {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.yoda-support__online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7dd956;
    box-shadow: 0 0 0 2px rgba(125, 217, 86, 0.3);
    flex-shrink: 0;
}

.yoda-support__subtitle-sep {
    opacity: 0.6;
}

.yoda-support__close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.yoda-support__close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.yoda-support__close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* Body */
.yoda-support__body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.yoda-support__form[hidden],
.yoda-support__success[hidden] {
    display: none !important;
}

/* Fields */
.yoda-support__field {
    margin-bottom: 16px;
}

.yoda-support__label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ys-text);
}

.yoda-support__input,
.yoda-support__select,
.yoda-support__textarea {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--ys-text);
    background: var(--ys-surface);
    border: 1px solid var(--ys-border);
    border-radius: 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    box-sizing: border-box;
}

.yoda-support__input:focus,
.yoda-support__select:focus,
.yoda-support__textarea:focus {
    border-color: var(--ys-green);
    box-shadow: 0 0 0 3px rgba(89, 137, 48, 0.25);
}

.yoda-support__input.is-invalid,
.yoda-support__select.is-invalid,
.yoda-support__textarea.is-invalid {
    border-color: #c0392b;
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15);
}

.yoda-support__select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235b6b52' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.yoda-support__textarea {
    resize: vertical;
    min-height: 100px;
}

.yoda-support__honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.yoda-support__turnstile {
    margin-bottom: 12px;
    min-height: 65px;
}

.yoda-support__error {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: 13px;
    color: #c0392b;
    background: rgba(192, 57, 43, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(192, 57, 43, 0.15);
}

.yoda-support__privacy {
    margin: 0 0 14px;
    font-size: 12px;
    color: var(--ys-text-muted);
    line-height: 1.4;
}

.yoda-support__privacy a {
    color: var(--ys-green);
    text-decoration: underline;
}

.yoda-support__privacy a:hover {
    color: var(--ys-green-dark);
}

/* Submit */
.yoda-support__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, var(--ys-green), #4a7a28);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    box-shadow: 0 4px 14px rgba(89, 137, 48, 0.35);
}

.yoda-support__submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(89, 137, 48, 0.42);
}

.yoda-support__submit:focus-visible {
    outline: 2px solid var(--ys-green);
    outline-offset: 2px;
}

.yoda-support__submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.yoda-support__submit.is-loading .yoda-support__submit-text {
    opacity: 0.6;
}

.yoda-support__submit-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ys-spin 0.7s linear infinite;
}

.yoda-support__submit.is-loading .yoda-support__submit-spinner {
    display: block;
}

/* Success state */
.yoda-support__success {
    text-align: center;
    padding: 24px 8px;
}

.yoda-support__success-icon {
    margin-bottom: 16px;
}

.yoda-support__success-circle {
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    animation: ys-circle-draw 0.5s ease forwards 0.1s;
}

.yoda-support__success-check {
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: ys-check-draw 0.4s ease forwards 0.5s;
}

.yoda-support__success-text {
    margin: 0 0 20px;
    font-size: 16px;
    font-weight: 500;
    color: var(--ys-text);
    line-height: 1.5;
}

.yoda-support__success-close {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: var(--ys-green-dark);
    background: transparent;
    border: 1px solid var(--ys-border);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.yoda-support__success-close:hover {
    background: rgba(41, 66, 29, 0.05);
    border-color: var(--ys-green);
}

/* Animations */
@keyframes ys-fab-in {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes ys-ring-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

@keyframes ys-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ys-circle-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes ys-check-draw {
    to {
        stroke-dashoffset: 0;
    }
}

/* Mobile bottom-sheet */
@media (max-width: 576px) {
    .yoda-support {
        --ys-fab-size: 56px;
        right: 16px;
        bottom: 16px;
    }

    #back-to-top {
        right: 16px !important;
        bottom: 84px !important;
    }

    .yoda-support__nudge {
        right: calc(var(--ys-fab-size) + 12px);
        max-width: 180px;
    }

    .yoda-support__panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        transform-origin: bottom center;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .yoda-support[data-state="open"] .yoda-support__fab {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.8);
    }

    .yoda-support__body {
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0));
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .yoda-support__fab,
    .yoda-support__panel,
    .yoda-support__nudge,
    .yoda-support__scrim,
    .yoda-support__fab-icon,
    .yoda-support__ring,
    .yoda-support__badge {
        animation: none !important;
        transition: opacity 0.01s !important;
    }

    .yoda-support__fab {
        opacity: 1;
        transform: none;
    }

    .yoda-support__ring.is-pulsing {
        display: none;
    }

    .yoda-support__success-circle,
    .yoda-support__success-check {
        animation: none !important;
        stroke-dashoffset: 0;
    }
}
