/* ============================================================
   RentalAjay Mobile Friendly V5
   Fokus: akses satu tangan, touch target, layout tanpa sesak,
   kontras, safe-area, customer + seller/admin.
   Desktop tidak diubah.
   ============================================================ */

@media (max-width: 820px) {
    :root {
        --raj-mobile-space: 12px;
        --raj-mobile-radius: 14px;
        --raj-mobile-touch: 44px;
        --raj-mobile-header: 58px;
        --raj-mobile-bottom: 68px;
    }

    html {
        scroll-padding-top: calc(var(--raj-mobile-header) + 10px);
        -webkit-text-size-adjust: 100%;
    }

    body {
        min-width: 0;
        overflow-x: hidden;
        font-size: 14px;
        line-height: 1.48;
        text-rendering: optimizeLegibility;
    }

    body.public-body,
    body.customer-body,
    body.admin-body {
        overscroll-behavior-x: none;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    img,
    video,
    iframe,
    canvas,
    svg {
        max-width: 100%;
    }

    a,
    button,
    summary,
    input,
    select,
    textarea {
        -webkit-tap-highlight-color: transparent;
    }

    a:focus-visible,
    button:focus-visible,
    summary:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible {
        outline: 3px solid rgba(39, 94, 254, .28);
        outline-offset: 2px;
    }

    .container {
        width: 100% !important;
        max-width: none !important;
        padding-inline: var(--raj-mobile-space);
    }

    .page-shell {
        width: 100%;
        min-width: 0;
        padding-top: 10px;
        padding-bottom: calc(var(--raj-mobile-bottom) + 24px + env(safe-area-inset-bottom, 0px));
    }

    main,
    .admin-content,
    .card,
    .card-body,
    .card-header,
    .hero,
    .search-panel,
    .grid,
    .detail-grid,
    .table-wrap {
        min-width: 0;
    }

    h1,
    h2,
    h3,
    h4,
    p {
        overflow-wrap: anywhere;
    }

    h1 {
        font-size: clamp(1.45rem, 7vw, 1.85rem);
        line-height: 1.12;
        letter-spacing: -.025em;
    }

    h2 {
        font-size: clamp(1.08rem, 5vw, 1.32rem);
        line-height: 1.2;
    }

    h3 {
        font-size: 1rem;
    }

    .muted,
    .small,
    .form-help {
        line-height: 1.45;
    }

    /* --------------------------------------------------------
       Touch controls
       -------------------------------------------------------- */
    .btn,
    button,
    input[type="button"],
    input[type="submit"],
    input[type="reset"] {
        min-height: var(--raj-mobile-touch);
        border-radius: 11px;
    }

    .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        padding: 10px 13px;
        font-size: .86rem;
        line-height: 1.15;
    }

    .btn-sm {
        min-height: 38px;
        padding: 8px 10px;
        font-size: .76rem;
    }

    .form-control,
    .form-select,
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea {
        width: 100%;
        min-height: 46px;
        padding: 10px 12px;
        border-radius: 11px;
        font-size: 16px; /* cegah auto zoom Safari/iOS */
    }

    textarea,
    textarea.form-control {
        min-height: 104px;
        resize: vertical;
    }

    input[type="checkbox"],
    input[type="radio"] {
        width: 19px;
        height: 19px;
        flex: 0 0 19px;
    }

    .form-row,
    .grid.grid-2,
    .grid.grid-3,
    .grid.grid-4 {
        gap: 10px;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    .alert {
        padding: 11px 12px;
        border-radius: 12px;
        font-size: .82rem;
        line-height: 1.42;
    }

    /* --------------------------------------------------------
       Header customer/public: sticky, ringkas, mudah dijangkau
       -------------------------------------------------------- */
    .site-header,
    .customer-header {
        position: sticky;
        top: 0;
        z-index: 1200;
        width: 100%;
        border-bottom: 1px solid var(--border);
        background: color-mix(in srgb, var(--surface) 92%, transparent);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .site-header .nav-wrap,
    .customer-header .nav-wrap,
    body.customer-body .customer-header .nav-wrap {
        min-height: calc(var(--raj-mobile-header) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top, 0px);
        padding-inline: 0;
        gap: 8px;
    }

    .brand {
        min-width: 0;
        gap: 7px;
        font-size: .98rem;
        font-weight: 800;
    }

    .brand-mark {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
        border-radius: 10px;
    }

    .brand > span:last-child,
    .brand strong {
        max-width: 118px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .customer-mobile-header-actions,
    .admin-mobile-header-actions {
        gap: 5px !important;
        margin-left: auto;
    }

    .customer-mobile-header-button,
    .customer-mobile-profile-shortcut,
    .admin-mobile-header-button,
    .admin-mobile-profile-button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        flex: 0 0 36px !important;
        padding: 0 !important;
        border-radius: 11px !important;
    }

    .customer-header-action-badge,
    .admin-header-action-badge {
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        font-size: .56rem;
    }

    .nav-toggle,
    .admin-menu-toggle {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        padding: 0;
        border-radius: 11px;
    }

    body.public-body .main-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        top: calc(var(--raj-mobile-header) + env(safe-area-inset-top, 0px) + 7px);
        width: auto;
        max-height: min(72dvh, 560px);
        overflow-y: auto;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: var(--surface);
        box-shadow: 0 18px 50px rgba(15, 23, 42, .22);
    }

    body.public-body .main-nav > a,
    body.public-body .main-nav > button,
    body.public-body .main-nav .btn {
        min-height: 44px;
        border-radius: 10px;
    }

    /* --------------------------------------------------------
       Bottom navigation customer: app-like dan aman dari notch
       -------------------------------------------------------- */
    body.customer-body {
        padding-bottom: calc(var(--raj-mobile-bottom) + env(safe-area-inset-bottom, 0px));
    }

    body.customer-body .customer-bottom-nav.customer-bottom-nav-minimal {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1180;
        min-height: calc(var(--raj-mobile-bottom) + env(safe-area-inset-bottom, 0px));
        padding: 5px max(7px, env(safe-area-inset-left, 0px)) calc(5px + env(safe-area-inset-bottom, 0px)) max(7px, env(safe-area-inset-right, 0px));
        border-top: 1px solid var(--border);
        background: color-mix(in srgb, var(--surface) 95%, transparent);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        box-shadow: 0 -8px 24px rgba(15, 23, 42, .10);
    }

    body.customer-body .customer-bottom-nav.customer-bottom-nav-minimal > a,
    body.customer-body .customer-more-menu > summary {
        min-height: 53px;
        justify-content: center;
        gap: 3px;
        padding: 4px 2px;
        border-radius: 12px;
    }

    body.customer-body .customer-bottom-nav.customer-bottom-nav-minimal > a.active,
    body.customer-body .customer-more-menu.active > summary,
    body.customer-body .customer-more-menu[open] > summary {
        color: var(--primary);
        background: color-mix(in srgb, var(--primary) 10%, var(--surface));
    }

    body.customer-body .customer-bottom-label {
        max-width: 100%;
        overflow: hidden;
        font-size: .58rem;
        font-weight: 700;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    body.customer-body .customer-more-sheet {
        left: 10px;
        right: 10px;
        bottom: calc(var(--raj-mobile-bottom) + 7px + env(safe-area-inset-bottom, 0px));
        max-height: min(70dvh, 560px);
        overflow-y: auto;
        padding: 12px;
        border-radius: 18px;
    }

    body.customer-body .customer-more-grid > a {
        min-height: 48px;
        padding: 10px;
    }

    /* floating lama jangan menutupi konten */
    .rp-mobile-action-dock,
    .rp-chat-floating-stack,
    .rp-review-floating-button {
        display: none !important;
    }

    /* --------------------------------------------------------
       Section / card density
       -------------------------------------------------------- */
    .card,
    .search-panel,
    .customer-panel,
    .rp-nearby-filter,
    .item-booking-card,
    .store-hero,
    .tripay-method-section {
        border-radius: var(--raj-mobile-radius);
        box-shadow: none;
    }

    .card-body,
    .customer-panel,
    .item-booking-card,
    .rp-nearby-filter {
        padding: 13px;
    }

    .card-header {
        padding: 12px 13px;
    }

    .section-head {
        align-items: flex-start;
        margin: 18px 0 9px;
        gap: 8px;
    }

    .section-head h1,
    .section-head h2 {
        margin: 0;
    }

    .section-head .actions,
    .section-head > .btn {
        width: 100%;
    }

    /* --------------------------------------------------------
       Homepage / katalog
       -------------------------------------------------------- */
    .hero {
        margin-top: 4px;
        padding: 16px 14px;
        border-radius: 17px;
    }

    .hero-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .hero h1 {
        margin: 8px 0 8px;
        font-size: clamp(1.42rem, 7vw, 1.8rem);
        line-height: 1.1;
    }

    .hero p {
        margin: 0 0 11px;
        font-size: .82rem;
        line-height: 1.48;
    }

    .hero-card {
        display: none !important;
    }

    .hero .actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .hero .actions .btn {
        width: 100%;
        min-height: 42px;
        padding-inline: 8px;
        font-size: .77rem;
    }

    .market-category-grid,
    #kategori + .grid.grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .market-category-card,
    #kategori + .grid.grid-4 > .card {
        min-width: 0;
        padding: 10px !important;
        border-radius: 12px !important;
    }

    .market-category-card strong,
    #kategori + .grid.grid-4 > .card strong {
        display: -webkit-box;
        overflow: hidden;
        font-size: .8rem !important;
        line-height: 1.25;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .market-category-card .small,
    #kategori + .grid.grid-4 > .card .small {
        display: none !important;
    }

    .search-panel,
    .store-filter {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 96px !important;
        gap: 7px !important;
        padding: 10px !important;
    }

    .search-panel > input:first-of-type,
    .store-filter > input:first-of-type {
        grid-column: 1 / -1;
    }

    .search-panel .btn,
    .store-filter .btn {
        width: 100%;
        min-width: 0;
    }

    .market-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 9px !important;
    }

    .market-card {
        min-width: 0;
        overflow: hidden;
        border-radius: 13px;
    }

    .market-card-image,
    .market-card-image-link {
        aspect-ratio: 1 / 1;
        overflow: hidden;
    }

    .market-card-image img,
    .market-card-image-link img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .market-card-body {
        padding: 9px;
    }

    .market-card-title {
        min-height: 34px;
        font-size: .79rem;
        line-height: 1.28;
    }

    .market-card-price {
        padding-top: 7px;
        font-size: .9rem;
    }

    .store-mini-copy,
    .store-mini-copy strong {
        min-width: 0;
    }

    .store-mini-copy strong {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* --------------------------------------------------------
       Customer dashboard
       -------------------------------------------------------- */
    .customer-dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .customer-dashboard-hero {
        padding: 16px 14px !important;
        border-radius: 17px !important;
    }

    .customer-dashboard-hero h1 {
        font-size: 1.5rem !important;
    }

    .customer-hero-actions {
        grid-template-columns: 1fr !important;
        gap: 7px !important;
    }

    .customer-stat-grid,
    .dashboard-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .customer-stat-card,
    .stat-card {
        min-width: 0;
        padding: 11px !important;
        border-radius: 12px !important;
    }

    .customer-panel-head {
        align-items: flex-start;
        gap: 8px;
    }

    /* --------------------------------------------------------
       Nearby
       -------------------------------------------------------- */
    .rp-nearby-page {
        width: 100%;
    }

    .rp-nearby-hero {
        min-height: 0 !important;
        padding: 15px 13px !important;
        border-radius: 16px !important;
    }

    .rp-nearby-hero-icon {
        display: none !important;
    }

    .rp-nearby-hero h1 {
        font-size: 1.38rem !important;
    }

    .rp-nearby-filter {
        margin-top: 10px;
    }

    .rp-nearby-filter-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 7px !important;
    }

    .rp-nearby-store-list {
        gap: 9px !important;
    }

    .rp-nearby-store-card {
        padding: 12px !important;
        border-radius: 13px !important;
    }

    .rp-nearby-store-top,
    .rp-nearby-store-main {
        gap: 9px !important;
    }

    .rp-nearby-store-logo,
    .rp-nearby-store-logo-fallback {
        width: 44px !important;
        height: 44px !important;
        flex: 0 0 44px !important;
    }

    .rp-nearby-store-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px !important;
    }

    /* --------------------------------------------------------
       Store / detail produk
       -------------------------------------------------------- */
    .store-hero-inner,
    .store-identity,
    .store-seller-panel-grid,
    .detail-grid {
        grid-template-columns: 1fr !important;
    }

    .store-hero-inner {
        padding: 14px !important;
    }

    .store-hero-actions,
    .store-seller-actions,
    .share-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px !important;
    }

    .store-hero-actions .btn,
    .store-seller-actions .btn,
    .share-actions .btn,
    .share-actions button {
        width: 100%;
    }

    .product-detail-card,
    .item-booking-card,
    .store-seller-panel {
        border-radius: 14px !important;
    }

    .product-gallery {
        border-radius: 14px;
    }

    .product-gallery-slide {
        aspect-ratio: 1 / 1;
    }

    .product-gallery-slide img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .product-gallery-prev,
    .product-gallery-next {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    .product-gallery-thumbs {
        overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    .product-gallery-thumbs::-webkit-scrollbar {
        display: none;
    }

    .spec-list {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 7px !important;
    }

    .item-booking-form .btn-primary,
    .item-booking-form .btn-block {
        width: 100%;
    }

    /* --------------------------------------------------------
       Pesanan / tabel mobile
       -------------------------------------------------------- */
    .customer-bookings-page,
    .customer-bookings-head {
        min-width: 0;
    }

    .customer-bookings-filter {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 7px !important;
    }

    .customer-bookings-table {
        width: 100% !important;
        table-layout: fixed !important;
    }

    .customer-bookings-table th,
    .customer-bookings-table td {
        min-width: 0 !important;
        padding: 7px 5px !important;
        font-size: .68rem !important;
        overflow-wrap: anywhere;
    }

    .booking-code-link {
        font-size: .7rem !important;
    }

    .booking-created-at,
    .booking-detail-mini {
        font-size: .58rem !important;
    }

    .table-wrap {
        width: 100%;
        max-width: 100%;
        margin-inline: 0 !important;
        border-radius: 12px;
    }

    /* tabel lain tetap bisa diakses tanpa merusak layout */
    .table-wrap:not(:has(.customer-bookings-table)) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    /* --------------------------------------------------------
       Login / profile / register
       -------------------------------------------------------- */
    .auth-shell,
    .social-auth-shell,
    .register-provider-shell,
    .rp-profile-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        margin-top: 6px !important;
    }

    .social-auth-grid,
    .register-category-grid,
    .seller-registration-period-grid,
    .tripay-method-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .register-provider-card,
    .rp-location-form-card,
    .register-category-card,
    .seller-registration-period-card,
    .tripay-method-card {
        border-radius: 13px !important;
    }

    .register-category-card,
    .seller-registration-period-card,
    .tripay-method-card {
        padding: 11px !important;
    }

    .tripay-method-collapse-head,
    .tripay-method-toggle {
        min-height: 48px;
    }

    .rp-profile-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 7px !important;
    }

    /* --------------------------------------------------------
       Cart
       -------------------------------------------------------- */
    body.customer-body .summary-row {
        gap: 8px;
    }

    .table-img {
        width: 46px !important;
        height: 46px !important;
        object-fit: cover;
        border-radius: 9px;
    }

    /* --------------------------------------------------------
       Footer publik/customer: lebih pendek di HP
       -------------------------------------------------------- */
    .site-footer {
        padding: 18px 0 calc(86px + env(safe-area-inset-bottom, 0px));
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 13px !important;
    }

    .footer-brand p {
        max-width: 34rem;
        margin-bottom: 0;
        font-size: .78rem;
    }

    .footer-links {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px 10px !important;
    }

    .footer-links a {
        min-height: 36px;
        display: flex;
        align-items: center;
        font-size: .72rem;
    }

    .footer-right {
        font-size: .68rem;
        line-height: 1.45;
    }

    /* --------------------------------------------------------
       Seller/Admin mobile
       -------------------------------------------------------- */
    body.admin-body {
        overflow-x: hidden;
    }

    .admin-topbar {
        position: sticky;
        top: 0;
        z-index: 1090;
        min-height: calc(58px + env(safe-area-inset-top, 0px));
        padding: calc(7px + env(safe-area-inset-top, 0px)) 10px 7px;
        border-bottom: 1px solid var(--border);
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .admin-topbar-left {
        min-width: 0;
        gap: 8px;
    }

    .admin-topbar h1 {
        max-width: min(52vw, 250px) !important;
        overflow: hidden;
        font-size: .98rem !important;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .admin-content {
        width: 100%;
        max-width: 100%;
        padding: 10px 10px 30px !important;
    }

    .admin-sidebar {
        width: min(86vw, 320px) !important;
        max-width: 320px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .admin-side-menu {
        padding: 6px 8px 18px !important;
    }

    .admin-side-menu a {
        min-height: 44px !important;
        padding: 9px 10px !important;
        border-radius: 10px !important;
        font-size: .81rem !important;
    }

    .admin-menu-icon {
        width: 22px !important;
        height: 22px !important;
        flex: 0 0 22px !important;
    }

    .admin-menu-label {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .admin-content .grid.grid-3,
    .admin-content .grid.grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .admin-content .grid.grid-2 {
        grid-template-columns: 1fr !important;
    }

    .admin-content .actions {
        gap: 7px;
    }

    .admin-content .actions .btn {
        flex: 1 1 auto;
    }

    .ops-filter-chips {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: 3px;
        scrollbar-width: none;
    }

    .ops-filter-chips::-webkit-scrollbar {
        display: none;
    }

    .ops-filter-chip {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    /* Super admin tidak sesak di HP */
    .super-admin-control,
    .super-admin-section,
    .super-admin-table {
        min-width: 0;
        max-width: 100%;
    }

    /* kalender lebih nyaman */
    .ops-calendar-summary {
        min-height: 48px;
        padding: 10px 11px !important;
    }

    .ops-calendar-disclosure-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --------------------------------------------------------
       Dark mode: hindari panel terang/teks samar tersisa
       -------------------------------------------------------- */
    html[data-theme="dark"] .site-header,
    html[data-theme="dark"] .customer-header,
    html[data-theme="dark"] .admin-topbar,
    html[data-theme="dark"] .customer-bottom-nav.customer-bottom-nav-minimal {
        background: rgba(11, 18, 32, .94) !important;
    }

    html[data-theme="dark"] .customer-more-sheet,
    html[data-theme="dark"] body.public-body .main-nav {
        background: var(--surface) !important;
        color: var(--text) !important;
    }

    html[data-theme="dark"] .hero,
    html[data-theme="dark"] .card,
    html[data-theme="dark"] .search-panel,
    html[data-theme="dark"] .rp-nearby-hero,
    html[data-theme="dark"] .rp-nearby-filter,
    html[data-theme="dark"] .rp-nearby-store-card,
    html[data-theme="dark"] .register-provider-card,
    html[data-theme="dark"] .tripay-method-card {
        color: var(--text);
    }

    html[data-theme="dark"] input,
    html[data-theme="dark"] select,
    html[data-theme="dark"] textarea {
        color: var(--text);
        background: var(--surface-2);
        border-color: var(--border);
    }

    html[data-theme="dark"] input::placeholder,
    html[data-theme="dark"] textarea::placeholder {
        color: #91a1b8;
        opacity: 1;
    }
}

@media (max-width: 390px) {
    .container {
        padding-inline: 9px;
    }

    .customer-mobile-header-actions,
    .admin-mobile-header-actions {
        gap: 4px !important;
    }

    .customer-mobile-header-button,
    .customer-mobile-profile-shortcut,
    .admin-mobile-header-button,
    .admin-mobile-profile-button {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        flex-basis: 34px !important;
    }

    .market-product-grid,
    .market-category-grid,
    #kategori + .grid.grid-4 {
        gap: 7px !important;
    }

    .market-card-body {
        padding: 8px;
    }

    .footer-links {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
