/**
 * Mobile Responsive Styles
 *
 * This file is loaded on every page. It must never restyle a Tailwind utility or a bare
 * element by viewport; add opt-in classes only.
 */

/* Mobile Navigation Styles */
@media (max-width: 768px) {
    /* Search bar adjustments */
    input[name="q"] {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Logo size */
    header .font-bold.text-xl {
        font-size: 1.125rem;
    }
}

/* Mobile Modals */
@media (max-width: 640px) {
    .modal-content {
        max-width: calc(100% - 2rem);
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Adjust modal padding */
    .modal-content > div {
        padding: 1rem;
    }
}

/* Mobile Forms */
@media (max-width: 640px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Mobile Toast Notifications */
@media (max-width: 640px) {
    /* Full width toasts */
    #toast-container {
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        padding: 1rem;
    }

    .toast {
        max-width: 100%;
        margin: 0;
    }

    /* Slide up animation on mobile */
    @keyframes mobile-toast-enter {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .toast-enter {
        animation: mobile-toast-enter 0.3s ease-out forwards;
    }
}

/* Touch-specific enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Add active states for better feedback */
    button:active,
    a:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* Landscape mobile adjustments */
@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce header height */
    header {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Horizontal scroll improvements for mobile */
.scrollbar-hide {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
    -webkit-overflow-scrolling: touch;  /* Smooth scroll on iOS */
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;  /* Chrome, Safari and Opera */
}

/* Ensure filter buttons don't wrap in mobile and allow scroll */
@media (max-width: 768px) {
    #bookinstances-filters {
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Opt-in: keeps a form's primary action reachable on phones (same look as the onboarding bar).
   Put it on the row that holds the buttons; that row must be a direct child of the element that
   spans the whole scrolling content (the <form>), with no overflow-hidden ancestor in between.
   --bar-bleed cancels the parent's horizontal padding so the bar reaches its edges;
   --bar-bleed-bottom cancels the scroll container's bottom padding (e.g. a modal body with py-4),
   which sticky positioning otherwise leaves as a gap below the bar. */
@media (max-width: 639.98px) {
    .mobile-action-bar {
        position: sticky;
        bottom: calc(-1 * var(--bar-bleed-bottom, 0px));
        z-index: 20;
        margin-left: calc(-1 * var(--bar-bleed, 0px));
        margin-right: calc(-1 * var(--bar-bleed, 0px));
        padding: 0.75rem var(--bar-bleed, 0px) max(0.75rem, env(safe-area-inset-bottom));
        background-color: #fff;
        border-top: 1px solid rgb(226 232 240 / 0.8);
        box-shadow: 0 -8px 24px rgba(23, 32, 51, 0.08);
    }
}

/* Print styles */
@media print {
    /* Hide navigation and controls */
    header, footer, .no-print {
        display: none !important;
    }

    /* Adjust layout for print */
    .container {
        max-width: 100%;
        margin: 0;
    }

    /* Remove shadows and backgrounds */
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* Black text on white */
    body {
        color: black !important;
        background: white !important;
    }
}
