/**
 * Mobile Responsive Enhancements for Doggy Haven PHP Application
 * Ensures optimal viewing and interaction experience across all mobile devices
 */

/* ============================================
   MOBILE-FIRST BASE STYLES
   ============================================ */

/* Ensure all elements are sized properly */
* {
    box-sizing: border-box;
}

/* Prevent horizontal scrolling on mobile */
html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Better text rendering on mobile */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Improve touch targets for mobile - minimum 44x44px */
button, a, input, select, textarea, .btn, .nav-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Make sure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   MOBILE NAVIGATION IMPROVEMENTS
   ============================================ */

/* Better mobile menu spacing */
@media (max-width: 991.98px) {
    .navbar-collapse {
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .navbar-nav {
        padding: 1rem 0;
    }
    
    .navbar-nav .nav-item {
        padding: 0.25rem 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        width: 100%;
        justify-content: flex-start;
    }
    
    /* Dropdown menu improvements for mobile */
    .dropdown-menu {
        width: 100%;
        border: none;
        box-shadow: none;
        background-color: rgba(0, 0, 0, 0.05);
        margin-top: 0;
    }
    
    .dropdown-item {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }
    
    /* Better navbar toggler */
    .navbar-toggler {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        border: none;
    }
    
    .navbar-toggler:focus {
        box-shadow: 0 0 0 0.2rem rgba(214, 51, 108, 0.25);
    }
}

/* ============================================
   CONTAINER AND LAYOUT ADJUSTMENTS
   ============================================ */

@media (max-width: 767.98px) {
    .container, .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Reduce margins on mobile */
    h1, h2, h3, h4, h5, h6 {
        margin-bottom: 1rem;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
    
    /* Better spacing for sections */
    section {
        padding: 2rem 0;
    }
}

/* ============================================
   CARD IMPROVEMENTS FOR MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .card {
        margin-bottom: 1rem;
        border-radius: 12px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .card-footer {
        padding: 0.75rem 1rem;
    }
    
    /* Stack card content vertically */
    .card .row {
        margin: 0;
    }
    
    .card .col-md-6,
    .card .col-md-4,
    .card .col-lg-6,
    .card .col-lg-4 {
        padding-left: 0;
        padding-right: 0;
    }
}

/* ============================================
   TABLE RESPONSIVENESS
   ============================================ */

/* Ensure all tables are wrapped in responsive containers */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

@media (max-width: 767.98px) {
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Stack table for very small screens */
    .table-mobile-stack {
        display: block;
        width: 100%;
    }
    
    .table-mobile-stack thead {
        display: none;
    }
    
    .table-mobile-stack tbody,
    .table-mobile-stack tr,
    .table-mobile-stack td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-stack tr {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        padding: 0.5rem;
    }
    
    .table-mobile-stack td {
        text-align: right;
        padding: 0.5rem;
        position: relative;
        border: none;
    }
    
    .table-mobile-stack td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 50%;
        padding-left: 0.5rem;
        font-weight: bold;
        text-align: left;
    }
}

/* ============================================
   FORM IMPROVEMENTS FOR MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
    
    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    .form-group,
    .mb-3 {
        margin-bottom: 1rem;
    }
    
    /* Better date/time inputs on mobile */
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        font-size: 16px;
        min-height: 44px;
    }
}

/* ============================================
   BUTTON IMPROVEMENTS FOR MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .btn {
        min-height: 44px;
        padding: 0.625rem 1rem;
        font-size: 1rem;
    }
    
    .btn-sm {
        min-height: 38px;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-lg {
        min-height: 50px;
        padding: 0.75rem 1.5rem;
        font-size: 1.125rem;
    }
    
    /* Stack buttons vertically on mobile */
    .btn-group-mobile-stack {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group-mobile-stack .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Button groups */
    .btn-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        flex: 1 1 auto;
    }
}

/* ============================================
   MODAL IMPROVEMENTS FOR MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    /* Full-screen modals on mobile if needed */
    .modal-fullscreen-sm-down {
        max-width: 100%;
        margin: 0;
        min-height: 100vh;
    }
    
    .modal-fullscreen-sm-down .modal-content {
        height: 100vh;
        border-radius: 0;
    }
}

/* ============================================
   ALERT IMPROVEMENTS FOR MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }
    
    .alert-dismissible .btn-close {
        padding: 0.75rem;
    }
}

/* ============================================
   BADGE AND TAG IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
}

/* ============================================
   PAGINATION IMPROVEMENTS
   ============================================ */

@media (max-width: 767.98px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-item {
        margin: 0.125rem;
    }
    
    .page-link {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* Hide some page numbers on very small screens */
    .pagination-sm .page-item:not(.active):not(.disabled):nth-child(n+4):nth-last-child(n+4) {
        display: none;
    }
}

/* ============================================
   BOOKING CALENDAR MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 767.98px) {
    .calendar {
        font-size: 0.875rem;
    }
    
    .calendar-day {
        min-height: 44px;
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .date-picker-mobile {
        width: 100%;
    }
}

/* ============================================
   GALLERY MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 767.98px) {
    .gallery-item {
        margin-bottom: 1rem;
    }
    
    .gallery-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.5rem;
    }
    
    /* Lightbox improvements for mobile */
    .lightbox-mobile {
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 9999;
    }
}

/* ============================================
   ADMIN DASHBOARD MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 767.98px) {
    /* Stack dashboard cards */
    .dashboard-card {
        margin-bottom: 1rem;
    }
    
    /* Statistics cards */
    .stat-card {
        padding: 1rem;
        text-align: center;
    }
    
    .stat-card .display-4 {
        font-size: 2rem;
    }
    
    /* Admin tables */
    .admin-table-mobile {
        font-size: 0.875rem;
    }
    
    .admin-table-mobile .btn {
        min-width: 36px;
        min-height: 36px;
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
    }
}

/* ============================================
   PROFILE PAGE MOBILE OPTIMIZATION
   ============================================ */

@media (max-width: 767.98px) {
    .profile-header {
        text-align: center;
        padding: 1rem;
    }
    
    .profile-image {
        width: 100px;
        height: 100px;
        margin: 0 auto 1rem;
    }
    
    .profile-info {
        padding: 1rem;
    }
}

/* ============================================
   UTILITY CLASSES FOR MOBILE
   ============================================ */

/* Hide on mobile */
.mobile-hide {
    display: none !important;
}

/* Show only on mobile */
.mobile-only {
    display: block !important;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
    
    .mobile-hide {
        display: block !important;
    }
}

/* Text alignment utilities for mobile */
@media (max-width: 767.98px) {
    .text-mobile-center {
        text-align: center !important;
    }
    
    .text-mobile-left {
        text-align: left !important;
    }
    
    .text-mobile-right {
        text-align: right !important;
    }
}

/* Margin utilities for mobile */
@media (max-width: 767.98px) {
    .mt-mobile-2 { margin-top: 0.5rem !important; }
    .mt-mobile-3 { margin-top: 1rem !important; }
    .mb-mobile-2 { margin-bottom: 0.5rem !important; }
    .mb-mobile-3 { margin-bottom: 1rem !important; }
    .mx-mobile-auto { margin-left: auto !important; margin-right: auto !important; }
}

/* Padding utilities for mobile */
@media (max-width: 767.98px) {
    .p-mobile-2 { padding: 0.5rem !important; }
    .p-mobile-3 { padding: 1rem !important; }
    .px-mobile-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .py-mobile-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
}

/* Width utilities for mobile */
@media (max-width: 767.98px) {
    .w-mobile-100 {
        width: 100% !important;
    }
    
    .w-mobile-auto {
        width: auto !important;
    }
}

/* ============================================
   TOUCH-FRIENDLY INTERACTIONS
   ============================================ */

/* Increase touch target sizes */
.touch-target {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Remove hover effects on touch devices */
@media (hover: none) {
    .hover-effect:hover {
        transform: none !important;
    }
}

/* Better tap highlighting */
a, button, .btn, .nav-link {
    -webkit-tap-highlight-color: rgba(214, 51, 108, 0.2);
}

/* ============================================
   LANDSCAPE ORIENTATION ADJUSTMENTS
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .navbar-collapse {
        max-height: 60vh;
    }
    
    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ============================================
   VERY SMALL SCREENS (< 360px)
   ============================================ */

@media (max-width: 359.98px) {
    body {
        font-size: 14px;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
    h4 { font-size: 1rem; }
    
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* ============================================
   LOADING STATES FOR MOBILE
   ============================================ */

@media (max-width: 767.98px) {
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }
    
    .spinner-border-sm {
        width: 1rem;
        height: 1rem;
    }
    
    .loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(255, 255, 255, 0.9);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS FOR MOBILE
   ============================================ */

/* Focus indicators should be visible on mobile */
*:focus {
    outline: 2px solid var(--primary-pink, #d6336c);
    outline-offset: 2px;
}

/* Skip to main content link for accessibility */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-pink, #d6336c);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 10000;
}

.skip-to-main:focus {
    top: 0;
}

/* ============================================
   PRINT STYLES FOR MOBILE
   ============================================ */

@media print {
    .mobile-hide,
    .navbar,
    .btn,
    .alert,
    .footer {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    .container {
        width: 100%;
        max-width: none;
    }
}

/* ============================================
   SPECIFIC COMPONENT FIXES
   ============================================ */

/* Hero section mobile optimization */
@media (max-width: 767.98px) {
    .hero-section {
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .hero-section h1 {
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
}

/* Service cards mobile optimization */
@media (max-width: 767.98px) {
    .service-card {
        margin-bottom: 1.5rem;
        padding: 1rem;
    }
    
    .service-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
}

/* Footer mobile optimization */
@media (max-width: 767.98px) {
    .footer {
        text-align: center;
        padding: 1.5rem 1rem;
    }
    
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
}

/* Booking form mobile optimization */
@media (max-width: 767.98px) {
    .booking-form {
        padding: 1rem;
    }
    
    .booking-summary {
        position: static;
        margin-top: 1rem;
    }
    
    .dog-info-section {
        margin-bottom: 1rem;
    }
}

/* Rating stars mobile optimization */
@media (max-width: 767.98px) {
    .star-rating .star {
        font-size: 1.5rem;
        padding: 0.25rem;
    }
}
