/* EduPlus website chat widgets — Franky AI + separate WhatsApp floater */

.edu-float-dock {
    --chat-z: 9000;
    --chat-accent: var(--brand-red, #dc4c0b);
    --chat-accent-soft: var(--brand-red-soft, #e85a1a);
    --chat-navy: var(--navy, #0f2557);
    --chat-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
    --wa-green: #25d366;
    --wa-green-dark: #1ebe57;
    position: fixed;
    right: clamp(16px, 3vw, 28px);
    bottom: clamp(16px, 3vw, 28px);
    z-index: var(--chat-z);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: var(--font, 'Plus Jakarta Sans', system-ui, sans-serif);
}

/* ── Franky AI chat ── */

.edu-chat {
    position: relative;
}

.edu-chat__launcher {
    position: relative;
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(145deg, var(--chat-accent-soft) 0%, var(--chat-navy) 55%, #1e40af 100%);
    box-shadow:
        0 8px 24px rgba(220, 76, 11, 0.35),
        0 4px 12px rgba(15, 37, 87, 0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.edu-chat__launcher:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 12px 32px rgba(220, 76, 11, 0.4),
        0 6px 16px rgba(15, 37, 87, 0.28);
}

.edu-chat__launcher-icon--close {
    display: none;
    font-size: 1.15rem;
}

.edu-chat.is-open .edu-chat__launcher-icon--open { display: none; }
.edu-chat.is-open .edu-chat__launcher-icon--close { display: block; }

.edu-chat__launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.edu-chat__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 14px);
    width: min(380px, calc(100vw - 32px));
    max-height: min(560px, calc(100vh - 120px));
    background: #fff;
    border-radius: 20px;
    border: 1px solid var(--gray-200, #e2e8f0);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: eduChatSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.edu-chat__panel[hidden] {
    display: none !important;
}

@keyframes eduChatSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.edu-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, var(--chat-navy) 0%, #1a3d8f 100%);
    color: #fff;
}

.edu-chat__header-main {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.edu-chat__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--chat-accent-soft), var(--chat-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.edu-chat__name {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.edu-chat__status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    opacity: 0.88;
    margin-top: 0.1rem;
}

.edu-chat__status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
}

.edu-chat__close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.edu-chat__close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.edu-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    scroll-behavior: smooth;
}

.edu-chat__msg {
    max-width: 88%;
    padding: 0.65rem 0.85rem;
    border-radius: 16px;
    font-size: 0.86rem;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.edu-chat__msg--bot {
    align-self: flex-start;
    background: #fff;
    color: var(--black, #0b0f19);
    border: 1px solid var(--gray-200, #e2e8f0);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.edu-chat__msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--blue-bright, #2563eb) 0%, var(--blue-deep, #1d4ed8) 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.edu-chat__msg-time {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.62rem;
    opacity: 0.55;
}

.edu-chat__typing {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 1rem 0.5rem;
    background: #fff;
}

.edu-chat__typing[hidden] {
    display: none !important;
}

.edu-chat__typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-400, #94a3b8);
    animation: eduChatBounce 1.2s infinite ease-in-out;
}

.edu-chat__typing-dot:nth-child(2) { animation-delay: 0.15s; }
.edu-chat__typing-dot:nth-child(3) { animation-delay: 0.3s; }

.edu-chat__typing-label {
    font-size: 0.72rem;
    color: var(--gray-600, #475569);
    margin-left: 0.25rem;
}

.edu-chat__msg--agent {
    align-self: flex-start;
    background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%);
    color: var(--black, #0b0f19);
    border: 1px solid #bbf7d0;
    border-bottom-left-radius: 6px;
}

.edu-chat__msg-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #16a34a;
    margin-bottom: 0.2rem;
}

.edu-chat__msg-body {
    display: block;
    white-space: pre-wrap;
}

@keyframes eduChatBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.edu-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--gray-200, #e2e8f0);
    background: #fff;
}

.edu-chat__hp {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

.edu-chat__input {
    flex: 1;
    min-height: 42px;
    max-height: 120px;
    resize: none;
    border: 1px solid var(--gray-200, #e2e8f0);
    border-radius: 14px;
    padding: 0.6rem 0.85rem;
    font-family: inherit;
    font-size: 0.86rem;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.edu-chat__input:focus {
    border-color: var(--blue-bright, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.edu-chat__send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--chat-accent-soft) 0%, var(--blue-bright, #2563eb) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.edu-chat__send:hover:not(:disabled) {
    transform: scale(1.05);
}

.edu-chat__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Soft nudge inside AI chat toward the separate WhatsApp floater */
.edu-chat__wa-nudge {
    align-self: stretch;
    margin-top: 0.15rem;
    padding: 0.65rem 0.75rem;
    border-radius: 12px;
    border: 1px solid #bbf7d0;
    background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.edu-chat__wa-nudge-text {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--gray-700, #334155);
}

.edu-chat__wa-nudge-btn {
    border: none;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    background: var(--wa-green);
    color: #fff;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background 0.2s, transform 0.2s;
}

.edu-chat__wa-nudge-btn:hover {
    background: var(--wa-green-dark);
    transform: translateY(-1px);
}

/* ── Separate WhatsApp floater ── */

.edu-wa {
    position: relative;
}

.edu-wa__launcher {
    position: relative;
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(145deg, #34e078 0%, var(--wa-green) 45%, #128c7e 100%);
    box-shadow:
        0 8px 22px rgba(37, 211, 102, 0.4),
        0 3px 10px rgba(18, 140, 126, 0.25);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
}

.edu-wa__launcher:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 12px 28px rgba(37, 211, 102, 0.45),
        0 5px 14px rgba(18, 140, 126, 0.3);
}

.edu-wa.is-attention .edu-wa__launcher {
    animation: eduWaPulse 1.4s ease-in-out 3;
}

@keyframes eduWaPulse {
    0%, 100% { box-shadow: 0 8px 22px rgba(37, 211, 102, 0.4), 0 0 0 0 rgba(37, 211, 102, 0.45); }
    50% { box-shadow: 0 8px 22px rgba(37, 211, 102, 0.55), 0 0 0 12px rgba(37, 211, 102, 0); }
}

.edu-wa__launcher-icon--close {
    display: none;
    font-size: 1.05rem;
}

.edu-wa.is-open .edu-wa__launcher-icon--open { display: none; }
.edu-wa.is-open .edu-wa__launcher-icon--close { display: block; }

.edu-wa__launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.edu-wa__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 14px);
    width: min(340px, calc(100vw - 32px));
    background: #fff;
    border-radius: 20px;
    border: 1px solid #bbf7d0;
    box-shadow: var(--chat-shadow);
    overflow: hidden;
    transform-origin: bottom right;
    animation: eduChatSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.edu-wa__panel[hidden] {
    display: none !important;
}

.edu-wa__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: linear-gradient(135deg, #075e54 0%, #128c7e 55%, #25d366 100%);
    color: #fff;
}

.edu-wa__header-main {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.edu-wa__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.edu-wa__name {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.edu-wa__status {
    font-size: 0.72rem;
    opacity: 0.9;
    margin-top: 0.12rem;
}

.edu-wa__close {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.edu-wa__close:hover {
    background: rgba(255, 255, 255, 0.24);
}

.edu-wa__body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: linear-gradient(180deg, #f0fdf4 0%, #fff 42%);
}

.edu-wa__intro {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--gray-700, #334155);
}

.edu-wa__ref {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 10px;
    background: #ecfdf5;
    border: 1px dashed #86efac;
}

.edu-wa__ref-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #15803d;
}

.edu-wa__ref-code {
    font-size: 0.78rem;
    font-weight: 700;
    color: #166534;
}

.edu-wa__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.edu-wa__action {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.8rem;
    border-radius: 14px;
    border: 1px solid #d1fae5;
    background: #fff;
    color: inherit;
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.edu-wa__action:hover {
    border-color: var(--wa-green);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.15);
}

.edu-wa__action--primary {
    border-color: transparent;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: #fff;
}

.edu-wa__action--primary:hover {
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.28);
}

.edu-wa__action-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
    background: rgba(37, 211, 102, 0.12);
    color: #16a34a;
}

.edu-wa__action--primary .edu-wa__action-icon {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.edu-wa__action-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    flex: 1;
}

.edu-wa__action-text strong {
    font-size: 0.84rem;
    line-height: 1.2;
}

.edu-wa__action-text span {
    font-size: 0.75rem;
    opacity: 0.8;
}

.edu-wa__action-go {
    font-size: 0.75rem;
    opacity: 0.65;
}

.edu-wa__hint {
    margin: 0;
    font-size: 0.68rem;
    line-height: 1.4;
    color: var(--gray-600, #475569);
    text-align: center;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 480px) {
    .edu-chat__panel,
    .edu-wa__panel {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
    }

    .edu-chat.is-open .edu-chat__launcher,
    .edu-wa.is-open .edu-wa__launcher {
        display: none;
    }

    .edu-float-dock:has(.edu-chat.is-open) .edu-wa,
    .edu-float-dock:has(.edu-wa.is-open) .edu-chat {
        opacity: 0;
        pointer-events: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .edu-chat__panel,
    .edu-wa__panel {
        animation: none;
    }

    .edu-chat__typing-dot,
    .edu-wa.is-attention .edu-wa__launcher {
        animation: none;
    }
}
