/**
 * Mobile Responsiveness Fixes
 *
 * Fixes horizontal scrolling issues on mobile devices (375px viewport)
 * Applied globally to prevent overflow on all pages
 */

/* Prevent horizontal overflow on body and html */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Ensure all containers respect viewport width */
.container,
.container-fluid,
.container-small,
.container-medium,
.container-large {
    max-width: 100%;
    overflow-x: hidden;
}

/* Make all images responsive by default */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive tables - wrap in scrollable container on mobile */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Alternative: make tables stack on mobile */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Fix cards and panels that might overflow */
.card,
.panel,
.pricing-card,
.service-card {
    max-width: 100%;
    overflow: hidden;
}

/* Ensure grid items don't overflow */
.row {
    margin-left: -15px;
    margin-right: -15px;
}

.row > * {
    max-width: 100%;
}

/* Fix for pre and code blocks that might cause overflow */
pre,
code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Responsive video embeds */
iframe,
embed,
object,
video {
    max-width: 100%;
    height: auto;
}

/* Fix wide content in mobile */
@media (max-width: 575px) {
    /* Reduce padding on mobile to prevent overflow */
    .px-3 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .px-5 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Ensure buttons don't overflow */
    .btn {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Stack navbar items on mobile */
    .navbar-nav {
        flex-direction: column;
    }

    /* Make form inputs full width on mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    select,
    textarea {
        max-width: 100%;
    }
}

/* Fix specific Phoenix theme issues */
.min-vh-100 {
    min-height: 100vh;
    overflow-x: hidden;
}

/* Ensure spot illustrations don't overflow */
.spot-illustrations img,
img[src*="spot-illustrations"] {
    max-width: 100%;
    height: auto;
}

/* Fix hero sections that might overflow */
.hero,
.hero-section,
section[class*="hero"] {
    max-width: 100%;
    overflow-x: hidden;
}

/* Responsive font sizes to prevent overflow */
@media (max-width: 575px) {
    h1, .h1 {
        font-size: 1.75rem;
    }

    h2, .h2 {
        font-size: 1.5rem;
    }

    .display-1 {
        font-size: 3rem;
    }

    .display-2 {
        font-size: 2.5rem;
    }

    .display-3 {
        font-size: 2rem;
    }

    .display-4 {
        font-size: 1.75rem;
    }
}

/* Fix Bootstrap grid issues on mobile */
@media (max-width: 575px) {
    .col,
    [class*="col-"] {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* Ensure modals don't overflow on mobile */
.modal-dialog {
    max-width: calc(100% - 20px);
    margin: 10px auto;
}

/* Fix navbar that might cause overflow */
.navbar {
    flex-wrap: wrap;
}

/* Keep the navbar logo at the theme's 32px height (height:auto let the 1024px
   site_logo render at 150px and overflow the navbar). */
.navbar-brand img {
    max-width: 150px;
    height: 32px;
    width: auto;
    object-fit: contain;
}

/* Fix wide elements in service cards */
.service-card .card-body,
.pricing-card .card-body {
    padding: 1rem;
}

@media (max-width: 575px) {
    .service-card .card-body,
    .pricing-card .card-body {
        padding: 0.75rem;
    }
}

/* Fix alert messages that might overflow */
.alert {
    max-width: 100%;
    word-wrap: break-word;
}

/* Ensure breadcrumbs don't overflow */
.breadcrumb {
    flex-wrap: wrap;
    max-width: 100%;
}

/* Fix wide buttons and button groups */
.btn-group {
    flex-wrap: wrap;
}

/* Ensure no fixed widths override responsive behavior */
* {
    box-sizing: border-box;
}

/* Fix potential issues with absolute positioning */
[style*="position: absolute"],
[style*="position: fixed"] {
    max-width: 100%;
}
