/* =========================================================================
   Pickup Locations page — mobile makeover.
   Same pattern: title + filters card hidden, Add button → purple FAB,
   table → cards with 3-dot ⋯ opening a bottom sheet.
   ========================================================================= */

/* Bottom sheet */
.pl-sheet-wrap { position: fixed; inset: 0; z-index: 10000; display: flex; flex-direction: column; justify-content: flex-end; pointer-events: none; }
.pl-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background 0.2s; pointer-events: auto; }
.pl-sheet-wrap.is-open .pl-sheet-backdrop { background: rgba(0,0,0,0.4); }
.pl-sheet { position: relative; background: #fff; border-radius: 16px 16px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform 0.22s ease-out; box-shadow: 0 -8px 24px rgba(0,0,0,0.15); pointer-events: auto; max-height: 85vh; overflow-y: auto; }
.pl-sheet-wrap.is-open .pl-sheet { transform: translateY(0); }
.pl-sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: #e5e7eb; margin: 4px auto 12px; }
.pl-sheet-title { font-weight: 700; font-size: 0.95rem; color: #111827; text-align: center; margin-bottom: 8px; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-sheet-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.pl-sheet-item { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 8px; border: none; background: transparent; color: #111827; font-size: 0.95rem; font-weight: 500; text-align: left; cursor: pointer; border-radius: 10px; }
.pl-sheet-item:active { background: #f3f4f6; }
.pl-sheet-item.is-danger { color: #991b1b; }
.pl-sheet-icon { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pl-sheet-label { flex: 0 0 auto; }
.pl-sheet-divider { height: 1px; background: #f3f4f6; margin: 6px 8px; }
.pl-sheet-cancel { width: 100%; margin-top: 8px; padding: 12px; background: #f3f4f6; border: none; border-radius: 10px; font-size: 0.95rem; font-weight: 600; color: #374151; cursor: pointer; }

/* Search bar + drawer (mobile-only, but declared outside the media query so
   they participate in specificity ordering with base rules). */
#plMobileSearchBar { display: none; }

.pl-drawer-wrap { position: fixed; inset: 0; z-index: 10000; }
.pl-drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background 0.2s; }
.pl-drawer-wrap.is-open .pl-drawer-backdrop { background: rgba(0,0,0,0.35); }
.pl-drawer {
    position: absolute; right: 0; top: 0; bottom: 0; width: 88%; max-width: 380px;
    background: #fff; box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transform: translateX(100%); transition: transform 0.22s ease-out;
    display: flex; flex-direction: column;
}
.pl-drawer-wrap.is-open .pl-drawer { transform: translateX(0); }
.pl-drawer-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.15rem; border-bottom: 1px solid #e5e7eb;
    font-weight: 700; font-size: 1.05rem;
}
.pl-drawer-close {
    border: none; background: transparent; font-size: 1.5rem;
    color: #6b7280; cursor: pointer; line-height: 1;
}
.pl-drawer-body {
    padding: 1rem 1.15rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.pl-drawer-body > * { display: block !important; width: 100% !important; margin-bottom: 0.75rem; }
.pl-drawer-body > .form-group > label {
    display: block !important;
    font-size: 0.85rem; font-weight: 600; color: #374151;
    margin-bottom: 4px;
}
.pl-drawer-body > .form-group > input,
.pl-drawer-body > .form-group > select {
    width: 100% !important; min-height: 42px;
    padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px;
    background: #fff; font-size: 0.95rem; box-sizing: border-box;
}
/* Reset button at the bottom of the drawer, full-width and secondary style. */
.pl-drawer-body > .form-group.u-flex {
    margin-top: auto !important;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    display: flex !important;
}
.pl-drawer-body > .form-group.u-flex > .btn {
    width: 100% !important;
    padding: 10px 14px !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
}

@media (max-width: 767px) {

    #pickup-locations {
        padding: 8px !important;
        padding-bottom: 100px !important;
        /* .main-content already has margin-top: 56px for the fixed mobile
           header (mobile-optimized.css). Only reserve space for the fixed
           search bar (~56px) that sits below it. */
        padding-top: 64px !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    /* Hide title + filters card. Filters can still be reached via the
       simplified search input we surface at the top. */
    #pickup-locations > .page-header { display: none !important; }

    /* Fixed search + filter bar — pinned right below the 56px mobile header,
       mirrors the pattern used by bookings-mobile.js. */
    #plMobileSearchBar {
        display: flex !important; gap: 0.5rem;
        padding: 0.55rem 0.75rem;
        position: fixed !important; top: 56px; left: 0; right: 0;
        z-index: 990;
        background: #ffffff;
        border-bottom: 1px solid #e5e7eb;
    }
    #plMobileSearchBar input {
        flex: 1; padding: 0.55rem 0.75rem; border: 1px solid #d1d5db;
        border-radius: 8px; font-size: 0.9rem; background: #fff;
    }
    #plMobileSearchBar .pl-filter-btn {
        width: 40px; height: 40px; border-radius: 8px;
        border: 1px solid #d1d5db; background: #fff;
        display: inline-flex; align-items: center; justify-content: center;
        cursor: pointer;
    }
    /* Desktop filters block is moved into the drawer by JS; hide it in-place
       so the .page-header container doesn't reserve any vertical space
       (it's already display:none above, but keep this scoped to be safe if
       .page-header is ever unhidden later). */
    #pickup-locations #pickupLocationFilters { display: none !important; }

    /* Content section — flatten */
    #pickup-locations > .content-section {
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }
    #pickup-locations > .content-section > .section-header,
    #pickup-locations > .content-section > div:first-of-type {
        display: block !important;
        height: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: transparent !important;
        overflow: visible !important;
    }
    #pickup-locations > .content-section > .section-header > .section-title { display: none !important; }

    /* Add Pickup Location → purple FAB.
       NOTE: the button is nested inside a wrapper <div> in the section-header
       (not a direct child), so this uses a descendant combinator. */
    #pickup-locations > .content-section > .section-header .btn.btn-primary {
        position: fixed !important;
        bottom: 90px !important; right: 16px !important;
        z-index: 900 !important;
        width: 56px !important; height: 56px !important;
        border-radius: 12px !important;
        background: linear-gradient(135deg, #667eea, #764ba2) !important;
        color: #fff !important;
        border: 2px solid rgba(255, 255, 255, 0.2) !important;
        display: inline-flex !important;
        align-items: center !important; justify-content: center !important;
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4) !important;
        padding: 0 !important; margin: 0 !important;
        font-size: 0 !important; overflow: hidden !important;
    }
    #pickup-locations > .content-section > .section-header .btn.btn-primary svg {
        width: 22px !important; height: 22px !important; color: #fff !important; margin: 0 !important;
    }
    #pickup-locations > .content-section > .section-header .btn.btn-primary span { display: none !important; }
    #pickup-locations > .content-section > .section-header .btn.btn-primary:active { transform: scale(0.95) !important; }

    /* The wrapper div holding the buttons must not reserve layout space
       (the primary button is a fixed FAB; the OSM import is hidden on mobile). */
    #pickup-locations > .content-section > .section-header > div {
        display: block !important;
        height: 0 !important; margin: 0 !important; padding: 0 !important;
        overflow: visible !important;
    }
    #pickup-locations #osmImportBtn { display: none !important; }

    /* Table → cards. Columns:
       Name | Type | Address | Pickup Time | Surcharge | Linked | Status | Actions */
    #pickup-locations .table-container { overflow-x: visible !important; padding: 0 !important; margin: 0 !important; border: none !important; }
    #pickup-locations .data-table { display: block !important; width: 100% !important; min-width: 0 !important; background: transparent !important; border: none !important; }
    #pickup-locations .data-table thead { display: none !important; }
    #pickup-locations .data-table tbody { display: flex !important; flex-direction: column !important; gap: 8px !important; }
    #pickup-locations .data-table tbody tr {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        gap: 6px 12px !important;
        background: #fff !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 10px !important;
        padding: 12px !important;
    }
    #pickup-locations .data-table tbody tr:has(td[colspan]) {
        display: block !important;
        text-align: center !important;
        padding: 24px 12px !important;
        color: #9ca3af !important;
    }
    #pickup-locations .data-table tbody tr:has(td[colspan]) td { display: block !important; padding: 0 !important; border: none !important; text-align: center !important; }
    #pickup-locations .data-table tbody td { display: block !important; padding: 0 !important; border: none !important; background: transparent !important; font-size: 0.85rem !important; color: #4b5563 !important; }

    /* Name (col 1) — bold title, top-left */
    #pickup-locations .data-table tbody td:nth-child(1) {
        grid-row: 1 !important; grid-column: 1 !important;
        font-weight: 700 !important; color: #111827 !important;
        font-size: 0.95rem !important; text-align: left !important;
    }
    /* Type badge (col 2) — inline pill row 2 col 1 */
    #pickup-locations .data-table tbody td:nth-child(2) {
        grid-column: 1 !important;
        display: inline-flex !important;
        align-items: center !important;
    }
    /* Address (col 3) — muted, full width */
    #pickup-locations .data-table tbody td:nth-child(3) {
        grid-column: 1 / -1 !important;
        color: #6b7280 !important;
    }
    /* Pickup time (col 4) + Surcharge (col 5) — small footer inline */
    #pickup-locations .data-table tbody td:nth-child(4) {
        grid-column: 1 !important;
        font-size: 0.75rem !important;
        color: #9ca3af !important;
    }
    #pickup-locations .data-table tbody td:nth-child(5) {
        grid-column: 2 !important;
        justify-self: end !important;
    }
    /* Linked services (col 6) — pills */
    #pickup-locations .data-table tbody td:nth-child(6) {
        grid-column: 1 / -1 !important;
    }
    /* Status (col 7) — inline pill */
    #pickup-locations .data-table tbody td:nth-child(7) {
        grid-column: 1 / -1 !important;
        display: inline-flex !important;
        align-items: center !important;
    }
    /* Actions (col 8) — 3-dot in row 1 col 2 */
    #pickup-locations .data-table tbody td:nth-child(8) {
        grid-row: 1 !important; grid-column: 2 !important;
        justify-self: end !important; align-self: start !important;
        display: block !important;
    }
    #pickup-locations .pl-more-btn {
        width: 36px; height: 36px;
        border: none; background: #f3f4f6; color: #4b5563;
        border-radius: 8px;
        display: inline-flex; align-items: center; justify-content: center;
        cursor: pointer; padding: 0;
    }
    #pickup-locations .pl-more-btn:active { background: #e5e7eb; }

    /* -----------------------------------------------------------------
       Add/Edit Pickup Location modal — full-viewport frame with sticky
       bottom action row. Same treatment as the Categories/Extras modal.
       ----------------------------------------------------------------- */
    #pickupLocationModal.modal,
    #managePickupServicesModal.modal {
        padding: 0 !important;
        align-items: stretch !important;
        justify-content: stretch !important;
    }
    #pickupLocationModal .modal-content,
    #managePickupServicesModal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        background: #fff !important;
    }
    /* Kill the purple gradient header — white + dark title */
    #pickupLocationModal .modal-header,
    #managePickupServicesModal .modal-header {
        padding: 14px 20px !important;
        background: #fff !important;
        color: #111827 !important;
        border-bottom: 1px solid #f3f4f6 !important;
        flex-shrink: 0 !important;
        border-radius: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    #pickupLocationModal .modal-header h2,
    #managePickupServicesModal .modal-header h2 {
        color: #111827 !important;
        font-size: 1.05rem !important;
        font-weight: 700 !important;
        margin: 0 !important;
    }
    #pickupLocationModal .close-modal,
    #managePickupServicesModal .close-modal {
        background: #f3f4f6 !important;
        color: #6b7280 !important;
        border: none !important;
        width: 32px !important;
        height: 32px !important;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 1.15rem !important;
        cursor: pointer !important;
    }

    /* Body — grey scrolling surface */
    #pickupLocationModal .modal-body,
    #managePickupServicesModal .modal-body {
        padding: 14px !important;
        background: #f9fafb !important;
        overflow-y: auto !important;
        flex: 1 !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }
    #pickupLocationModal #pickupLocationForm {
        display: flex !important;
        flex-direction: column !important;
        min-height: 100% !important;
    }

    /* Lat/Lng grid — stack on mobile */
    #pickupLocationModal #pickupLatLngGroup {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Form fields — normalize */
    #pickupLocationModal .form-group {
        margin-bottom: 12px !important;
    }
    #pickupLocationModal .form-group > label {
        font-size: 0.85rem !important;
        font-weight: 600 !important;
        color: #374151 !important;
        display: block !important;
        margin-bottom: 4px !important;
    }
    #pickupLocationModal .form-group input:not([type="checkbox"]):not([type="radio"]),
    #pickupLocationModal .form-group select,
    #pickupLocationModal .form-group textarea {
        width: 100% !important;
        min-height: 42px !important;
        padding: 8px 12px !important;
        border: 1px solid #d1d5db !important;
        border-radius: 8px !important;
        font-size: 0.95rem !important;
        background: #fff !important;
        box-sizing: border-box !important;
    }
    #pickupLocationModal .form-group textarea {
        min-height: 70px !important;
        resize: vertical !important;
    }
    #pickupLocationModal .form-group input:focus,
    #pickupLocationModal .form-group select:focus,
    #pickupLocationModal .form-group textarea:focus {
        outline: none !important;
        border-color: #6366f1 !important;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
    }
    #pickupLocationModal .form-group small {
        display: block !important;
        margin-top: 4px !important;
        font-size: 0.75rem !important;
        color: #6b7280 !important;
    }
    /* Checkboxes — keep native size, purple accent */
    #pickupLocationModal .form-group input[type="checkbox"],
    #managePickupServicesModal input[type="checkbox"] {
        width: 18px !important;
        height: 18px !important;
        min-height: 0 !important;
        padding: 0 !important;
        accent-color: #6366f1 !important;
        flex-shrink: 0 !important;
    }
    /* Surcharge fee input — full width when shown */
    #pickupLocationModal #pickupSurchargeAmountGroup input {
        width: 100% !important;
    }
    /* Tours checkbox list — cleaner box */
    #pickupLocationModal #pickupTourCheckboxList,
    #managePickupServicesModal #servicesCheckboxList {
        background: #fff !important;
        border: 1px solid #d1d5db !important;
        border-radius: 8px !important;
        padding: 10px !important;
        max-height: 300px !important;
    }
    #pickupLocationModal #pickupTourCheckboxList label,
    #managePickupServicesModal #servicesCheckboxList label {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 0.9rem !important;
        padding: 6px 4px !important;
    }

    /* Sticky bottom actions (Cancel + Save) */
    #pickupLocationModal #pickupLocationForm > div[style*="justify-content: flex-end"]:last-child,
    #managePickupServicesModal .modal-body > div[style*="justify-content: flex-end"]:last-child {
        margin: auto -14px 0 !important;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom)) !important;
        position: sticky !important;
        bottom: 0 !important;
        background: #fff !important;
        border-top: 1px solid #f3f4f6 !important;
        display: flex !important;
        gap: 8px !important;
        justify-content: stretch !important;
        z-index: 5 !important;
    }
    #pickupLocationModal #pickupLocationForm > div[style*="justify-content: flex-end"]:last-child > .btn,
    #managePickupServicesModal .modal-body > div[style*="justify-content: flex-end"]:last-child > .btn {
        flex: 1 1 calc(50% - 4px) !important;
        max-width: calc(50% - 4px) !important;
        margin: 0 !important;
        height: 44px !important;
        border-radius: 10px !important;
        font-weight: 600 !important;
        font-size: 0.9rem !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #pickupLocationModal .btn-danger,
    #managePickupServicesModal .btn-danger {
        background: #f3f4f6 !important;
        color: #374151 !important;
        border: 1px solid #e5e7eb !important;
    }
    #pickupLocationModal .btn-danger span,
    #managePickupServicesModal .btn-danger span {
        color: #374151 !important;
    }
    #pickupLocationModal .btn-success,
    #managePickupServicesModal .btn-success {
        background: linear-gradient(135deg, #667eea, #764ba2) !important;
        color: #fff !important;
        border: none !important;
    }

    /* Manage-services modal description text */
    #managePickupServicesModal .modal-body > p {
        color: #6b7280 !important;
        font-size: 0.85rem !important;
        margin-bottom: 12px !important;
    }
}
