/**
 * IPPC Dashboard - Global Mobile Responsive Styles
 * Applied across all pages for consistent mobile experience
 * Target: Mobile (320px-576px), Tablet (577px-768px)
 */

/* ========================================
   MOBILE OPTIMIZATIONS (max-width: 576px)
   ======================================== */

@media (max-width: 576px) {
    /* Page Headers */
    .content-header h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem;
    }

    h1.display-4 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }

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

    h3, .h3 {
        font-size: 1.25rem !important;
    }

    /* Content Spacing */
    .content-wrapper {
        padding: 0.5rem !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem !important;
    }

    /* Navbar Optimizations */
    .navbar-nav .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem;
    }

    .main-header .navbar-nav .nav-item {
        margin: 0 0.25rem;
    }

    /* Breadcrumbs */
    .breadcrumb {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    /* Cards */
    .card {
        margin-bottom: 1rem;
    }

    .card-header .card-title {
        font-size: 1rem;
        word-break: break-word;
    }

    /* Buttons - Touch-Friendly */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .btn-sm {
        min-height: 38px;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Full-width buttons on mobile */
    .btn-lg,
    .btn-block {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Form Elements */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-control,
    .form-select,
    select.form-control {
        font-size: 1rem;
        padding: 0.75rem;
        min-height: 44px;
    }

    label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }

    textarea.form-control {
        min-height: 100px;
    }

    /* Alerts */
    .alert {
        font-size: 0.875rem;
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    /* Text Sizing */
    .lead,
    p {
        font-size: 1rem;
    }

    /* Tables - Responsive */
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 4px;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.8rem;
    }

    table th,
    table td {
        padding: 0.5rem 0.35rem !important;
        white-space: nowrap;
    }

    /* Action buttons in tables */
    table .btn-sm {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
        min-height: 32px;
    }

    table .btn-sm i {
        font-size: 0.875rem;
    }

    /* DataTables Specific */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_length select {
        padding: 0.25rem 0.5rem;
    }

    /* Badges */
    .badge {
        font-size: 0.75rem;
        padding: 0.35em 0.5em;
    }

    /* Small Boxes (Dashboard widgets) */
    .small-box {
        margin-bottom: 1rem;
    }

    .small-box .inner h3 {
        font-size: 1.75rem;
    }

    .small-box .inner p {
        font-size: 0.875rem;
    }

    /* Modal Dialogs */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-title {
        font-size: 1.25rem;
    }

    /* Footer */
    .main-footer {
        font-size: 0.875rem;
        padding: 1rem;
    }

    /* Hide elements on mobile */
    .d-mobile-none {
        display: none !important;
    }

    /* Stack elements vertically */
    .mobile-stack {
        flex-direction: column !important;
    }

    .mobile-stack > * {
        width: 100% !important;
        margin-bottom: 0.5rem;
    }

    /* Card header with buttons - stack vertically */
    .card-header.mobile-stack {
        align-items: flex-start !important;
    }

    /* Quick Actions */
    .d-grid .btn {
        margin-bottom: 0.5rem;
    }

    /* Sidebar adjustments */
    .sidebar {
        font-size: 0.9rem;
    }

    .nav-sidebar .nav-link {
        padding: 0.75rem 1rem;
    }

    /* Better text wrapping */
    .text-wrap-mobile {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* ========================================
   TABLET OPTIMIZATIONS (577px-768px)
   ======================================== */

@media (min-width: 577px) and (max-width: 768px) {
    .content-header h1 {
        font-size: 1.75rem;
    }

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

    table {
        font-size: 0.875rem;
    }

    .btn {
        min-height: 42px;
    }

    .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* ========================================
   TOUCH-FRIENDLY ELEMENTS (all mobile/tablet)
   ======================================== */

@media (max-width: 768px) {
    /* Minimum touch target size (44px recommended by Apple) */
    .btn,
    .nav-link,
    a.btn,
    button,
    input[type="button"],
    input[type="submit"],
    .pagination .page-link {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better spacing for touch */
    .nav-link {
        padding: 0.75rem 0.5rem;
    }

    /* Form inputs */
    input,
    select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Better tap highlighting */
    * {
        -webkit-tap-highlight-color: rgba(0, 123, 255, 0.1);
    }
}

/* ========================================
   HORIZONTAL SCROLL INDICATOR
   ======================================== */

@media (max-width: 768px) {
    .table-responsive {
        position: relative;
    }

    .table-responsive::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        background: linear-gradient(to right, transparent, rgba(255,255,255,0.95) 30%);
        padding: 0.5rem 0.75rem;
        font-size: 1.5rem;
        color: #007bff;
        pointer-events: none;
        opacity: 0.7;
        transition: opacity 0.3s;
    }

    .table-responsive.scrolled::after {
        opacity: 0;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Show/hide based on screen size */
.mobile-only {
    display: none;
}

@media (max-width: 576px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

/* Responsive text alignment */
@media (max-width: 576px) {
    .text-mobile-center {
        text-align: center !important;
    }

    .text-mobile-left {
        text-align: left !important;
    }
}
