/* Mobile-specific styles for WhyRent */

/* Add extra small breakpoint */
@media (min-width: 375px) {
    .xs\:inline {
        display: inline !important;
    }
    
    .xs\:block {
        display: block !important;
    }
    
    .xs\:flex {
        display: flex !important;
    }
    
    .xs\:hidden {
        display: none !important;
    }
}

@media (max-width: 768px) {
    body {
        background-color: #fff;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        padding-top: 70px; /* Space for fixed header */
        padding-bottom: 70px; /* Space for bottom nav (removed on homepage via JS) */
    }

    /* Mobile Request to Rent Button Styling */
    .mobile-only-button,
    #mobile-rent-button {
        position: fixed !important;
        bottom: 120px !important;
        left: 16px !important;
        right: 16px !important;
        z-index: 99999 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .mobile-only-button button,
    .mobile-only-button a,
    #mobile-rent-button button,
    #mobile-rent-button a {
        width: 100% !important;
        background-color: #8B5CF6 !important;
        color: white !important;
        padding: 16px 24px !important;
        border-radius: 12px !important;
        font-weight: 600 !important;
        font-size: 18px !important;
        border: none !important;
        box-shadow: 0 10px 25px rgba(139, 92, 246, 0.3) !important;
        text-decoration: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.3s ease !important;
        cursor: pointer !important;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
        position: relative !important;
    }

    .mobile-only-button button:hover,
    .mobile-only-button a:hover,
    #mobile-rent-button button:hover,
    #mobile-rent-button a:hover {
        background-color: #7C3AED !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 15px 30px rgba(139, 92, 246, 0.4) !important;
    }

    /* Ensure mobile tab bar is below the rent button */
    .mobile-tab-bar {
        z-index: 9998 !important;
    }

    /* Add extra padding when mobile tab bar is present */
    body.has-mobile-tab-bar {
        padding-bottom: 180px !important;
    }

    /* Mobile modal fixes */
    body.modal-open {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile modal container */
    #rentalDetailsModal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        z-index: 9999 !important;
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        background-color: rgba(0, 0, 0, 0.5);
    }

    /* Mobile modal content */
    #rentalDetailsModal .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        background: white;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix for rental cards on mobile */
    .rental-card {
        margin-bottom: 1rem;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Mobile rental grid */
    .rentals-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }

    #rentalDetailsModal .bg-white {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #rentalDetailsModal .max-h-\[70vh\] {
        max-height: none !important;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure modal content is scrollable */
    #rentalDetailsModal #rentalDetailsContent {
        padding: 1rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix modal header on mobile */
    #rentalDetailsModal .px-6.py-4 {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        border-bottom: 1px solid #e5e7eb;
    }

    /* Fix modal footer on mobile */
    #rentalDetailsModal .bg-gray-50 {
        position: sticky;
        bottom: 0;
        background: white !important;
        z-index: 10;
        border-top: 1px solid #e5e7eb;
        padding: 1rem;
    }

    /* Mobile modal close button improvements */
    #rentalDetailsModal .close-modal-btn,
    #closeRentalDetailsModal,
    #closeRentalDetailsBtn {
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        -webkit-tap-highlight-color: transparent;
        cursor: pointer !important;
        pointer-events: auto !important;
        z-index: 9999 !important;
        position: relative !important;
    }

    /* Improve touch targets for mobile */
    #rentalDetailsModal button {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* Prevent mobile zoom on double tap */
    #rentalDetailsModal * {
        touch-action: manipulation;
    }

    /* Mobile modal overlay improvements */
    #rentalDetailsModal::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        pointer-events: auto;
    }
    
    /* Remove bottom padding on homepage */
    body.is-homepage {
        padding-bottom: 30px; /* Less padding since no bottom nav */
    }

    /* Mobile Messages Interface */
    .messages-mobile-container {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        bottom: 70px;
        background: white;
        z-index: 10;
    }

    #mobileConversationsList {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        overflow-y: auto;
        z-index: 11;
    }

    #mobileChatView {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 12;
        display: flex;
        flex-direction: column;
    }

    #mobileChatView.hidden {
        display: none !important;
    }

    #mobileConversationsList.hidden {
        display: none !important;
    }

    /* Mobile conversation items */
    .mobile-conversation-item {
        border-bottom: 1px solid #f3f4f6;
        padding: 16px;
        background: white;
        transition: background-color 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-conversation-item:active {
        background-color: #f9fafb;
    }

    .mobile-conversation-item:last-child {
        border-bottom: none;
    }

    /* Mobile chat header */
    #mobileChatView .mobile-chat-header {
        background: white;
        border-bottom: 1px solid #e5e7eb;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        min-height: 60px;
        flex-shrink: 0;
    }

    /* Mobile messages container */
    #mobileMessagesContainer {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
        background: #f9fafb;
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile message input */
    #mobileChatView .mobile-message-input {
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 16px;
        flex-shrink: 0;
    }

    /* Ensure desktop messages are hidden on mobile */
    .hidden.md\\:flex {
        display: none !important;
    }

    /* Hide desktop right panel on mobile */
    #chatArea:not(#mobileConversationsList):not(#mobileChatView) {
        display: none !important;
    }
    
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    /* Make clickable elements larger on mobile */
    button, a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Dashboard mobile sidebar styles */
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    #sidebar.sidebar-mobile-open {
        transform: translateX(0);
        z-index: 50;
    }
    
    /* Mobile overlay styles - DISABLED to prevent blocking background interactions
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        display: none;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 40;
    }
    
    .overlay.active {
        display: block;
        opacity: 1;
        pointer-events: auto;
        z-index: 40;
    }
    */
    
    /* Button optimizations */
    button, .button, [class*="!rounded-button"] {
        border-radius: 8px !important;
    }
    
    /* Header bar customization for mobile */
    header {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        background-color: #fff;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 40;
    }
    
    header .container {
        padding: 0.5rem 0.75rem;
    }
    
    /* Mobile logo style */
    header .logo {
        font-family: 'Pacifico', cursive;
        color: #8B5CF6;
        font-size: 1.25rem;
    }
    
    /* Mobile search input style */
    header .search-container {
        background-color: #F9FAFB;
        border-radius: 9999px;
        padding: 0.5rem 1rem;
        display: flex;
        align-items: center;
    }
    
    header .search-container i {
        color: #9CA3AF;
        margin-right: 0.5rem;
    }
    
    header .search-container input {
        background: transparent;
        border: none;
        outline: none;
        font-size: 0.875rem;
        width: 100%;
    }
    
    /* Mobile user profile section */
    .user-profile-section {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        background-color: #fff;
        margin-top: 3.5rem;
    }
    
    .user-profile-section .avatar {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 9999px;
        object-fit: cover;
        margin-right: 0.75rem;
    }
    
    .user-profile-section .user-info h2 {
        font-size: 0.9375rem;
        font-weight: 500;
        margin: 0;
    }
    
    .user-profile-section .user-info .rating {
        display: flex;
        align-items: center;
        font-size: 0.75rem;
        color: #4B5563;
    }
    
    .user-profile-section .user-info .rating i {
        color: #F59E0B;
        margin-right: 0.25rem;
    }
    
    /* Welcome message */
    .welcome-section {
        padding: 0.5rem 1rem 1rem;
    }
    
    .welcome-section h1 {
        font-size: 1.25rem;
        font-weight: 600;
        margin: 0 0 0.25rem 0;
    }
    
    .welcome-section p {
        color: #6B7280;
        font-size: 0.875rem;
        margin: 0;
    }
    
    /* Stats cards */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.5rem 1rem 1.5rem;
    }
    
    .stat-card {
        background-color: #F9FAFB;
        border-radius: 0.75rem;
        padding: 1rem;
        position: relative;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }
    
    .stat-card .icon {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        width: 1.5rem;
        height: 1.5rem;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .stat-card .icon.purple {
        background-color: rgba(139, 92, 246, 0.1);
        color: #8B5CF6;
    }
    
    .stat-card .icon.blue {
        background-color: rgba(96, 165, 250, 0.1);
        color: #3B82F6;
    }
    
    .stat-card .icon.green {
        background-color: rgba(16, 185, 129, 0.1);
        color: #10B981;
    }
    
    .stat-card .icon.yellow {
        background-color: rgba(245, 158, 11, 0.1);
        color: #F59E0B;
    }
    
    .stat-card .label {
        font-size: 0.75rem;
        color: #6B7280;
        margin-bottom: 0.5rem;
    }
    
    .stat-card .value {
        font-size: 1.25rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
    }
    
    .stat-card .change {
        font-size: 0.6875rem;
        color: #10B981;
        display: flex;
        align-items: center;
    }
    
    .stat-card .change i {
        margin-right: 0.25rem;
    }
    
    /* Section headers */
    .section-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 1rem 0.75rem;
        margin-top: 0.75rem;
    }
    
    .section-header h2 {
        font-size: 1rem;
        font-weight: 600;
        margin: 0;
    }
    
    .section-header .view-all {
        color: #8B5CF6;
        font-size: 0.875rem;
        text-decoration: none;
    }
    
    .section-header .date-selector {
        display: flex;
        align-items: center;
        background-color: #F9FAFB;
        padding: 0.25rem 0.75rem;
        border-radius: 9999px;
        font-size: 0.75rem;
        color: #4B5563;
    }
    
    .section-header .date-selector i {
        margin-left: 0.25rem;
    }
    
    /* Chart section */
    .chart-container {
        padding: 0 1rem;
        margin-bottom: 1rem;
    }
    
    .chart-wrapper {
        background-color: #F9FAFB;
        border-radius: 0.75rem;
        padding: 0.75rem;
        height: 12rem;
        overflow: hidden;
    }
    
    /* Activity feed */
    .activity-feed {
        padding: 0 1rem;
    }
    
    .activity-item {
        display: flex;
        padding: 0.75rem 0;
        border-bottom: 1px solid #F3F4F6;
    }
    
    .activity-item:last-child {
        border-bottom: none;
    }
    
    .activity-item .icon-wrapper {
        width: 2rem;
        height: 2rem;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 0.75rem;
        flex-shrink: 0;
    }
    
    .activity-item .icon-wrapper.blue {
        background-color: #EFF6FF;
        color: #3B82F6;
    }
    
    .activity-item .icon-wrapper.green {
        background-color: #ECFDF5;
        color: #10B981;
    }
    
    .activity-item .icon-wrapper.yellow {
        background-color: #FFFBEB;
        color: #F59E0B;
    }
    
    .activity-item .icon-wrapper.purple {
        background-color: #F5F3FF;
        color: #8B5CF6;
    }
    
    .activity-item .content {
        flex: 1;
    }
    
    .activity-item .content p {
        margin: 0;
        font-size: 0.875rem;
    }
    
    .activity-item .content .time {
        color: #9CA3AF;
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }
    
    /* Active rentals */
    .rentals-list {
        padding: 0 1rem 5rem; /* Extra padding at bottom for navigation */
    }
    
    .rental-item {
        display: flex;
        background-color: #F9FAFB;
        border-radius: 0.75rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .rental-item .image {
        width: 3rem;
        height: 3rem;
        border-radius: 0.5rem;
        overflow: hidden;
        margin-right: 0.75rem;
        flex-shrink: 0;
    }
    
    .rental-item .image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .rental-item .details {
        flex: 1;
    }
    
    .rental-item .details .item-title {
        font-weight: 500;
        font-size: 0.875rem;
        margin: 0;
    }
    
    .rental-item .details .item-subtitle {
        color: #6B7280;
        font-size: 0.75rem;
        margin: 0.25rem 0 0.5rem;
    }
    
    .rental-item .details .item-status {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .rental-item .details .price {
        font-weight: 500;
        font-size: 0.875rem;
    }
    
    .rental-item .details .badge {
        font-size: 0.75rem;
        padding: 0.125rem 0.5rem;
        border-radius: 9999px;
    }
    
    .rental-item .details .badge.blue {
        background-color: #EFF6FF;
        color: #3B82F6;
    }
    
    .rental-item .details .badge.green {
        background-color: #ECFDF5;
        color: #10B981;
    }
    
    .rental-item .details .badge.gray {
        background-color: #F3F4F6;
        color: #6B7280;
    }
    
    .rental-item .details .dates {
        font-size: 0.75rem;
        color: #6B7280;
        margin-top: 0.25rem;
    }
    
    /* Mobile sidebar menu */
    .mobile-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 80%;
        max-width: 20rem;
        height: 100vh;
        background-color: white;
        z-index: 50;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .mobile-sidebar.open {
        transform: translateX(0);
    }
    
    /* Mobile sidebar styles */
    #mobileSidebar {
        display: block;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        z-index: 50;
    }
    
    #mobileSidebar.open {
        transform: translateX(0);
    }
    
    .mobile-sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid #F3F4F6;
    }
    
    .mobile-sidebar-header .logo {
        font-family: 'Pacifico', cursive;
        color: #8B5CF6;
        font-size: 1.25rem;
    }
    
    .mobile-sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding: 0.5rem 0;
    }
    
    .mobile-sidebar-nav {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .mobile-sidebar-nav li a {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        color: #4B5563;
        text-decoration: none;
        transition: background-color 0.2s ease;
    }
    
    .mobile-sidebar-nav li a.active {
        background-color: rgba(139, 92, 246, 0.1);
        color: #8B5CF6;
    }
    
    .mobile-sidebar-nav li a:hover {
        background-color: #F9FAFB;
    }
    
    .mobile-sidebar-nav li a i {
        margin-right: 0.75rem;
        font-size: 1.25rem;
    }
    
    /* Mobile overlay - DISABLED to prevent blocking background interactions
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 40;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .mobile-overlay.open {
        opacity: 1;
        visibility: visible;
    }
    */
    
    /* Bottom navigation */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: white;
        display: flex;
        justify-content: space-around;
        padding: 0.5rem 0.25rem;
        box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.1);
        z-index: 30;
    }
    
    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #6B7280;
        text-decoration: none;
        font-size: 0.625rem;
        width: 20%;
    }
    
    .mobile-bottom-nav a.active {
        color: #8B5CF6;
    }
    
    .mobile-bottom-nav a i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }
    
    /* Bottom spacer to account for bottom navigation */
    .mobile-bottom-spacer {
        height: 4rem;
    }

    /* Adjust padding for main content */
    .main-content {
        padding-top: 0 !important;
        margin-left: 0 !important;
    }
    
    /* Mobile sidebar specific styles */
    #mobileSidebar {
        display: block;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        z-index: 50;
    }
    
    #mobileSidebar.open {
        transform: translateX(0);
    }
    
    /* Make close button more visible and larger target */
    #closeMenu {
        width: 44px !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
    }
    
    #closeMenu:hover, #closeMenu:active {
        background-color: rgba(0,0,0,0.05);
    }
    
    #closeMenu i {
        font-size: 24px;
    }
    
    /* Mobile overlay - DISABLED to prevent blocking background interactions
    #mobileOverlay {
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
        z-index: 45 !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        pointer-events: none;
    }
    
    #mobileOverlay.active {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
    */
    
    /* Bottom navigation style improvements */
    #mobileBottomNav {
        height: 64px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }
    
    /* Mobile navigation elements with better touch targets and spacing */
    #mobileBottomNav a, 
    #mobileBottomNav button {
        min-height: 48px;
        min-width: 48px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        position: relative;
    }
    
    /* Highlight active bottom nav item */
    #mobileBottomNav a.text-primary::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 30%;
        right: 30%;
        height: 2px;
        background-color: currentColor;
        border-radius: 2px;
    }
    
    /* Special styling for login button in bottom nav */
    #mobileBottomNav a.gradient-bg {
        margin-top: -5px;
        padding-top: 5px;
        border-radius: 8px 8px 0 0;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
    
    .mobile-bottom-nav,
    .mobile-sidebar,
    .mobile-bottom-spacer {
        display: none !important;
    }
}