/* Shared touch support. */

button,
[role="button"],
a,
label[for],
input[type="button"],
input[type="submit"],
input[type="reset"] {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(22, 163, 74, 0.16);
}

/* any-pointer covers hybrid POS devices. */
@media (any-pointer: coarse) {
    /* 44px targets; 16px prevents iOS focus zoom. */
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        min-height: 44px;
        font-size: 16px !important;
    }

    button,
    [role="button"],
    input[type="button"],
    input[type="submit"],
    input[type="reset"] {
        min-height: 44px;
    }

    /* Keep scrolling inside the fixed app shell. */
    :where(
        .sidebar-content,
        .appointments-list,
        .search-results,
        .searchable-select-list,
        .slide-panel-body,
        .modal-body,
        .picker-grid-area,
        .picker-cart-list,
        .kanban-board,
        .kanban-column-body,
        .timeline-grid,
        .table-responsive,
        .pv-schedule-grid,
        .pv-main,
        .ptv-scroll-area,
        .pl-list,
        .pl-preview,
        .pos-grid,
        .pos-ps-list,
        .pos-cart-items,
        .receipt-panel-body,
        .management-main,
        .employee-main
    ) {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-x pan-y;
    }

    /* Finger-sized search choices. */
    .searchable-select-item {
        display: flex;
        min-height: 44px;
        box-sizing: border-box;
        flex-direction: column;
        justify-content: center;
        touch-action: pan-y;
    }

    /* Finger-sized icon controls. */
    .appointment-item .apt-card-edit-btn,
    .appointment-item .apt-card-delete-btn,
    .apt-card-actions .apt-card-edit-btn,
    .apt-card-actions .apt-card-delete-btn,
    .kanban-card-edit-btn,
    .kanban-card-delete-btn,
    .timeline-apt-edit-btn,
    .timeline-apt-view-btn,
    .timeline-apt-plan-btn,
    .pv-apt-edit-btn,
    .pv-apt-edit-btn--sm {
        min-width: 44px;
        min-height: 44px;
    }

    .appointment-item .apt-card-edit-btn { right: 4px; }
    .appointment-item .apt-card-delete-btn { right: 52px; }
    .kanban-card-edit-btn { right: 54px; }
    .kanban-card-edit-btn.is-alone { right: 6px; }
    .kanban-card-delete-btn { right: 6px; }
    .timeline-apt-view-btn { right: 52px; }
    .timeline-apt-plan-btn { right: 100px; }
    .no-edit-btn .timeline-apt-view-btn { right: 4px; }
    .no-edit-btn .timeline-apt-plan-btn { right: 52px; }
}

@media (hover: none), (any-pointer: coarse) {
    /* Show hover-only controls on touch. */
    .appointment-item .apt-card-edit-btn,
    .appointment-item .apt-card-delete-btn,
    .kanban-card-edit-btn,
    .kanban-card-delete-btn,
    .timeline-apt-edit-btn,
    .timeline-apt-view-btn,
    .timeline-apt-plan-btn,
    .pv-apt-edit-btn,
    .timeline-appointment .pv-apt-edit-btn--sm {
        opacity: 1;
    }

    .appointment-hover-actions {
        display: flex;
    }

    /* Make empty slots discoverable. */
    .timeline-provider-slot.empty-slot::after,
    .pv-sched-apt-cell.empty-slot::after {
        content: '+ Book';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 11px;
        font-weight: 600;
        color: var(--calendar-green);
        opacity: 0.6;
        pointer-events: none;
    }

    /* Tap feedback. */
    button:active:not(:disabled),
    [role="button"]:active,
    .day-cell:active,
    .appointment-item:active,
    .compact-patient-card:active,
    .kanban-card:active,
    .timeline-provider-slot.empty-slot:active,
    .pv-sched-apt-cell.empty-slot:active,
    .search-result-card:active {
        filter: brightness(0.96);
    }

    .pl-item {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    button,
    [role="button"] {
        transition-duration: 0.01ms !important;
    }
}
