/* Mobile Responsiveness CSS for Dove Finance Portal */

/* ============================================
   Login Page Specific Styles
   ============================================ */

/* Fix vh-100 issues on mobile browsers (address bar) */
.vh-100 {
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ============================================
   Tablet and Mobile (768px and below)
   ============================================ */
@media (max-width: 768px) {
    
    /* Login page adjustments */
    .vh-100 {
        min-height: 100vh;
        height: auto;
    }
    
    .vh-100 .container {
        padding: 2rem 1rem;
    }
    
    .vh-100 .h-100 {
        min-height: auto;
    }
    
    /* Login logo sizing */
    .vh-100 img.img-fluid {
        max-width: 200px;
        margin: 0 auto;
        display: block;
    }
    
    /* Login buttons */
    .district-button {
        width: 100%;
        min-height: 50px;
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    /* Calendar Inputs - Make responsive */
    .calendar-icon,
    .calendar-icon-form {
        width: 100% !important;
        max-width: 100%;
    }
    
    /* Container adjustments */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Action Icons - Reduce size on mobile */
    .fa-2xl {
        font-size: 1.5em !important;
    }
    
    /* Table responsive improvements */
    .table-responsive {
        border: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* DataTables wrapper */
    .dataTables_wrapper {
        overflow-x: auto;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-header {
        padding: 0.75rem 1rem;
    }
    
    /* Form improvements */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Button layouts - Better spacing */
    .btn {
        min-height: 44px; /* Touch target size */
        padding: 0.5rem 1rem;
    }
    
    /* Navigation improvements */
    .navbar-collapse {
        background-color: #f8f9fa;
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 0.25rem;
    }
    
    .nav-item {
        padding: 0.25rem 0;
    }
    
    /* Table in modals */
    .modal-body table {
        font-size: 0.9rem;
    }
    
    .modal-body table th,
    .modal-body table td {
        padding: 0.5rem;
        word-break: break-word;
    }
    
    /* Action icons spacing */
    .d-flex .p-2 i {
        margin-left: 15px !important;
    }
    
    /* File input improvements */
    input[type="file"] {
        font-size: 14px;
        padding: 0.5rem;
    }
    
    /* Touch targets for icons */
    i[role="button"],
    i[tabindex="0"] {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
    }
    
    /* Column width adjustments */
    .col-lg-10 {
        max-width: 100%;
        flex: 0 0 100%;
    }
    
    /* Toast notifications */
    .position-fixed.bottom-0.end-0 {
        left: 0;
        right: 0;
        bottom: 0;
        padding: 0.5rem !important;
    }
    
    .toast {
        max-width: 100%;
    }
}

/* ============================================
   Mobile Phone (576px and below)
   ============================================ */
@media (max-width: 576px) {
    
    /* Login page mobile optimization */
    .vh-100 .container {
        padding: 1.5rem 1rem;
    }
    
    .vh-100 h1 {
        font-size: 1.75rem;
    }
    
    .vh-100 p {
        font-size: 0.95rem;
    }
    
    .vh-100 img.img-fluid {
        max-width: 150px;
    }
    
    .vh-100 .mb-md-5 {
        margin-bottom: 2rem !important;
    }
    
    .vh-100 .mt-md-4 {
        margin-top: 1.5rem !important;
    }
    
    /* Login buttons - larger touch targets */
    .district-button {
        min-height: 56px;
        font-size: 1.15rem;
        font-weight: 600;
        padding: 1rem;
    }
    
    /* Page title and header */
    h3 {
        font-size: 1.5rem;
    }
    
    /* Further reduce icon sizes */
    .fa-2xl {
        font-size: 1.25em !important;
    }
    
    .fa-xl {
        font-size: 1.1em !important;
    }
    
    .fa-lg {
        font-size: 1em !important;
    }
    
    /* Action buttons container */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .d-flex.justify-content-between > .p-2 {
        padding: 0.25rem !important;
        text-align: center;
    }
    
    /* Selected total text */
    #totalSelected {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }
    
    /* Date range filter - full width */
    .d-flex.mb-1.justify-content-md-center {
        width: 100%;
    }
    
    .calendar-icon,
    .calendar-icon-form {
        background-size: 1.5rem 1.5rem !important;
        background-position: 8px center !important;
        padding-left: 2.5rem !important;
    }
    
    /* Modal full screen on small devices */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    /* Form buttons - full width on mobile */
    .text-end .btn {
        width: 100%;
    }
    
    /* Form columns - ensure stacking */
    .col-md-4,
    .col-md-6,
    .col-md-8,
    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* DataTables elements */
    .dataTables_length,
    .dataTables_filter,
    .dataTables_info,
    .dataTables_paginate {
        text-align: center;
        margin: 0.5rem 0;
    }
    
    .dataTables_filter input {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    /* Pagination buttons */
    .pagination {
        font-size: 0.9rem;
    }
    
    .page-link {
        padding: 0.4rem 0.6rem;
    }
    
    /* Table font size */
    .table {
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Checkbox sizing */
    input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    /* Select elements */
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Logo sizing */
    .navbar-brand img,
    .navbar img {
        max-width: 80px;
        height: auto;
    }
    
    /* Collapsible sections */
    .collapse {
        font-size: 0.9rem;
    }
    
    /* Form check items */
    .form-check {
        padding-left: 2rem;
    }
    
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    /* Print button in modal */
    .modal-header .p-2 {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    /* Invalid feedback */
    .invalid-feedback {
        font-size: 0.85rem;
    }
}

/* ============================================
   Landscape Phone Orientation
   ============================================ */
@media (max-width: 896px) and (orientation: landscape) {
    
    /* Modal adjustments for landscape */
    .modal-dialog {
        margin: 0.5rem auto;
        max-width: 90%;
        height: auto;
    }
    
    .modal-content {
        height: auto;
    }
    
    .modal-body {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* ============================================
   Touch Device Improvements
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    
    /* Increase touch targets */
    button,
    .btn,
    a,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
    
    /* Better active states for touch */
    .btn:active {
        transform: scale(0.98);
    }
    
    /* Improve tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* ============================================
   DataTables Responsive Plugin Enhancements
   ============================================ */
@media (max-width: 768px) {
    
    /* Responsive child row styling */
    table.dataTable.dtr-inline.collapsed > tbody > tr > td.child,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.child,
    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty {
        cursor: default !important;
    }
    
    table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > td:first-child:before,
    table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child:before {
        top: 50%;
        transform: translateY(-50%);
    }
    
    /* Child row details */
    table.dataTable > tbody > tr.child ul.dtr-details {
        display: block;
        width: 100%;
    }
    
    table.dataTable > tbody > tr.child ul.dtr-details > li {
        border-bottom: 1px solid #efefef;
        padding: 0.75rem 0;
    }
    
    table.dataTable > tbody > tr.child span.dtr-title {
        display: inline-block;
        min-width: 100px;
        font-weight: bold;
    }
}

/* ============================================
   File Upload Improvements
   ============================================ */
@media (max-width: 576px) {
    
    /* Make file input more touch-friendly */
    input[type="file"]::file-selector-button {
        padding: 0.5rem 1rem;
        margin-right: 1rem;
        min-height: 44px;
        border-radius: 0.25rem;
        border: 1px solid #ced4da;
        background-color: #f8f9fa;
        cursor: pointer;
    }
    
    input[type="file"]::file-selector-button:active {
        background-color: #e9ecef;
    }
}
