/* ============================================================
   StartoRent Mobile Responsive Overrides
   Applied after all other CSS. Fixes mobile layout issues.
   ============================================================ */

/* ---- GLOBAL FIXES ---- */

/* Prevent horizontal overflow everywhere */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

img {
    max-width: 100%;
    height: auto;
}

/* ---- MOBILE OFF-CANVAS SIDEBAR ---- */
.mobile-sidebar-panel {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 1060;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

.mobile-sidebar-panel.open {
    left: 0;
}

.mobile-sidebar-header {
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-sidebar-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.mobile-sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1055;
    display: none;
}

.mobile-sidebar-overlay.open {
    display: block;
}

body.sidebar-open {
    overflow: hidden;
}

/* ---- SMALL PHONES (< 576px) ---- */
@media (max-width: 575.98px) {

    /* Body: reduce top padding for smaller navbar on mobile */
    body {
        padding-top: 80px !important;
    }

    /* Homepage search form - stack all fields vertically */
    #filter-form .row {
        flex-direction: column !important;
    }

    #filter-form .row .col,
    #filter-form .row [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    #filter-form .form-control-modern,
    #filter-form .form-select-modern {
        width: 100% !important;
        font-size: 16px !important; /* Prevent iOS zoom */
    }

    /* Listings section - reduce padding */
    #listings-section {
        padding: 1rem 0 !important;
    }

    #listings-section .row.pt-5 {
        padding-top: 0.5rem !important;
    }

    /* Hero Section */
    .hero-section {
        min-height: auto !important;
        padding: 30px 0 !important;
    }

    .hero-section .display-4,
    .hero-section h1 {
        font-size: 1.6rem !important;
        line-height: 1.3 !important;
    }

    .hero-section .lead,
    .hero-section p.lead {
        font-size: 0.95rem !important;
    }

    .hero-stats {
        padding: 12px !important;
    }

    .hero-stats .stat-item h3 {
        font-size: 1.3rem !important;
    }

    .hero-stats .stat-item small {
        font-size: 0.75rem !important;
    }

    /* Hero CTA buttons */
    .hero-section .btn-lg {
        padding: 10px 20px !important;
        font-size: 0.9rem !important;
    }

    /* Filter/Search elements */
    .filter-select {
        min-width: 100% !important;
        width: 100% !important;
        font-size: 14px !important;
    }

    .dropdown-menu {
        min-width: 100% !important;
        max-width: calc(100vw - 30px) !important;
    }

    .search-container {
        flex-direction: column;
        gap: 8px;
    }

    /* Cards - full width */
    .card {
        margin-bottom: 12px;
    }

    .card-img-top {
        max-height: 180px;
    }

    /* Dashboard Hero */
    .dashboard-hero {
        margin: -10px -12px 20px -12px !important;
        padding: 24px 0 !important;
        border-radius: 0 0 12px 12px !important;
    }

    .dashboard-hero h2 {
        font-size: 1.4rem !important;
    }

    .dashboard-hero p {
        font-size: 0.9rem !important;
    }

    /* KPI Cards */
    .card.dashboard-kpi-card h3 {
        font-size: 1.3rem !important;
    }

    .card.dashboard-kpi-card {
        border-radius: 10px !important;
    }

    /* Dashboard Quick Actions */
    .dashboard-action-btn {
        padding: 10px 12px !important;
        font-size: 0.8rem !important;
        gap: 6px !important;
    }

    .quick-actions {
        padding: 12px !important;
    }

    /* Listing Detail */
    .info-label {
        width: 100px !important;
        font-size: 0.82rem !important;
    }

    /* Vendor Stats Bar */
    .vendor-stats-bar,
    .vendor-stats {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .vendor-stats-bar .stat-item,
    .vendor-stats .stat-item {
        flex: 1 1 45% !important;
        min-width: 0 !important;
        text-align: center !important;
        padding: 8px !important;
    }

    /* Vendor Hero */
    .vendor-hero {
        padding: 24px 16px !important;
    }

    .vendor-avatar {
        width: 80px !important;
        height: 80px !important;
    }

    /* Rental History Cards */
    .rental-card {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .rental-image {
        width: 100% !important;
        height: 160px !important;
        border-radius: 8px !important;
    }

    .rental-dates {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Notification Cards */
    .notification-card {
        flex-wrap: wrap !important;
    }

    .notification-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.9rem !important;
    }

    /* Messages / Inbox */
    .conversation-avatar img {
        width: 40px !important;
        height: 40px !important;
    }

    /* Create Listing Stepper */
    .stepper-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    .stepper-circle {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.75rem !important;
    }

    .stepper-wrapper .stepper-label,
    .step-label {
        font-size: 0.65rem !important;
        max-width: 60px;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .wizard-container {
        margin: 1rem auto !important;
    }

    .wizard-card {
        padding: 1.25rem !important;
    }

    .wizard-header h1 {
        font-size: 1.4rem !important;
    }

    /* Tables */
    .table-responsive {
        border: 0;
    }

    .table th,
    .table td {
        padding: 8px 6px !important;
        font-size: 0.8rem !important;
    }

    /* Profile Page */
    .profile-header h2 {
        font-size: 1.4rem !important;
    }

    .profile-avatar {
        width: 72px !important;
        height: 72px !important;
    }

    .profile-header-content {
        gap: 0.75rem !important;
    }

    /* Pricing Page */
    .pricing-hero {
        padding: 30px 15px 20px !important;
    }

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

    .pricing-hero p {
        font-size: 0.9rem !important;
    }

    .plan-card {
        padding: 20px 16px !important;
    }

    .plan-card h3 {
        font-size: 1.2rem !important;
    }

    .plan-card .price {
        font-size: 1.8rem !important;
    }

    /* Pricing comparison table */
    .table-comparison {
        font-size: 0.75rem !important;
    }

    .table-comparison th,
    .table-comparison td {
        padding: 6px 4px !important;
    }

    /* Category Sidebar - full width on mobile with proper visibility */
    .category-page-container .col-md-3 {
        display: none !important;
    }
    .category-page-container .col-md-9 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
    .category-card {
        position: static !important;
    }

    /* Forms */
    .col-md-6 .form-control,
    .col-md-6 .form-select {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    /* Contract Analytics */
    .contract-analytics .col-md-3 {
        margin-bottom: 8px;
    }

    /* Admin Tools */
    .admin-tools .stat-mini .val {
        font-size: 1.1rem !important;
    }

    .kb-entry-question {
        font-size: 0.82rem !important;
    }

    /* Footer */
    .footer {
        margin-top: 2rem !important;
        padding: 24px 0 !important;
    }

    /* Headings general */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.3rem !important; }
    h3 { font-size: 1.15rem !important; }

    /* Navbar on mobile */
    .navbar {
        padding: 8px 12px !important;
    }

    .navbar-brand img {
        height: 55px !important;
        max-height: 55px !important;
    }

    /* Language selector */
    .navbar .form-select-sm {
        width: 100% !important;
        margin-top: 8px;
    }

    /* Buttons minimum touch target */
    .btn {
        min-height: 44px;
        padding: 8px 16px;
    }

    .btn-sm {
        min-height: 36px;
    }
}

/* ---- MEDIUM PHONES (576px - 767px) ---- */
@media (min-width: 576px) and (max-width: 767.98px) {

    /* Homepage search form - stack fields */
    #filter-form .row {
        flex-direction: column !important;
    }

    #filter-form .row .col,
    #filter-form .row [class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    #listings-section {
        padding: 1.5rem 0 !important;
    }

    #listings-section .row.pt-5 {
        padding-top: 1rem !important;
    }

    .hero-section {
        min-height: auto !important;
        padding: 36px 0 !important;
    }

    .hero-section .display-4,
    .hero-section h1 {
        font-size: 2rem !important;
    }

    .filter-select {
        min-width: 200px !important;
    }

    .dashboard-hero h2 {
        font-size: 1.6rem !important;
    }

    .rental-card {
        flex-wrap: wrap !important;
    }

    .rental-image {
        width: 100px !important;
        height: 100px !important;
    }

    .vendor-stats-bar,
    .vendor-stats {
        flex-wrap: wrap !important;
    }

    .stepper-circle {
        width: 40px !important;
        height: 40px !important;
    }
}

/* ---- TABLETS (768px - 991px) ---- */
@media (min-width: 768px) and (max-width: 991.98px) {

    .hero-section {
        min-height: 45vh !important;
    }

    .hero-section .display-4 {
        font-size: 2.4rem !important;
    }

    .filter-select {
        min-width: 200px !important;
    }

    .vendor-stats-bar .stat-item {
        padding: 10px !important;
    }

    .pricing-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ---- LANDSCAPE PHONES ---- */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        min-height: auto !important;
        padding: 20px 0 !important;
    }

    body {
        padding-top: 60px !important;
    }
}

/* ---- CHAT WIDGET MOBILE FIXES ---- */
@media (max-width: 575.98px) {
    #sr-chat-box {
        width: calc(100vw - 16px) !important;
        right: 8px !important;
        bottom: 80px !important;
        max-height: 65vh !important;
        border-radius: 12px !important;
    }

    #sr-chat-toggle {
        width: 52px !important;
        height: 52px !important;
        bottom: 16px !important;
        right: 16px !important;
    }

    #sr-chat-messages {
        min-height: 200px !important;
        max-height: 45vh !important;
    }

    #sr-chat-input {
        font-size: 16px !important; /* Prevent iOS zoom */
    }
}

/* ---- FIX: Prevent inline style overrides ---- */
@media (max-width: 575.98px) {
    /* Override any inline font-size on hero elements */
    [style*="font-size: 3rem"],
    [style*="font-size:3rem"] {
        font-size: 1.6rem !important;
    }

    [style*="font-size: 2.5rem"],
    [style*="font-size:2.5rem"] {
        font-size: 1.4rem !important;
    }

    [style*="font-size: 2rem"],
    [style*="font-size:2rem"] {
        font-size: 1.3rem !important;
    }

    [style*="min-height: 60vh"],
    [style*="min-height:60vh"] {
        min-height: auto !important;
    }

    [style*="padding: 40px"],
    [style*="padding:40px"] {
        padding: 20px 0 !important;
    }
}
