/* ===== MOBILE SPECIFIC STYLES ===== */

/* Prevent zooming on input focus (but allow user zoom) */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="password"],
textarea,
select {
    font-size: 16px !important;
}

/* Improve touch targets */
@media (max-width: 576px) {
    .bills-page .bills-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(6rem, 1fr));
        min-width: 14rem;
        gap: 0.45rem;
    }

    .bills-page .bills-actions .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 44px;
        padding: 0.5rem;
        margin: 0;
        font-size: 0.8rem;
        text-align: center;
    }

    /* Minimum 44x44px touch targets */
    .btn,
    a.btn,
    .btn-group .btn,
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        padding: 0.75rem 1rem !important;
    }
    
    /* Optimize for small screens */
    .navbar {
        padding: 0.5rem 0;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
        padding: 0.5rem 0;
    }
    
    /* Stack two-column layouts */
    .row [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }
    
    /* Better spacing for cards */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Make tables more compact */
    .table {
        font-size: 0.85rem;
    }
    
    .table thead {
        display: none;
    }
    
    /* Card-based table display on mobile */
    .table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #ddd;
        border-radius: 4px;
    }
    
    .table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem;
        border: none;
        border-bottom: 1px solid #eee;
    }
    
    .table tbody td:last-child {
        border-bottom: none;
    }
    
    .table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        min-width: 45%;
    }
    
    /* Alternative: scrollable table */
    .table-responsive {
        border: 1px solid #ddd;
        border-radius: 4px;
    }

    .table-responsive > .table {
        display: table;
        width: max-content;
        min-width: 100%;
        margin-bottom: 0.5rem;
    }

    .table-responsive > .table thead {
        display: table-header-group;
    }

    .table-responsive > .table tbody tr {
        display: table-row;
        margin-bottom: 0;
        border: 0;
        border-radius: 0;
    }

    .table-responsive > .table tbody td {
        display: table-cell;
        padding: 0.5rem;
        border: 1px solid #dee2e6;
        white-space: normal;
    }

    .table-responsive > .table tbody td::before {
        content: none;
    }
    
    /* Form improvements */
    .form-control,
    .form-select,
    .input-group {
        width: 100%;
    }
    
    .input-group {
        margin-bottom: 1rem;
    }
    
    .input-group-text {
        background-color: #f8f9fa;
        border: 1px solid #ddd;
    }
    
    /* Make buttons full width on mobile */
    .btn-group-vertical .btn {
        width: 100%;
    }
    
    .btn-group:not(.btn-group-vertical) {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group:not(.btn-group-vertical) .btn {
        width: 100%;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 8px;
    }
    
    /* Reduce padding in modal */
    .modal-header,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Alert styling */
    .alert {
        margin-bottom: 1rem;
        padding: 0.75rem;
    }
    
    /* Better list display */
    ul, ol {
        padding-left: 1.5rem;
    }
    
    li {
        margin-bottom: 0.5rem;
    }
    
    /* Tab styling for mobile */
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-bottom: 2px solid #ddd;
    }
    
    .nav-tabs .nav-link {
        white-space: nowrap;
        border: none;
        border-bottom: 3px solid transparent;
        padding: 0.75rem 1rem;
    }
    
    .nav-tabs .nav-link.active {
        border-bottom-color: #007bff;
        background-color: transparent;
    }
    
    /* Reduce search input clutter */
    .card.mb-3 {
        margin-bottom: 1rem;
    }
    
    .row.g-2 {
        gap: 0.5rem !important;
    }
    
    .col-md-2,
    .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Extra small devices (phones < 360px) */
@media (max-width: 360px) {
    body {
        font-size: 14px;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    h1 {
        font-size: 1.25rem;
    }
    
    .h3 {
        font-size: 1rem;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .table tbody td {
        padding: 0.5rem;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        padding: 0.25rem 0;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    h1 {
        margin-bottom: 0.5rem;
    }
    
    .card {
        margin-bottom: 0.5rem;
    }
}

/* High DPI displays */
@media (min-resolution: 300dpi) {
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select,
    .form-control,
    .form-select {
        font-size: 16px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .nav-link,
    #navbarNav {
        display: none !important;
    }
}
