/* ========================================
   MOBILE-FIRST RESPONSIVE CSS
   Optimized for mobile devices and tablets
   ======================================== */

/* Base: Mobile-first approach (320px and up) */

/* Touch-friendly tap targets (minimum 44x44px) */
.btn,
a.nav-link,
.nav-item,
.dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* Larger form controls for mobile */
@media (max-width: 767px) {
    .form-control,
    .form-select,
    .btn {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        min-height: 48px;
    }

    /* Larger checkboxes and radios */
    .form-check-input {
        width: 1.5rem;
        height: 1.5rem;
        margin-top: 0.125rem;
    }

    /* Better spacing for mobile */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Stack form groups */
    .row > [class*='col-'] {
        margin-bottom: 0.75rem;
    }

    /* Full-width buttons on mobile */
    .btn-group-mobile-full {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-mobile-full .btn {
        width: 100%;
    }

    /* Responsive tables */
    .table-responsive {
        border: none;
    }

    /* Stack table headers vertically */
    .table-mobile-cards {
        border: 0;
    }

    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        background: white;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem;
        border: none;
        border-bottom: 1px solid #f0f0f0;
    }

    .table-mobile-cards td:last-child {
        border-bottom: none;
    }

    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: bold;
        flex: 0 0 40%;
    }

    /* Better modal experience */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-fullscreen-sm-down {
        width: 100vw;
        max-width: none;
        height: 100%;
        margin: 0;
    }

    .modal-fullscreen-sm-down .modal-content {
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    /* Navbar improvements */
    .navbar-collapse {
        margin-top: 0.5rem;
        padding: 0.5rem 0;
    }

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

    /* Better flash messages on mobile */
    .flash-messages {
        top: 60px;
        right: 10px;
        left: 10px;
        min-width: auto;
    }

    .flash-messages .alert {
        padding: 0.75rem;
        font-size: 14px;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-item {
        margin: 2px;
    }

    /* Hide long text, show icons */
    .mobile-hide-text {
        font-size: 0;
    }

    .mobile-hide-text i,
    .mobile-hide-text .bi {
        font-size: 1.25rem;
    }

    /* Better footer on mobile */
    footer {
        padding: 1rem 0;
        font-size: 0.875rem;
    }

    /* Search input full width */
    .search-form {
        width: 100%;
    }

    .search-form .form-control {
        width: 100%;
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .container-fluid {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    /* Two-column forms on tablets */
    .form-tablet-2col .row > [class*='col-'] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Landscape phone */
@media (max-width: 767px) and (orientation: landscape) {
    .navbar {
        padding: 0.25rem 1rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    /* Reduce vertical spacing in landscape */
    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .my-4 {
        margin-top: 1rem !important;
        margin-bottom: 1rem !important;
    }
}

/* Very small devices (320px - 374px) */
@media (max-width: 374px) {
    .btn {
        font-size: 14px;
        padding: 10px;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .card-body {
        padding: 0.75rem;
    }
}

/* Utility classes for responsive design */
.mobile-only {
    display: none;
}

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

    .mobile-hide {
        display: none !important;
    }

    .mobile-text-center {
        text-align: center;
    }

    .mobile-mb-3 {
        margin-bottom: 1rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* This targets touch devices */
    
    /* Larger click targets */
    a, button, .btn, .nav-link {
        padding: 12px;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover {
        opacity: 1;
    }

    /* Better focus states for touch */
    .btn:active,
    .nav-link:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    .pagination,
    footer,
    .no-print {
        display: none !important;
    }

    .container,
    .container-fluid {
        width: 100%;
        max-width: 100%;
    }

    .card {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}