/* =====================================================================
   Services (Tours) page — mobile makeover. Same pattern as the
   bookings/customers pages:
     - Hide the title + filter card
     - Fixed search bar + funnel button at the top
     - FAB (+) at the bottom right
     - Category + Status filters live in a slide-in drawer
   Everything scoped inside @media (max-width: 767px).
   ===================================================================== */

/* Desktop safety net */
#tours .tm-mobile-header,
#tours .tm-fab { display: none; }

@media (max-width: 767px) {
    /* Kill the title + filter card block */
    #tours > .modern-content-card.u-mb-4 {
        display: none !important;
    }

    /* Fixed search + funnel bar (right below the mobile header) */
    #tours .tm-mobile-header {
        display: flex !important;
        gap: 8px;
        padding: 0.55rem 0.75rem;
        position: fixed !important;
        top: 56px;
        left: 0;
        right: 0;
        z-index: 990;
        background: #ffffff;
        border-bottom: 1px solid #e5e7eb;
    }
    #tours .tm-top-search-input {
        flex: 1;
        min-width: 0;
        height: 40px;
        padding: 0.55rem 0.75rem;
        border: 1px solid #d1d5db;
        border-radius: 8px;
        font-size: 0.9rem;
        background: #fff;
        color: #111827;
        outline: none;
    }
    #tours .tm-top-search-input:focus {
        border-color: #6366f1;
    }
    #tours .tm-filter-trigger {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        border: 1px solid #d1d5db;
        background: #fff;
        color: #4b5563;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        position: relative;
    }
    .tm-filter-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 8px;
        background: #ef4444;
        color: #fff;
        font-size: 0.6rem;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
    .tm-filter-badge[hidden] { display: none; }

    /* Push the container down so it clears the fixed search bar */
    #tours #toursContainer {
        padding-top: 60px !important;
        padding-bottom: 90px !important;
    }

    /* FAB */
    #tours .tm-fab {
        display: inline-flex !important;
        position: fixed;
        bottom: 90px;
        right: 16px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: #fff;
        border: 2px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 900;
    }
    #tours .tm-fab:active { transform: scale(0.95); }

    /* Right-side slide-in filter drawer */
    .tm-drawer-wrap {
        position: fixed;
        inset: 0;
        z-index: 1050;
        pointer-events: none;
    }
    .tm-drawer-wrap.is-open { pointer-events: auto; }
    .tm-drawer-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        transition: background 0.22s;
    }
    .tm-drawer-wrap.is-open .tm-drawer-backdrop { background: rgba(0, 0, 0, 0.45); }
    .tm-drawer {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(85vw, 340px);
        background: #fff;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        display: flex;
        flex-direction: column;
    }
    .tm-drawer-wrap.is-open .tm-drawer { transform: translateX(0); }
    .tm-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px 12px;
        border-bottom: 1px solid #f3f4f6;
    }
    .tm-drawer-title {
        font-size: 1.1rem;
        font-weight: 700;
        margin: 0;
        color: #111827;
    }
    .tm-drawer-close {
        background: transparent;
        border: none;
        font-size: 1.75rem;
        color: #6b7280;
        cursor: pointer;
        padding: 4px 8px;
        line-height: 1;
    }
    .tm-drawer-body {
        padding: 16px 20px;
        overflow-y: auto;
        flex: 1;
    }
    .tm-drawer-group {
        margin-bottom: 18px;
    }
    .tm-drawer-group-label {
        display: block;
        font-size: 0.8rem;
        font-weight: 600;
        color: #374151;
        margin-bottom: 6px;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
    .tm-drawer-pills {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .tm-drawer-pill {
        display: inline-flex;
        align-items: center;
        padding: 8px 14px;
        border-radius: 999px;
        border: 1.5px solid #e5e7eb;
        background: #fff;
        color: #4b5563;
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
    }
    .tm-drawer-pill.selected {
        background: #eef2ff;
        border-color: #6366f1;
        color: #4338ca;
    }
    .tm-drawer-footer {
        display: flex;
        gap: 8px;
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #f3f4f6;
    }
    .tm-drawer-footer button {
        flex: 1;
        height: 42px;
        border-radius: 10px;
        font-weight: 600;
        font-size: 0.9rem;
        cursor: pointer;
    }
    .tm-clear-btn {
        background: #f3f4f6;
        color: #374151;
        border: 1px solid #e5e7eb;
    }
    .tm-close-btn {
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: #fff;
        border: none;
    }

    /* ---------------------------------------------------------------
       Compact service card layout for mobile:
       - Tighter header (title + badges inline)
       - Description clamps to 2 lines
       - Info grid becomes a horizontal chip row (Duração · Máx · €Adulto · €Criança)
       - Action buttons hidden — replaced by a floating 3-dot menu (added
         by tours-mobile.js) that opens a bottom sheet.
       --------------------------------------------------------------- */
    #tours .tour-card {
        position: relative;
        padding: 14px 16px !important;
        margin-bottom: 12px !important;
        border-radius: 12px !important;
    }
    /* Header — compact, left-aligned, minimal padding */
    #tours .tour-card .tour-card-header {
        padding: 10px 12px !important;
        background: transparent !important;
        border-radius: 0 !important;
        border-bottom: 1px solid #f3f4f6 !important;
        margin-bottom: 10px !important;
    }
    #tours .tour-card .tour-card-title-section {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
        margin-bottom: 6px !important;
    }
    #tours .tour-card .tour-card-header h3 {
        font-size: 1rem !important;
        line-height: 1.3 !important;
        margin: 0 !important;
        flex: 1 !important;
        min-width: 0 !important;
    }
    #tours .tour-card .tour-id-badge {
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
        flex-shrink: 0 !important;
    }
    /* Status badges — left-aligned, tighter */
    #tours .tour-card .tour-card-badges > div {
        display: flex !important;
        justify-content: flex-start !important;
        gap: 4px !important;
        flex-wrap: wrap !important;
    }
    #tours .tour-card .tour-card-badges .status-badge,
    #tours .tour-card .tour-card-badges span {
        font-size: 0.68rem !important;
        padding: 2px 8px !important;
    }
    #tours .tour-card .tour-card-badges svg {
        width: 11px !important;
        height: 11px !important;
    }
    /* Category inline, small caption */
    #tours .tour-card .tour-card-category {
        font-size: 0.75rem !important;
        color: #6b7280 !important;
        margin: 6px 0 0 !important;
        font-style: italic !important;
    }
    /* Description — clamp to 2 lines */
    #tours .tour-card .tour-card-body > div[style*="background"] {
        padding: 8px 10px !important;
        margin-bottom: 10px !important;
    }
    #tours .tour-card .tour-card-body > div[style*="background"] > div {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        font-size: 0.82rem !important;
    }
    /* Info items → single vertical list. Icon + label on the left,
       value on the right, spanning full width. No wasted space. */
    #tours .tour-card .tour-info {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        gap: 0 !important;
        margin-bottom: 10px !important;
        background: #f9fafb !important;
        border: 1px solid #f3f4f6 !important;
        border-radius: 10px !important;
        overflow: hidden !important;
    }
    #tours .tour-card .tour-info .info-item {
        padding: 10px 12px !important;
        background: transparent !important;
        border: none !important;
        border-bottom: 1px solid #f3f4f6 !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
        min-width: 0 !important;
        box-shadow: none !important;
        transition: none !important;
        position: relative !important;
    }
    #tours .tour-card .tour-info .info-item:last-child {
        border-bottom: none !important;
    }
    #tours .tour-card .tour-info .info-item:hover {
        transform: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    /* Label — inline with icon on the left, medium size, grey */
    #tours .tour-card .tour-info .info-item .info-label {
        display: inline-flex !important;
        align-items: center !important;
        font-size: 0.8rem !important;
        text-transform: none !important;
        letter-spacing: 0 !important;
        color: #6b7280 !important;
        font-weight: 500 !important;
        margin: 0 !important;
        padding-left: 22px !important;   /* room for the ::before icon */
        flex: 1 !important;
        min-width: 0 !important;
    }
    /* Value — right-aligned, bold */
    #tours .tour-card .tour-info .info-item .info-value {
        font-size: 0.9rem !important;
        font-weight: 700 !important;
        color: #111827 !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: right !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
    /* Icon on the far left, aligned with the label */
    #tours .tour-card .tour-info .info-item::before {
        content: '';
        position: absolute;
        top: 50% !important;
        left: 12px !important;
        transform: translateY(-50%) !important;
        width: 14px !important;
        height: 14px !important;
        background: currentColor;
        color: #9ca3af;
        -webkit-mask-size: contain;
        mask-size: contain;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
    }
    /* Icons — use inline SVG data URIs so they inherit currentColor */
    #tours .tour-card .tour-info .info-item:nth-child(1)::before {
        /* clock */
        -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><path fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z' clip-rule='evenodd'/></svg>");
                mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><path fill-rule='evenodd' d='M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z' clip-rule='evenodd'/></svg>");
    }
    #tours .tour-card .tour-info .info-item:nth-child(2)::before {
        /* users */
        -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><path d='M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z'/></svg>");
                mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><path d='M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z'/></svg>");
    }
    #tours .tour-card .tour-info .info-item:nth-child(3)::before,
    #tours .tour-card .tour-info .info-item:nth-child(4)::before {
        /* coin stack (matches the money icon used in bookings table) */
        -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><ellipse cx='10' cy='6' rx='6' ry='2.2'/><path d='M4 8.2c0 1.22 2.69 2.2 6 2.2s6-.98 6-2.2v2.6c0 1.22-2.69 2.2-6 2.2s-6-.98-6-2.2V8.2zm0 4.6c0 1.22 2.69 2.2 6 2.2s6-.98 6-2.2v2.6c0 1.22-2.69 2.2-6 2.2s-6-.98-6-2.2v-2.6z'/></svg>");
                mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><ellipse cx='10' cy='6' rx='6' ry='2.2'/><path d='M4 8.2c0 1.22 2.69 2.2 6 2.2s6-.98 6-2.2v2.6c0 1.22-2.69 2.2-6 2.2s-6-.98-6-2.2V8.2zm0 4.6c0 1.22 2.69 2.2 6 2.2s6-.98 6-2.2v2.6c0 1.22-2.69 2.2-6 2.2s-6-.98-6-2.2v-2.6z'/></svg>");
        color: #92400e;
    }
    #tours .tour-card .tour-info .info-item:nth-child(5)::before {
        /* map pin */
        -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><path fill-rule='evenodd' d='M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z' clip-rule='evenodd'/></svg>");
                mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='black'><path fill-rule='evenodd' d='M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z' clip-rule='evenodd'/></svg>");
    }
    /* No special treatment needed for Localização in the vertical list */
    #tours .tour-card .tour-info .info-item:nth-child(5) {
        grid-column: auto !important;
    }
    #tours .tour-card .tour-info .info-label {
        font-size: 0.65rem !important;
        text-transform: uppercase !important;
        color: #6b7280 !important;
        letter-spacing: 0.03em !important;
        margin: 0 !important;
    }
    #tours .tour-card .tour-info .info-value {
        font-size: 0.8rem !important;
        font-weight: 700 !important;
        color: #111827 !important;
        margin: 0 !important;
    }
    /* Hide the action button row — replaced by a 3-dot menu */
    #tours .tour-card .tour-card-body > div:last-child[style*="flex-wrap"] {
        display: none !important;
    }

    /* 3-dot menu button injected by tours-mobile.js */
    #tours .tour-card .tm-card-more {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        border-radius: 8px;
        border: none;
        background: transparent;
        color: #6b7280;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        z-index: 2;
    }
    #tours .tour-card .tm-card-more:active { background: #f3f4f6; }
    /* Give the header room for the button */
    #tours .tour-card .tour-card-header {
        padding-right: 40px !important;
    }

    /* Bottom action sheet (same visual language as bookings/QR sheet) */
    .tm-sheet-wrap {
        position: fixed;
        inset: 0;
        z-index: 1100;
        pointer-events: none;
    }
    .tm-sheet-wrap.is-open { pointer-events: auto; }
    .tm-sheet-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        transition: background 0.2s;
    }
    .tm-sheet-wrap.is-open .tm-sheet-backdrop { background: rgba(0, 0, 0, 0.35); }
    .tm-sheet {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        border-radius: 20px 20px 0 0;
        padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
        transform: translateY(100%);
        transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .tm-sheet-wrap.is-open .tm-sheet { transform: translateY(0); }
    .tm-sheet-handle {
        width: 40px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
        margin: 8px auto 12px;
    }
    .tm-sheet-title {
        text-align: center;
        font-size: 0.85rem;
        color: #6b7280;
        margin-bottom: 8px;
        font-weight: 600;
    }
    .tm-sheet-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 8px;
        background: transparent;
        border: none;
        cursor: pointer;
        text-align: left;
        width: 100%;
    }
    .tm-sheet-item:active { background: #f3f4f6; }
    .tm-sheet-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    .tm-sheet-label {
        font-size: 0.95rem;
        font-weight: 600;
        color: #111827;
    }
    .tm-sheet-divider {
        height: 1px;
        background: #f3f4f6;
        margin: 6px 8px;
    }
    .tm-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;
    }
}
