/* =============================================
   MOBILE RESPONSIVE OVERRIDES
   ============================================= */

/* --- Global Mobile Fixes --- */
html {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
}

/* Touch-friendly tap targets */
@media (max-width: 768px) {
    .btn, button, a.nav-link, .form-control, .form-select {
        min-height: 44px;
    }
    .btn-sm {
        min-height: 36px;
        padding: 0.4rem 0.75rem;
    }
}

/* --- Responsive Utility Classes --- */
.d-mobile-none {
    display: revert;
}
@media (max-width: 768px) {
    .d-mobile-none {
        display: none !important;
    }
    .d-mobile-block {
        display: block !important;
    }
    .d-mobile-flex {
        display: flex !important;
    }
    .mobile-stack {
        flex-direction: column !important;
    }
    .mobile-full-width {
        width: 100% !important;
    }
    .mobile-text-sm {
        font-size: 0.78rem !important;
    }
    .mobile-text-xs {
        font-size: 0.68rem !important;
    }
    .mobile-p-2 {
        padding: 0.5rem !important;
    }
    .mobile-gap-2 {
        gap: 0.5rem !important;
    }
}

/* --- Dashboard Sidebar: Tablet + Mobile --- */
@media (max-width: 991.98px) {
    .dashboard-sidebar {
        transform: translateX(-100%);
        z-index: 1050;
        width: 260px;
    }
    .dashboard-sidebar.show {
        transform: translateX(0);
    }
    .dashboard-main {
        margin-left: 0 !important;
    }
    .sidebar-collapsed .dashboard-main {
        margin-left: 0 !important;
    }
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show {
    display: block;
}

/* --- Dashboard Content Mobile --- */
@media (max-width: 768px) {
    .dashboard-content {
        padding: 0.75rem !important;
    }
    .dashboard-topbar {
        padding: 0.5rem 0.75rem !important;
    }
    .card-body {
        padding: 0.75rem !important;
    }
    .card-header {
        padding: 0.6rem 0.75rem !important;
    }
    .card-header h5 {
        font-size: 0.9rem;
    }
    .card-header h6 {
        font-size: 0.82rem;
    }
    /* Reduce gap for nested cards */
    .card .card {
        margin-bottom: 0.5rem;
    }
    .card .card .card-body {
        padding: 0.6rem !important;
    }
}

/* --- Typography Mobile --- */
@media (max-width: 768px) {
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.3rem !important; }
    h3 { font-size: 1.15rem !important; }
    h4 { font-size: 1rem !important; }
    .text-2xl { font-size: 1.25rem !important; }
    .text-3xl { font-size: 1.5rem !important; }
    .text-4xl { font-size: 1.75rem !important; }
}

/* --- Tables Mobile --- */
@media (max-width: 768px) {
    .table-responsive-mobile {
        display: block;
    }
    .overflow-x-auto {
        -webkit-overflow-scrolling: touch;
    }
    .table {
        font-size: 0.78rem;
    }
    .table th {
        font-size: 0.68rem;
        padding: 0.5rem 0.4rem;
        white-space: nowrap;
    }
    .table td {
        padding: 0.5rem 0.4rem;
        font-size: 0.78rem;
    }
    .table td small {
        font-size: 0.68rem;
    }
    .table .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
    }
    .table .btn-sm {
        min-height: 30px;
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }
    .table code {
        font-size: 0.68rem;
        word-break: break-all;
    }
    /* Table minimum width for wide tables */
    .table-wide {
        min-width: 700px;
    }
    .table-extra-wide {
        min-width: 900px;
    }
}

/* --- Mobile Card Table (stacked rows) --- */
@media (max-width: 640px) {
    .table-mobile-cards thead {
        display: none;
    }
    .table-mobile-cards tbody tr {
        display: block;
        padding: 0.75rem;
        border-bottom: 1px solid #e5e7eb;
        margin-bottom: 0;
    }
    .table-mobile-cards tbody tr:last-child {
        border-bottom: none;
    }
    .table-mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border: none;
        font-size: 0.82rem;
    }
    .table-mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        color: #6b7280;
        margin-right: 0.5rem;
        flex-shrink: 0;
    }
    .table-mobile-cards tbody td:first-child {
        padding-top: 0;
    }
    .table-mobile-cards tbody td:last-child {
        padding-bottom: 0;
    }
}

/* --- Grid Mobile --- */
@media (max-width: 768px) {
    .grid.grid-cols-1.md\:grid-cols-4,
    .grid.grid-cols-1.md\:grid-cols-3,
    .grid.grid-cols-1.md\:grid-cols-5,
    .grid.grid-cols-2.md\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 480px) {
    .grid.grid-cols-1.md\:grid-cols-4,
    .grid.grid-cols-1.md\:grid-cols-3,
    .grid.grid-cols-1.md\:grid-cols-5,
    .grid.grid-cols-2.md\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
}

/* Stats cards - 2 col on mobile */
@media (max-width: 640px) {
    .grid.grid-cols-2 {
        gap: 0.5rem !important;
    }
    .grid.grid-cols-2 .card-body {
        padding: 0.5rem !important;
    }
}

/* --- Filter Forms Mobile --- */
@media (max-width: 768px) {
    .grid.items-end {
        grid-template-columns: 1fr !important;
    }
    .grid.items-end .flex.gap-2 {
        display: flex;
        width: 100%;
    }
    .grid.items-end .flex.gap-2 .btn {
        flex: 1;
    }
    /* Filter date range side-by-side on mobile */
    .filter-date-range {
        display: flex;
        gap: 0.5rem;
    }
    .filter-date-range .form-control {
        min-width: 0;
    }
}

/* --- Page Header Mobile --- */
@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    .page-header .btn,
    .page-header .flex {
        align-self: flex-start;
    }
}

/* --- Notification Dropdown Mobile --- */
@media (max-width: 480px) {
    #notifDropdown {
        position: fixed !important;
        left: 0.5rem !important;
        right: 0.5rem !important;
        top: 60px !important;
        width: auto !important;
        max-height: 70vh !important;
        border-radius: 12px !important;
    }
}
@media (min-width: 481px) and (max-width: 768px) {
    #notifDropdown {
        width: 300px !important;
        right: 0 !important;
    }
}

/* --- Flex Layout Mobile --- */
@media (max-width: 640px) {
    .flex.items-center.justify-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .flex.items-center.justify-between h3,
    .flex.items-center.justify-between h4 {
        width: 100%;
    }
    .flex.justify-between.items-center {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .flex.justify-between.items-center h4 {
        width: 100%;
    }
    .flex.gap-1.flex-wrap {
        flex-direction: column;
    }
}

/* --- Badges Mobile --- */
@media (max-width: 640px) {
    .badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.5rem;
    }
}

/* --- Modal Mobile --- */
@media (max-width: 640px) {
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    .modal-body {
        padding: 1rem !important;
    }
}

/* --- Front-end Hero Mobile --- */
@media (max-width: 768px) {
    .header-carousel,
    [style*="height: 420px"],
    [style*="height:420px"] {
        height: 280px !important;
    }
}
@media (max-width: 480px) {
    .header-carousel,
    [style*="height: 420px"],
    [style*="height:420px"] {
        height: 220px !important;
    }
}

/* =============================================
   CLIENT-SIDE / FRONT-END MOBILE FIXES
   ============================================= */

/* --- Navbar Mobile Menu --- */
@media (max-width: 1023px) {
    .nav-mobile-menu.nav-mobile-open {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #163116;
        padding: 0.75rem 1rem 1rem;
        z-index: 50;
        border-top: 1px solid rgba(255,255,255,0.1);
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
        gap: 0.25rem;
    }
    .nav-mobile-menu.nav-mobile-open .nav-mobile-link {
        padding: 0.75rem 0.75rem !important;
        border-radius: 0.375rem;
        font-size: 0.95rem;
        transition: background-color 0.15s;
    }
    .nav-mobile-menu.nav-mobile-open .nav-mobile-link:hover {
        background-color: rgba(255,255,255,0.08);
    }
    /* Auth buttons in mobile menu */
    .nav-mobile-menu.nav-mobile-open .nav-mobile-auth {
        padding-top: 0.75rem;
        margin-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.1);
        width: 100%;
        gap: 0.5rem;
    }
    .nav-mobile-menu.nav-mobile-open .nav-mobile-auth .btn {
        flex: 1;
        text-align: center;
    }
    /* Profile dropdown in mobile menu */
    .nav-mobile-menu.nav-mobile-open .nav-profile-dropdown {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        top: auto !important;
        width: auto !important;
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* --- Front-end Navbar Spacing --- */
@media (max-width: 768px) {
    .navbar-campsite .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    /* Profile dropdown fix */
    .nav-profile-dropdown,
    .w-56 {
        width: min(14rem, calc(100vw - 2rem)) !important;
        right: 0 !important;
    }
}

/* --- Hero Search Bar Mobile --- */
@media (max-width: 480px) {
    .hero-search-input {
        padding-right: 3.5rem !important;
        padding-top: 0.875rem !important;
        padding-bottom: 0.875rem !important;
        font-size: 0.8rem !important;
    }
    .hero-search-btn {
        padding: 0.5rem 0.875rem !important;
    }
    .hero-search-label {
        display: none;
    }
    .hero-search-form {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}
@media (min-width: 481px) and (max-width: 768px) {
    .hero-search-input {
        padding-right: 6rem !important;
        padding-top: 0.875rem !important;
        padding-bottom: 0.875rem !important;
    }
    .hero-search-btn {
        padding: 0.5rem 1rem !important;
    }
}

/* --- Hero Slide Text Mobile --- */
@media (max-width: 480px) {
    [style*="height: 420px"] .text-4xl,
    [style*="height:420px"] .text-4xl {
        font-size: 1.4rem !important;
        margin-bottom: 0.5rem !important;
    }
    [style*="height: 420px"] .text-lg,
    [style*="height:420px"] .text-lg {
        font-size: 0.85rem !important;
    }
    [style*="height: 420px"] .mb-6,
    [style*="height:420px"] .mb-6 {
        margin-bottom: 1rem !important;
    }
}

/* --- Campsite Detail Page Mobile --- */
@media (max-width: 1024px) {
    .lg\:col-span-7,
    .lg\:col-span-8 {
        grid-column: span 12 / span 12 !important;
    }
    .lg\:col-span-4,
    .lg\:col-span-5 {
        grid-column: span 12 / span 12 !important;
    }
    .sticky.top-4 {
        position: relative !important;
        top: 0 !important;
    }
}

/* Gallery image responsive height */
@media (max-width: 640px) {
    [style*="height: 300px"],
    [style*="height:300px"] {
        height: 200px !important;
    }
    /* Card images in grids */
    .card-img-top[style*="height: 180px"],
    [style*="height: 180px"].card-img-top,
    .card img[style*="height: 180px"] {
        height: 160px !important;
    }
    [style*="height: 200px"]:not([class*="header"]):not([class*="hero"]) {
        height: 160px !important;
    }
}

/* Gallery thumbnails on mobile */
@media (max-width: 480px) {
    .w-20.h-14 {
        width: 3.5rem !important;
        height: 2.5rem !important;
    }
}

/* --- Search Page Filter Mobile --- */
@media (max-width: 640px) {
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}
@media (min-width: 641px) and (max-width: 768px) {
    .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* --- Cards Grid Mobile --- */
@media (max-width: 640px) {
    .sm\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* Campsite search result cards hover fix for touch */
@media (max-width: 768px) {
    .card[onmouseover] {
        transform: none !important;
        box-shadow: none !important;
    }
}

/* --- Booking Detail 3-col layout Mobile --- */
@media (max-width: 1024px) {
    .lg\:col-span-2 {
        grid-column: span 3 / span 3 !important;
    }
    .grid.grid-cols-1.lg\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
}

/* --- Dashboard stat cards compact mobile --- */
@media (max-width: 480px) {
    .text-2xl.font-bold {
        font-size: 1.1rem !important;
    }
    .text-3xl.font-bold {
        font-size: 1.3rem !important;
    }
}

/* --- Action buttons row mobile --- */
@media (max-width: 640px) {
    .flex.gap-1 {
        flex-wrap: wrap;
    }
    .d-inline {
        display: inline-block !important;
    }
}

/* --- Calendar table mobile --- */
@media (max-width: 768px) {
    .overflow-x-auto {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
}

/* --- Footer mobile --- */
@media (max-width: 640px) {
    .footer-campsite {
        text-align: center;
        padding-top: 1.5rem;
    }
    .footer-campsite .grid {
        grid-template-columns: 1fr !important;
        text-align: center;
        gap: 1.5rem !important;
    }
    .footer-campsite h5 {
        font-size: 1rem;
    }
    .footer-campsite p,
    .footer-campsite li {
        font-size: 0.85rem;
    }
    .footer-bottom {
        margin-top: 1rem;
    }
}

/* --- Auth Pages Mobile (Login/Register) --- */
@media (max-width: 480px) {
    .social-login-buttons {
        flex-direction: column !important;
    }
    .social-login-buttons .btn {
        width: 100% !important;
    }
    .auth-btn-group {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem;
    }
    .auth-btn-group .btn {
        width: 100% !important;
        text-align: center;
    }
}

/* Auth layout container padding */
@media (max-width: 640px) {
    body.bg-cream > .container {
        padding-top: 2rem !important;
    }
}

/* --- Payment Method Grid Mobile --- */
@media (max-width: 480px) {
    .payment-method-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem !important;
    }
    .payment-method-grid button {
        padding: 0.75rem 0.25rem !important;
    }
    .payment-method-grid .text-2xl {
        font-size: 1.25rem !important;
    }
    .payment-method-grid .text-sm {
        font-size: 0.7rem !important;
    }
    .payment-method-grid small {
        font-size: 0.6rem !important;
        display: block;
    }
}
@media (max-width: 360px) {
    .payment-method-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Payment action buttons mobile */
@media (max-width: 640px) {
    .payment-actions {
        flex-direction: column !important;
    }
    .payment-actions .btn {
        width: 100% !important;
        text-align: center;
    }
    .payment-actions .btn-lg {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }
}

/* Saved card labels mobile */
@media (max-width: 480px) {
    .saved-card-label {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
    .saved-card-label .badge {
        margin-left: 0;
    }
}

/* --- Wallet Page Mobile --- */
@media (max-width: 640px) {
    .wallet-card-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .wallet-card-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .wallet-card-actions .btn {
        flex: 1;
    }
}

/* --- Wallet / Payment cards mobile --- */
@media (max-width: 640px) {
    .card .grid.grid-cols-1.md\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* --- Profile / Linked Accounts Mobile --- */
@media (max-width: 480px) {
    .linked-account-card {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .linked-account-card > div:last-child {
        width: 100%;
    }
    .linked-account-card .btn {
        width: 100%;
    }
}

/* --- Invoice Page Mobile --- */
@media (max-width: 640px) {
    .invoice-header {
        flex-direction: column !important;
        gap: 1rem;
    }
    .invoice-header .text-right {
        text-align: left !important;
    }
    .invoice-topbar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .invoice-topbar .no-print {
        width: 100%;
    }
    .invoice-topbar .no-print .btn {
        flex: 1;
    }
}

/* --- Booking Confirmation Buttons Mobile --- */
@media (max-width: 480px) {
    .confirmation-actions {
        flex-direction: column !important;
    }
    .confirmation-actions .btn {
        width: 100% !important;
        text-align: center;
    }
}

/* --- Contact Page Sidebar Mobile --- */
@media (max-width: 1024px) {
    .lg\:col-span-7 {
        grid-column: span 12 / span 12 !important;
    }
    .lg\:col-span-5 {
        grid-column: span 12 / span 12 !important;
    }
}

/* --- Search Modal Mobile --- */
@media (max-width: 480px) {
    .mt-24 {
        margin-top: 4rem !important;
    }
    [class*="max-w-xl"] {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }
}

/* --- Notification page mobile --- */
@media (max-width: 640px) {
    #notifList button,
    .notification-item {
        padding: 10px 12px !important;
    }
    .notif-item-btn {
        padding: 10px 12px !important;
    }
    .notif-item-btn .flex {
        gap: 0.5rem !important;
    }
}

/* --- Search/filter input group mobile --- */
@media (max-width: 480px) {
    .input-group {
        flex-direction: column;
    }
    .input-group .form-control {
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem;
    }
}

/* --- Location add forms mobile --- */
@media (max-width: 640px) {
    .flex.gap-3.items-end.flex-wrap {
        flex-direction: column;
        align-items: stretch !important;
    }
    .flex.gap-3.items-end.flex-wrap > div,
    .flex.gap-3.items-end.flex-wrap > .flex-1 {
        width: 100%;
    }
    .flex.gap-3.items-end.flex-wrap .btn {
        width: 100%;
    }
    .flex.flex-wrap.gap-3.items-end {
        flex-direction: column;
        align-items: stretch !important;
    }
    .flex.flex-wrap.gap-3.items-end > div,
    .flex.flex-wrap.gap-3.items-end > .flex-1 {
        width: 100%;
    }
    .flex.flex-wrap.gap-3.items-end .btn {
        width: 100%;
    }
}

/* --- Blog post table mobile --- */
@media (max-width: 768px) {
    .blog-thumb {
        width: 36px !important;
        height: 36px !important;
    }
    .blog-thumb-placeholder {
        width: 36px !important;
        height: 36px !important;
    }
}

/* --- Quill editor mobile --- */
@media (max-width: 768px) {
    #editor {
        min-height: 250px !important;
    }
    .ql-toolbar {
        flex-wrap: wrap;
    }
    .ql-toolbar .ql-formats {
        margin-right: 8px !important;
    }
}

/* --- Blog/CMS editor layout mobile --- */
@media (max-width: 1024px) {
    .grid.grid-cols-1.lg\:grid-cols-3 .lg\:col-span-2 {
        grid-column: span 1 !important;
    }
}

/* --- SSO cards mobile --- */
@media (max-width: 640px) {
    .sso-card {
        padding: 0.6rem !important;
    }
    .sso-card .fa-2x {
        font-size: 1.3rem !important;
    }
}

/* --- Detail page info grid mobile --- */
@media (max-width: 640px) {
    .info-grid {
        grid-template-columns: 1fr !important;
    }
    .info-grid p {
        margin-bottom: 0.25rem;
    }
}

/* --- Auth summary list mobile --- */
@media (max-width: 640px) {
    .auth-summary-list li {
        font-size: 0.82rem;
        padding: 0.4rem 0 !important;
    }
}

/* --- Withdrawal action buttons mobile --- */
@media (max-width: 640px) {
    .withdrawal-actions {
        flex-direction: column;
        gap: 0.25rem !important;
    }
    .withdrawal-actions form {
        width: 100%;
    }
    .withdrawal-actions .btn {
        width: 100%;
    }
}

/* --- FAQ Accordion Mobile --- */
@media (max-width: 640px) {
    .card-body .space-y-4 > div {
        margin-bottom: 0.5rem;
    }
}

/* --- Blog Cards Mobile --- */
@media (max-width: 640px) {
    .grid.grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }
}

/* --- Campsite Card on Homepage Mobile --- */
@media (max-width: 640px) {
    .grid.grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
}

/* --- Smooth scrolling for overflow --- */
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.overflow-x-auto::-webkit-scrollbar {
    height: 4px;
}
.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* --- Safe area for iOS notch devices --- */
@supports (padding: max(0px)) {
    .navbar-campsite {
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }
    .footer-campsite {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* --- Print hide sidebar/topbar --- */
@media print {
    .dashboard-sidebar,
    .dashboard-topbar,
    .sidebar-overlay {
        display: none !important;
    }
    .dashboard-main {
        margin-left: 0 !important;
    }
}
