/*
 * Agendos - Camada de Compatibilidade de Tema e Otimização Touch
 * Garante proteção contra estilos globais invasivos de temas (ex: Astra)
 * e padroniza a resposta tátil rápida, áreas de toque e fluidez mobile.
 */

/* 1. Reset de variáveis para isolar de temas com cores invasivas em botões */
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) button:where(:not(:disabled)):hover,
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) button:where(:not(:disabled)):focus,
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) button:where(:not(:disabled)):active,
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) input[type="button"]:where(:not(:disabled)):is(:hover, :focus, :active),
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) input[type="submit"]:where(:not(:disabled)):is(:hover, :focus, :active),
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) input[type="reset"]:where(:not(:disabled)):is(:hover, :focus, :active) {
    color: var(--agendos-control-color, inherit);
    border-color: var(--agendos-control-border-color, currentColor);
    background-color: var(--agendos-control-background, transparent);
}

/* 2. Foco visível acessível */
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) :is(button, input[type="button"], input[type="submit"], input[type="reset"]):focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.32);
    outline-offset: 2px;
}

/* 3. Touch-Action & Tap-Highlight Padronizados (elimina 300ms delay sem quebrar scroll/zoom) */
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) :is(
    button,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    a[role="button"],
    .ag-service-card,
    .ag-professional-card,
    .service-item,
    .professional-item,
    .time-slot,
    .ag-time-slot,
    .pro-tab-btn,
    .ts-tab-btn,
    .customer-mode-btn,
    .settings-nav-btn,
    .edit-services-btn,
    .edit-professional-btn,
    .cancel-new-schedule-btn,
    .cancel-edit-btn,
    .cancel-edit-services-btn,
    .btn-delete-block,
    .btn-cancel,
    .btn-whatsapp
) {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* 4. Resposta visual imediata aos toques (Feedback Tátil Nativo) */
:where(
    .agendamento-saas-business-dashboard,
    .professional-dashboard-app,
    #agendos-public-ui,
    .agendos-default-public-page,
    .booking-wrapper,
    .cancellation-container
) :is(
    button,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    .ag-service-card,
    .ag-professional-card,
    .service-item,
    .professional-item,
    .time-slot,
    .ag-time-slot,
    .pro-tab-btn,
    .ts-tab-btn,
    .customer-mode-btn,
    .settings-nav-btn,
    .edit-services-btn,
    .edit-professional-btn,
    .btn-delete-block,
    .btn-cancel,
    .btn-whatsapp
):where(:not(:disabled, [aria-disabled="true"])) {
    transition: transform 90ms ease-out, opacity 90ms ease-out, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
    will-change: transform;
}

@media (prefers-reduced-motion: no-preference) {
    :where(
        .agendamento-saas-business-dashboard,
        .professional-dashboard-app,
        #agendos-public-ui,
        .agendos-default-public-page,
        .booking-wrapper,
        .cancellation-container
    ) :is(
        button,
        input[type="button"],
        input[type="submit"],
        input[type="reset"],
        .ag-service-card,
        .ag-professional-card,
        .service-item,
        .professional-item,
        .time-slot,
        .ag-time-slot,
        .pro-tab-btn,
        .ts-tab-btn,
        .customer-mode-btn,
        .settings-nav-btn,
        .edit-services-btn,
        .edit-professional-btn,
        .btn-delete-block,
        .btn-cancel,
        .btn-whatsapp
    ):where(:not(:disabled, [aria-disabled="true"])):active {
        transform: scale(0.97);
        filter: brightness(0.95);
    }
}

/* 5. Alvos de Toque Confortáveis para Mobile (mínimo 44px de área clicável sem quebrar o layout) */
@media (max-width: 768px) {
    :where(
        .agendamento-saas-business-dashboard,
        .professional-dashboard-app,
        #agendos-public-ui,
        .agendos-default-public-page,
        .booking-wrapper,
        .cancellation-container
    ) :is(
        .cancel-new-schedule-btn,
        .close-delete-block-calendar,
        .close-upgrade-modal,
        .close-whatsapp-modal
    ) {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    :where(
        .agendamento-saas-business-dashboard,
        .professional-dashboard-app,
        #agendos-public-ui,
        .agendos-default-public-page,
        .booking-wrapper,
        .cancellation-container
    ) :is(.time-slot, .ag-time-slot) {
        min-height: 44px;
    }

    :where(
        .agendamento-saas-business-dashboard,
        .professional-dashboard-app,
        #agendos-public-ui,
        .agendos-default-public-page,
        .booking-wrapper,
        .cancellation-container
    ) :is(.btn-delete-block) {
        min-width: 44px;
        min-height: 44px;
    }
}
