/* Mobile UX improvements for RSVP and admin. Desktop layout remains unchanged. */

@media (max-width: 767.98px) {
    /* General mobile spacing */
    body {
        padding-top: 56px;
    }

    body > .container.mt-4.mb-5 {
        width: 100%;
        max-width: 100%;
        padding-left: 12px;
        padding-right: 12px;
        margin-top: 0.75rem !important;
    }

    .navbar-brand {
        font-size: 1.25rem !important;
    }

    /* RSVP: compact shell, large touch targets, clear choices */
    #rsvp-form {
        font-size: 1rem;
    }

    .card:has(#rsvp-form) {
        border-radius: 16px !important;
        box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.10) !important;
    }

    .card:has(#rsvp-form) .card-body {
        padding: 1.25rem !important;
    }

    #rsvp-form .form-control,
    #rsvp-form .form-select,
    #rsvp-form .input-group .btn {
        min-height: 48px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    #rsvp-form textarea.form-control {
        min-height: 96px;
    }

    #rsvp-form label.btn {
        min-height: 66px;
        border-radius: 12px;
        padding: 0.85rem 1rem !important;
    }

    #rsvp-form label.btn .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        flex: 0 0 auto;
    }

    #rsvp-submit {
        min-height: 54px;
        border-radius: 12px;
        font-weight: 700;
    }

    /* Existing RSVP / thank-you cards also become less padded. */
    .card:has(a[href*="/rsvp?code="]) .card-body,
    .card:has(a[href*="/info"]) .card-body {
        padding: 1.25rem !important;
    }

    /* Admin header actions wrap naturally instead of overflowing. */
    h2 + p.text-muted.small {
        margin-bottom: 0.25rem !important;
    }

    /* Guest toolbar: buttons/search get their own comfortable mobile rows. */
    #guestSearch {
        min-height: 46px;
        font-size: 16px;
    }

    .guest-search-group {
        width: 100% !important;
        max-width: none !important;
        flex: 1 1 100%;
    }

    .guest-search-group .input-group-text {
        min-width: 46px;
        justify-content: center;
    }

    #guestTable.closest-mobile-placeholder { width: 100%; }

    #guestFilterPanel .card-body {
        padding: 0.9rem !important;
    }

    #guestFilterPanel #guestFilterButtons {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 0.35rem;
        margin-left: -0.15rem;
        margin-right: -0.15rem;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    #guestFilterPanel .guest-filter-btn {
        flex: 0 0 auto;
        min-height: 42px;
        border-radius: 999px;
        padding-left: 0.85rem;
        padding-right: 0.85rem;
        white-space: nowrap;
    }

    #guestFilterPanel #guestFilterCount {
        font-size: 0.95rem;
    }

    /* Turn the guests table into stacked cards on phones. */
    #guestTable,
    #guestTable tbody,
    #guestTable tr,
    #guestTable td {
        display: block;
        width: 100%;
    }

    #guestTable thead {
        display: none;
    }

    #guestTable {
        border-collapse: separate;
        border-spacing: 0;
    }

    #guestTable tbody {
        padding: 0.25rem;
    }

    #guestTable .guest-row {
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 14px;
        margin-bottom: 0.75rem;
        padding: 0.25rem 0.75rem;
        box-shadow: 0 0.15rem 0.45rem rgba(0, 0, 0, 0.05);
        overflow: hidden;
    }

    #guestTable .guest-row td {
        border: 0;
        border-bottom: 1px solid #f0f1f2;
        padding: 0.65rem 0.15rem;
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 0.65rem;
        align-items: center;
        text-align: left !important;
        overflow-wrap: anywhere;
    }

    #guestTable .guest-row td::before {
        font-size: 0.72rem;
        font-weight: 700;
        color: #6c757d;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

    #guestTable .guest-row td:nth-child(1)::before { content: 'Gast'; }
    #guestTable .guest-row td:nth-child(2)::before { content: 'Type'; }
    #guestTable .guest-row td:nth-child(3)::before { content: 'Status'; }
    #guestTable .guest-row td:nth-child(4)::before { content: 'Aantal'; }
    #guestTable .guest-row td:nth-child(5)::before { content: 'Info'; }
    #guestTable .guest-row td:nth-child(6)::before { content: 'Acties'; }

    #guestTable .guest-row td:last-child {
        border-bottom: 0;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 0.5rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    #guestTable .guest-row td:last-child::before {
        content: '';
        display: none;
    }

    #guestTable .guest-row td:last-child .btn {
        min-width: 46px;
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    #guestTable .guest-row code {
        word-break: break-all;
    }

    .table-responsive:has(#guestTable) {
        overflow: visible;
    }

    .card:has(#guestTable) {
        box-shadow: none !important;
        border: 0 !important;
        background: transparent;
    }

    /* Floating helpers should not cover primary mobile actions. */
    #translate-wrapper {
        bottom: 12px !important;
        left: 12px !important;
    }

    #translate-launcher {
        width: 48px !important;
        height: 48px !important;
        font-size: 22px !important;
    }

    #chatbot-launcher {
        width: 54px !important;
        height: 54px !important;
        bottom: 12px !important;
        right: 12px !important;
        font-size: 25px !important;
    }

    #chatbot-window {
        left: 10px !important;
        right: 10px !important;
        bottom: 78px !important;
        width: auto !important;
        max-width: none !important;
        height: min(520px, 70vh) !important;
    }
}

@media (max-width: 420px) {
    #guestTable .guest-row td {
        grid-template-columns: 78px minmax(0, 1fr);
        gap: 0.45rem;
    }

    #rsvp-form label.btn small {
        font-size: 0.78rem;
    }
}
