/**
 * Auth Form Component
 * 
 * @package Candini
 * @since 1.0.0
 */

/* =====================================================
   CONTAINER PRINCIPAL
   ===================================================== */
.auth-form {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    font-family: var(--font-family, 'Galano Grotesque', sans-serif);
}

/* Auth Form no contexto do checkout */
.checkout-step .auth-form {
    max-width: 100%;
    width: 100%;
    margin: 0;
}

/* =====================================================
   TABS LOGIN/CADASTRO
   ===================================================== */
.auth-form__tabs {
    display: flex;
    border-bottom: 2px solid var(--color-gray-light, #F0EFEC);
    margin-bottom: 32px;
    background: #fff;
    border-radius: 12px 12px 0 0;
    position: relative;
}

.checkout-step .auth-form__tabs {
    margin-bottom: 40px;
    border-bottom: 3px solid #f0f0f0;
}

.auth-form__tab {
    flex: 1;
    padding: 18px 24px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 100 !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    touch-action: manipulation;
    outline: none;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    display: block;
    width: 100%;
    text-align: center;
}

/* Garantir que filhos da tab não bloqueiem cliques */
.auth-form__tab * {
    pointer-events: none;
}

.auth-form__tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    pointer-events: none;
}

.checkout-step .auth-form__tab {
    padding: 20px 24px;
    font-size: 18px;
}

.auth-form__tab:focus {
    outline: 2px solid var(--color-primary, #310775);
    outline-offset: -2px;
    border-radius: 8px 8px 0 0;
}

.auth-form__tab:active {
    transform: none;
}

.auth-form__tab::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    transition: background 0.3s ease;
    pointer-events: none;
    border-radius: 2px 2px 0 0;
}

.auth-form__tab:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.02);
}

.auth-form__tab.active {
    color: #000;
    font-weight: 700;
}

.auth-form__tab.active::after {
    background: #000;
    height: 3px;
}

.checkout-step .auth-form__tab.active::after {
    height: 4px;
}

/* =====================================================
   CONTEÚDO DOS TABS
   ===================================================== */
.auth-form__content {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.auth-form__content.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: fadeInUp 0.4s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   FORMULÁRIOS
   ===================================================== */
.auth-form__form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.checkout-step .auth-form__form {
    gap: 28px;
}

/* =====================================================
   GRUPOS DE CAMPO
   ===================================================== */
.auth-form__field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkout-step .auth-form__field {
    gap: 12px;
}

.auth-form__label {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

.checkout-step .auth-form__label {
    font-size: 16px;
    font-weight: 600;
}

.auth-form__label--required::after {
    content: ' *';
    color: #dc2626;
    font-weight: 700;
}

/* =====================================================
   INPUTS
   ===================================================== */
.auth-form__input {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-family: inherit;
    font-size: 16px;
    color: #111827;
    background: #ffffff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.5;
}

.checkout-step .auth-form__input {
    padding: 18px 20px;
    font-size: 16px;
    border-radius: 12px;
}

.auth-form__input::placeholder {
    color: var(--color-gray-dark, #666666);
}

.auth-form__input:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
    background: #fafafa;
}

.checkout-step .auth-form__input:focus {
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
}

.auth-form__input.error {
    border-color: #dc3545;
}

.auth-form__input.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.auth-form__input.success {
    border-color: #28a745;
}

/* =====================================================
   CAMPO DE SENHA COM TOGGLE
   ===================================================== */
.auth-form__password-wrapper {
    position: relative;
}

.auth-form__password-wrapper .auth-form__input {
    padding-right: 48px;
}

.auth-form__password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--color-gray-dark, #666666);
    transition: color var(--transition-fast, 0.15s ease);
}

.auth-form__password-toggle:hover {
    color: var(--color-primary, #310775);
}

.auth-form__password-toggle svg {
    width: 20px;
    height: 20px;
}

/* =====================================================
   MENSAGENS DE ERRO
   ===================================================== */
.auth-form__error {
    font-size: 13px;
    color: #dc2626;
    display: none;
    margin-top: 6px;
    font-weight: 500;
    line-height: 1.4;
}

.checkout-step .auth-form__error {
    font-size: 14px;
    margin-top: 8px;
}

.auth-form__error.visible {
    display: block;
}

.auth-form__message {
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    display: none;
    margin-bottom: 24px;
    font-weight: 500;
    line-height: 1.6;
}

.checkout-step .auth-form__message {
    padding: 18px 22px;
    font-size: 16px;
    margin-bottom: 28px;
    border-radius: 14px;
}

.auth-form__message.visible {
    display: block;
}

.auth-form__message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 2px solid #fecaca;
}

.auth-form__message.success {
    background: #d1fae5;
    color: #065f46;
    border: 2px solid #a7f3d0;
}

/* =====================================================
   CHECKBOX
   ===================================================== */
.auth-form__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px 0;
    margin: 8px 0;
}

.checkout-step .auth-form__checkbox {
    gap: 14px;
    padding: 14px 0;
    margin: 12px 0;
}

.auth-form__checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    flex-shrink: 0;
    accent-color: #000;
    cursor: pointer;
    margin-top: 2px;
}

.checkout-step .auth-form__checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
}

.auth-form__checkbox-label {
    font-size: 15px;
    color: #4b5563;
    line-height: 1.6;
    flex: 1;
}

.checkout-step .auth-form__checkbox-label {
    font-size: 15px;
}

.auth-form__checkbox-label a {
    color: var(--color-primary, #310775);
    text-decoration: underline;
}

/* =====================================================
   BOTÕES
   ===================================================== */
.auth-form__button {
    width: 100%;
    padding: 18px 24px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
    margin-top: 8px;
}

.checkout-step .auth-form__button {
    padding: 20px 24px;
    font-size: 18px;
    border-radius: 14px;
    margin-top: 12px;
}

.auth-form__button--primary {
    background: var(--color-primary, #310775);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(49, 7, 117, 0.2);
}

.auth-form__button--primary:hover,
.auth-form__button--primary:hover a {
    background: #000;
    color: #ffffff !important; /* Garante texto branco no hover */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* Garante que links dentro do botão também fiquem brancos no hover */
a.auth-form__button--primary:hover {
    color: #ffffff !important;
}

.auth-form__button--primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    color: #ffffff !important; /* Garante texto branco no active também */
}

/* Garante que links dentro do botão também fiquem brancos no active */
a.auth-form__button--primary:active {
    color: #ffffff !important;
}

.auth-form__button--primary:disabled {
    background: var(--color-gray, #C4C4C4);
    cursor: not-allowed;
}

.auth-form__button.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.auth-form__button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-white, #FFFFFF);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   LINKS
   ===================================================== */
.auth-form__link {
    font-size: 15px;
    color: #000;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.auth-form__link:hover {
    color: #333;
    border-bottom-color: #333;
}

.auth-form__forgot {
    text-align: right;
    margin-top: 4px;
}

.auth-form__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0;
    gap: 16px;
}

.checkout-step .auth-form__row {
    margin: 20px 0;
    gap: 20px;
}

/* =====================================================
   USUÁRIO LOGADO
   ===================================================== */
.auth-form__user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm, 16px);
    padding: var(--spacing-sm, 16px);
    background: var(--color-gray-light, #F0EFEC);
    border-radius: var(--radius-md, 8px);
}

.auth-form__user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary, #310775);
    color: var(--color-white, #FFFFFF);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-bold, 700);
    font-size: var(--font-size-lg, 18px);
}

.auth-form__user-details {
    flex: 1;
}

.auth-form__user-name {
    font-weight: var(--font-semibold, 600);
    color: var(--color-black, #16121C);
}

.auth-form__user-email {
    font-size: var(--font-size-sm, 14px);
    color: var(--color-gray-dark, #666666);
}

.auth-form__user-change {
    font-size: var(--font-size-sm, 14px);
    color: var(--color-primary, #310775);
    text-decoration: none;
}

/* =====================================================
   RESPONSIVO
   ===================================================== */
@media (max-width: 768px) {
    .auth-form__tab {
        padding: 16px 20px;
        font-size: 16px;
    }
    
    .checkout-step .auth-form__tab {
        padding: 18px 22px;
        font-size: 17px;
    }
    
    .auth-form__input {
        padding: 16px 18px;
        font-size: 16px;
    }
    
    .checkout-step .auth-form__input {
        padding: 16px 18px;
    }
    
    .auth-form__button {
        padding: 16px 20px;
        font-size: 16px;
    }
    
    .checkout-step .auth-form__button {
        padding: 18px 22px;
        font-size: 17px;
    }
    
    .auth-form__form {
        gap: 20px;
    }
    
    .checkout-step .auth-form__form {
        gap: 24px;
    }
    
    .auth-form__field {
        gap: 10px;
    }
    
    .checkout-step .auth-form__field {
        gap: 12px;
    }
    
    .auth-form__tabs {
        margin-bottom: 24px;
    }
    
    .checkout-step .auth-form__tabs {
        margin-bottom: 32px;
    }
}

@media (min-width: 769px) {
    .auth-form {
        max-width: 500px;
    }
    
    .checkout-step .auth-form {
        max-width: 600px;
    }
}