/* ========================================
   REFERRAL TRIAL (link do parceiro)
   ----------------------------------------
   Secao montada por src/js/referral-trial.js SOMENTE quando existe indicacao
   ativa (?ref= na URL ou cookie ags_ref + code confirmado pela API). Sem
   indicacao, nenhuma dessas regras tem alvo na pagina.

   Reaproveita a linguagem visual do card escuro do Kliper (.kliper-demo):
   superficie var(--bg-dark), raio 12px, borda var(--border-dark), sombra em
   camadas, acento var(--brand-lime). Nenhuma fonte, cor ou raio novo.
   ======================================== */

.referral-section {
    padding: 96px 0 60px;
    background: white;
    /* Estado de entrada; o JS adiciona .referral-visible no frame seguinte a
       insercao. Como a secao so existe com JS, nada de conteudo escondido
       para crawler ou leitor de tela. */
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
}

.referral-section.referral-visible {
    opacity: 1;
    transform: none;
    will-change: auto;
}

.referral-card {
    position: relative;
    overflow: hidden;
    background: var(--bg-dark);
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    padding: 64px 72px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 64px;
    align-items: center;
    box-shadow: 0 6px 4px rgba(12, 25, 39, 0.05),
                0 16px 10px rgba(12, 25, 39, 0.06),
                0 50px 30px rgba(12, 25, 39, 0.12);
}

/* Brilho de marca no canto, na mesma familia do blob do hero (so bem mais
   contido: aqui e leitura de texto, nao capa). */
.referral-card::after {
    content: '';
    position: absolute;
    top: -180px;
    right: -120px;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: var(--secondary-green);
    opacity: 0.16;
    filter: blur(120px);
    pointer-events: none;
}

.referral-copy,
.referral-action {
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.referral-visible .referral-copy {
    opacity: 1;
    transform: none;
    transition-delay: 0.1s;
}

.referral-visible .referral-action {
    opacity: 1;
    transform: none;
    transition-delay: 0.2s;
}

/* --- Coluna de copy ------------------------------------------------- */

.referral-badge {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    row-gap: 0;
    background: rgba(228, 255, 51, 0.1);
    border: 1px solid rgba(228, 255, 51, 0.32);
    border-radius: 999px;
    padding: 6px 14px;
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--brand-lime);
}

.referral-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-lime);
    flex-shrink: 0;
}

/* "Indicado por" nunca quebra no meio; o nome do parceiro, sim (em telas
   estreitas ele vai para a segunda linha da pilula). */
.referral-badge-label {
    white-space: nowrap;
}

.referral-badge strong {
    font-weight: 700;
}

.referral-title {
    color: white;
    margin-bottom: 16px;
}

.referral-description {
    font-size: 16px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 24px;
    max-width: 46ch;
}

.referral-benefits {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.referral-benefits li {
    position: relative;
    padding-left: 28px;
    font-size: 15px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.86);
}

.referral-benefits li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 12px;
    height: 7px;
    border-left: 2px solid var(--secondary-green);
    border-bottom: 2px solid var(--secondary-green);
    transform: rotate(-45deg);
}

/* --- Formulario ----------------------------------------------------- */

.referral-action {
    display: grid;
    gap: 16px;
    align-content: center;
}

.referral-form {
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    padding: 32px;
}

.referral-login {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.6);
}

.referral-login a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    padding-bottom: 1px;
    transition: border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.referral-login a:hover {
    color: var(--brand-lime);
    border-bottom-color: var(--brand-lime);
}

.referral-login a:focus-visible {
    outline: 2px solid var(--brand-lime);
    outline-offset: 3px;
    border-radius: 2px;
}

.referral-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 8px;
}

.referral-field {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.referral-input {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-primary);
    font-size: 15px;
    line-height: 1.4;
    color: white;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    padding: 14px 16px;
    transition: border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.referral-input::placeholder {
    color: rgba(255, 255, 255, 0.46);
}

.referral-input:hover:not(:disabled) {
    border-color: #3E5364;
}

/* Foco visivel obrigatorio: anel de 3px na cor de marca, alem da borda. */
.referral-input:focus,
.referral-input:focus-visible {
    outline: none;
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--secondary-green);
    box-shadow: 0 0 0 3px rgba(59, 184, 139, 0.28);
}

.referral-input[aria-invalid="true"] {
    border-color: #E8734A;
}

.referral-input[aria-invalid="true"]:focus,
.referral-input[aria-invalid="true"]:focus-visible {
    box-shadow: 0 0 0 3px rgba(232, 115, 74, 0.28);
}

.referral-input:disabled {
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

.referral-submit {
    flex: 0 0 auto;
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-heading);
    background: var(--brand-lime);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 14px 22px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.referral-submit:hover:not(:disabled) {
    background: var(--brand-lime-darker);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.22);
}

.referral-submit:active:not(:disabled) {
    transform: translateY(0);
}

.referral-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(228, 255, 51, 0.35);
}

.referral-submit:disabled {
    cursor: not-allowed;
    opacity: 0.62;
    transform: none;
}

.referral-submit svg {
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.referral-submit:hover:not(:disabled) svg {
    transform: translateX(3px);
}

/* Estado concluido: o pedido foi aceito (202), entao o botao deixa de ser um
   convite a clicar e passa a ser confirmacao. O texto vive no HTML. */
.referral-submit-done,
.referral-check {
    display: none;
}

.referral-form.is-done .referral-submit-idle,
.referral-form.is-done .referral-arrow {
    display: none;
}

.referral-form.is-done .referral-submit-done {
    display: inline;
}

.referral-form.is-done .referral-check {
    display: block;
}

.referral-form.is-done .referral-submit:disabled {
    opacity: 1;
    background: rgba(59, 184, 139, 0.16);
    border-color: rgba(59, 184, 139, 0.4);
    color: var(--secondary-green);
    box-shadow: none;
}

/* Estado de envio: a seta sai, o anel entra. O botao ja esta disabled pelo
   JS, entao o duplo clique nao chega aqui -- isto e o feedback, nao a trava. */
.referral-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(26, 43, 59, 0.25);
    border-top-color: var(--text-heading);
    border-radius: 50%;
    flex-shrink: 0;
    animation: referralSpin 0.7s linear infinite;
}

.referral-form.is-pending .referral-spinner {
    display: block;
}

.referral-form.is-pending .referral-arrow {
    display: none;
}

@keyframes referralSpin {
    to {
        transform: rotate(360deg);
    }
}

.referral-hint {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.52);
    margin: 12px 0 0;
}

.referral-hint a {
    color: var(--secondary-green);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.referral-hint a:hover {
    color: var(--brand-lime);
}

.referral-hint a:focus-visible {
    outline: 2px solid var(--brand-lime);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Espaco reservado para a mensagem, para a resposta nao empurrar o layout. */
.referral-status {
    min-height: 20px;
    margin: 12px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.72);
}

.referral-status-pending,
.referral-status-ok,
.referral-status-error {
    animation: referralStatusIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.referral-status-ok {
    color: var(--secondary-green);
    font-weight: 500;
}

.referral-status-error {
    color: #FFB08C;
}

@keyframes referralStatusIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* --- Responsivo ----------------------------------------------------- */

@media (max-width: 1280px) {
    .referral-card {
        padding: 56px 48px;
        gap: 48px;
    }
}

@media (max-width: 1024px) {
    .referral-section {
        padding: 72px 0 48px;
    }

    .referral-card {
        grid-template-columns: 1fr;
        gap: 40px;
        padding: 48px 40px;
    }

    .referral-description {
        max-width: none;
    }
}

@media (max-width: 768px) {
    .referral-card {
        padding: 36px 24px;
    }

    .referral-title {
        font-size: 30px;
    }

    .referral-form {
        padding: 24px 20px;
    }

    .referral-field {
        flex-direction: column;
    }

    .referral-submit {
        justify-content: center;
        padding: 15px 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .referral-section,
    .referral-copy,
    .referral-action {
        transition: none;
    }

    .referral-spinner {
        animation: none;
    }

    .referral-status-pending,
    .referral-status-ok,
    .referral-status-error {
        animation: none;
    }
}
