/* Yoga Sadharma Anandana — Full-height right sidebar chat */

:root {
    --ysa-chat-primary: #2d6a4f;
    --ysa-chat-primary-dark: #1b4332;
    --ysa-chat-accent: #c8b5a6;
    --ysa-chat-accent-light: #f3ece4;
    --ysa-chat-bg: #ffffff;
    --ysa-chat-surface: #faf9f7;
    --ysa-chat-text: #222222;
    --ysa-chat-muted: #6b7280;
    --ysa-chat-border: #e8e2db;
    --ysa-chat-width: 400px;
    --ysa-chat-z: 10050;
}

.ysa-chat-root {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ysa-chat-text);
}

/* Backdrop */
.ysa-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(21, 31, 55, 0.35);
    z-index: calc(var(--ysa-chat-z) - 2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.ysa-chat-root.is-open .ysa-chat-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* Welcome teaser card */
.ysa-chat-teaser {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: #faf8f5;
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(21, 31, 55, 0.2);
    z-index: calc(var(--ysa-chat-z) - 1);
    overflow: hidden;
    border: 1px solid var(--ysa-chat-border);
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ysa-chat-root.is-teaser-open .ysa-chat-teaser {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ysa-chat-teaser[hidden] {
    display: block !important;
}

.ysa-chat-teaser-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ysa-chat-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: background 0.2s;
}

.ysa-chat-teaser-close:hover {
    background: #fff;
    color: var(--ysa-chat-text);
}

.ysa-chat-teaser-hero {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(180deg, #f5f0ea 0%, #ebe4dc 100%);
}

.ysa-chat-teaser-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 8%;
    display: block;
}

.ysa-chat-teaser-body {
    padding: 20px 22px 24px;
    text-align: center;
    background: #faf8f5;
}

.ysa-chat-teaser-title {
    margin: 0 0 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--ysa-chat-primary-dark);
    line-height: 1.35;
}

.ysa-chat-teaser-desc {
    margin: 0 0 18px;
    font-size: 14px;
    color: var(--ysa-chat-muted);
    line-height: 1.55;
}

.ysa-chat-teaser-start {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--ysa-chat-primary) 0%, var(--ysa-chat-primary-dark) 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(45, 106, 79, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}

.ysa-chat-teaser-start:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(45, 106, 79, 0.45);
}

/* Floating launcher — Yoga Anandana AI animated icon */
.ysa-chat-toggle {
    position: fixed;
    right: 14px;
    bottom: 20px;
    width: auto;
    height: auto;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    box-shadow: none;
    z-index: var(--ysa-chat-z);
    display: block;
    line-height: 1.2;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ysa-chat-launcher {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.ysa-chat-launcher-avatar {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--ysa-chat-primary);
    background: #111;
    box-shadow: 0 6px 24px rgba(45, 106, 79, 0.45);
    animation: ysa-sway 2.8s ease-in-out infinite;
}

.ysa-chat-launcher-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 12%;
    display: block;
    pointer-events: none;
    user-select: none;
}

.ysa-chat-launcher-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(45, 106, 79, 0.55);
    animation: ysa-ring-pulse 2s ease-out infinite;
    pointer-events: none;
}

.ysa-chat-launcher-ring--delay {
    animation-delay: 1s;
}

.ysa-chat-launcher-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--ysa-chat-primary) 0%, var(--ysa-chat-primary-dark) 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 20px;
    box-shadow: 0 4px 14px rgba(45, 106, 79, 0.35);
    white-space: nowrap;
    animation: ysa-label-float 2.8s ease-in-out infinite;
}

.ysa-chat-launcher-dot {
    width: 7px;
    height: 7px;
    background: #6ee7a0;
    border-radius: 50%;
    flex-shrink: 0;
    animation: ysa-dot-blink 1.4s ease-in-out infinite;
}

.ysa-chat-launcher-wave {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 14px;
    margin-top: -2px;
}

.ysa-chat-launcher-wave span {
    display: block;
    width: 4px;
    height: 8px;
    background: var(--ysa-chat-primary);
    border-radius: 3px;
    opacity: 0.7;
    animation: ysa-wave-bar 1.1s ease-in-out infinite;
}

.ysa-chat-launcher-wave span:nth-child(2) {
    animation-delay: 0.15s;
    height: 12px;
}

.ysa-chat-launcher-wave span:nth-child(3) {
    animation-delay: 0.3s;
}

.ysa-chat-toggle:hover .ysa-chat-launcher-avatar {
    animation-duration: 1.6s;
}

.ysa-chat-toggle:hover {
    transform: scale(1.04);
}

.ysa-chat-toggle:focus {
    outline: none;
}

.ysa-chat-toggle:focus .ysa-chat-launcher-label {
    outline: 2px solid var(--ysa-chat-primary);
    outline-offset: 3px;
}

.ysa-chat-root.is-open .ysa-chat-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.85);
}

@keyframes ysa-sway {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    20% { transform: translateY(-5px) rotate(-3deg); }
    50% { transform: translateY(-2px) rotate(0deg); }
    80% { transform: translateY(-5px) rotate(3deg); }
}

@keyframes ysa-ring-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.35); opacity: 0; }
}

@keyframes ysa-label-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes ysa-dot-blink {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(110, 231, 160, 0.6); }
    50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(110, 231, 160, 0); }
}

@keyframes ysa-wave-bar {
    0%, 100% { transform: scaleY(0.5); opacity: 0.4; }
    50% { transform: scaleY(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .ysa-chat-launcher-avatar,
    .ysa-chat-launcher-ring,
    .ysa-chat-launcher-label,
    .ysa-chat-launcher-dot,
    .ysa-chat-launcher-wave span {
        animation: none !important;
    }
}

/* Full-height right sidebar */
.ysa-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--ysa-chat-width);
    height: 100vh;
    height: 100dvh;
    background: var(--ysa-chat-bg);
    z-index: calc(var(--ysa-chat-z) - 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--ysa-chat-border);
    box-shadow: -8px 0 40px rgba(21, 31, 55, 0.12);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.ysa-chat-root.is-open .ysa-chat-panel {
    transform: translateX(0);
}

.ysa-chat-panel[hidden] {
    display: flex !important;
}

/* Header */
.ysa-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--ysa-chat-primary) 0%, var(--ysa-chat-primary-dark) 100%);
    color: #fff;
    flex-shrink: 0;
    min-height: 72px;
}

.ysa-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ysa-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 2px solid rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.ysa-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ysa-chat-avatar--icon {
    background: #111;
    border: 2px solid rgba(255, 255, 255, 0.35);
    overflow: hidden;
}

.ysa-chat-avatar--icon img {
    object-fit: cover;
    object-position: center 12%;
}

.ysa-chat-title {
    display: block;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.ysa-chat-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.92;
    margin-top: 2px;
}

.ysa-chat-online {
    width: 8px;
    height: 8px;
    background: #6ee7a0;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(110, 231, 160, 0.35);
}

.ysa-chat-close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ysa-chat-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Messages area */
.ysa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: var(--ysa-chat-surface);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.ysa-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.ysa-chat-messages::-webkit-scrollbar-thumb {
    background: var(--ysa-chat-border);
    border-radius: 4px;
}

.ysa-chat-msg-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 100%;
}

.ysa-chat-msg-row--user {
    flex-direction: row-reverse;
}

.ysa-chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--ysa-chat-accent-light);
}

.ysa-chat-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ysa-chat-msg {
    max-width: calc(100% - 40px);
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14.5px;
    line-height: 1.55;
}

.ysa-chat-msg--bot {
    background: #fff;
    border: 1px solid var(--ysa-chat-border);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ysa-chat-msg--bot strong {
    color: var(--ysa-chat-primary-dark);
    font-weight: 600;
}

.ysa-chat-msg--bot ul,
.ysa-chat-msg--bot ol {
    margin: 8px 0 4px;
    padding-left: 18px;
}

.ysa-chat-msg--bot li {
    margin-bottom: 6px;
}

.ysa-chat-msg--bot p {
    margin: 0 0 8px;
}

.ysa-chat-msg--bot p:last-child {
    margin-bottom: 0;
}

/* Clickable link chips inside bot messages */
.ysa-chat-link-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--ysa-chat-border);
}

.ysa-chat-link-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    min-height: 38px;
}

.ysa-chat-link-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.ysa-chat-link-chip--primary {
    background: var(--ysa-chat-primary);
    color: #fff !important;
}

.ysa-chat-link-chip--primary:hover {
    background: var(--ysa-chat-primary-dark);
    color: #fff !important;
}

.ysa-chat-link-chip--wa {
    background: #25d366;
    color: #fff !important;
}

.ysa-chat-link-chip--wa:hover {
    background: #1da851;
    color: #fff !important;
}

.ysa-chat-msg--user {
    background: linear-gradient(135deg, var(--ysa-chat-primary) 0%, var(--ysa-chat-primary-dark) 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(45, 106, 79, 0.25);
}

.ysa-chat-msg--typing {
    background: #fff;
    border: 1px solid var(--ysa-chat-border);
    color: var(--ysa-chat-muted);
    padding: 12px 18px;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.ysa-chat-typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.ysa-chat-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--ysa-chat-muted);
    border-radius: 50%;
    animation: ysa-dot 1.2s infinite ease-in-out;
}

.ysa-chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.ysa-chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ysa-dot {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick reply chips */
.ysa-chat-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 4px 4px;
}

.ysa-chat-chip {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--ysa-chat-primary);
    background: #fff;
    color: var(--ysa-chat-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ysa-chat-chip:hover {
    background: var(--ysa-chat-primary);
    color: #fff;
}

/* CTA buttons inside bot messages area */
.ysa-chat-cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.ysa-chat-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.ysa-chat-cta--primary {
    background: var(--ysa-chat-primary);
    color: #fff !important;
}

.ysa-chat-cta--primary:hover {
    background: var(--ysa-chat-primary-dark);
    color: #fff !important;
}

.ysa-chat-cta--wa {
    background: #25d366;
    color: #fff !important;
}

.ysa-chat-cta--wa:hover {
    background: #1da851;
    color: #fff !important;
}

/* Lead capture — compact mobile bar */
.ysa-chat-lead {
    padding: 8px 12px 6px;
    background: #fff;
    border-top: 1px solid var(--ysa-chat-border);
    flex-shrink: 0;
}

.ysa-chat-lead-form {
    margin: 0;
}

.ysa-chat-lead-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ysa-chat-lead-row input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1.5px solid var(--ysa-chat-border);
    border-radius: 24px;
    font-size: 14px;
    box-sizing: border-box;
    background: var(--ysa-chat-surface);
    height: 42px;
}

.ysa-chat-lead-row input:focus {
    outline: none;
    border-color: var(--ysa-chat-primary);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.1);
}

.ysa-chat-lead-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ysa-chat-primary) 0%, var(--ysa-chat-primary-dark) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.ysa-chat-lead-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ysa-chat-lead-send:not(:disabled):hover {
    transform: scale(1.05);
}

.ysa-chat-lead-skip {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 4px 0;
    border: none;
    background: transparent;
    color: var(--ysa-chat-muted);
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ysa-chat-lead-skip:hover {
    color: var(--ysa-chat-primary);
}

/* Input area */
.ysa-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--ysa-chat-border);
    background: #fff;
    flex-shrink: 0;
}

.ysa-chat-input-wrap textarea {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--ysa-chat-border);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    max-height: 120px;
    line-height: 1.45;
    background: var(--ysa-chat-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ysa-chat-input-wrap textarea:focus {
    outline: none;
    border-color: var(--ysa-chat-primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
    background: #fff;
}

.ysa-chat-send {
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ysa-chat-primary) 0%, var(--ysa-chat-primary-dark) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.ysa-chat-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ysa-chat-send:not(:disabled):hover {
    transform: scale(1.05);
}

/* Footer */
.ysa-chat-footer {
    padding: 10px 16px 14px;
    text-align: center;
    font-size: 12px;
    color: var(--ysa-chat-muted);
    background: #fff;
    flex-shrink: 0;
    border-top: 1px solid var(--ysa-chat-border);
}

.ysa-chat-footer a {
    color: var(--ysa-chat-primary);
    text-decoration: none;
    font-weight: 600;
}

.ysa-chat-footer a:hover {
    text-decoration: underline;
}

body.ysa-chat-open {
    overflow: hidden;
}

/* Mobile: full width */
@media (max-width: 767px) {
    :root {
        --ysa-chat-width: 100%;
    }

    .ysa-chat-toggle {
        right: 10px;
        bottom: 20px;
    }

    .ysa-chat-launcher-avatar {
        width: 68px;
        height: 68px;
    }

    .ysa-chat-launcher-label {
        font-size: 10px;
        padding: 5px 10px;
    }

    .ysa-chat-teaser {
        right: 12px;
        left: 12px;
        bottom: auto;
        top: 50%;
        transform: translateY(-50%) scale(0.96);
        width: auto;
        max-width: none;
    }

    .ysa-chat-root.is-teaser-open .ysa-chat-teaser {
        transform: translateY(-50%) scale(1);
    }

    .ysa-chat-teaser-hero {
        height: 180px;
    }

    .ysa-chat-panel {
        width: 100%;
    }
}

/* Desktop: optional page squeeze when chat open on large screens */
@media (min-width: 1200px) {
    body.ysa-chat-open {
        margin-right: 0;
    }
}
