/* Responsive Fixes for All Pages */

/* Prevent horizontal scroll */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Mobile-first typography */
@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem !important;
        line-height: 2rem !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
        line-height: 1.75rem !important;
    }
    
    h3 {
        font-size: 1.125rem !important;
        line-height: 1.5rem !important;
    }
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Mobile-friendly buttons */
@media (max-width: 640px) {
    button, a.btn, .btn {
        min-height: 44px; /* iOS touch target size */
        padding: 0.75rem 1rem;
    }
}

/* Prevent text overflow */
.text-overflow-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile navigation fixes */
@media (max-width: 768px) {
    nav {
        position: relative;
        z-index: 50;
    }
    
    nav .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Ensure containers don't overflow */
.container {
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Fix for long words breaking layout */
p, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Mobile-friendly forms */
@media (max-width: 640px) {
    input, textarea, select {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Touch-friendly spacing */
@media (max-width: 640px) {
    .space-x-6 > * + * {
        margin-left: 0.5rem !important;
    }
    
    .space-y-6 > * + * {
        margin-top: 1rem !important;
    }
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* Flexbox fixes for mobile */
@media (max-width: 768px) {
    .flex {
        flex-wrap: wrap;
    }
}

/* Modal/Dialog responsive */
@media (max-width: 640px) {
    .modal, .dialog {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        overflow-y: auto;
    }
}

/* Table responsive */
@media (max-width: 640px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Card responsive spacing */
@media (max-width: 640px) {
    .card, .rounded-xl {
        border-radius: 0.75rem !important;
    }
}

/* Fix Alpine.js transitions on mobile */
@media (max-width: 640px) {
    [x-transition] {
        transition-duration: 200ms !important;
    }
}
