/* Mobile-specific styles for Rogatna */

/* Mobile Navigation Fixes */
@media (max-width: 991px) {
    /* Ensure navbar is always accessible */
    .navbar {
        position: relative;
        z-index: 1030;
    }
    
    /* Fix hamburger menu button */
    .navbar-toggler {
        position: relative;
        z-index: 1040;
        border: 1px solid rgba(255, 255, 255, 0.3);
        padding: 0.375rem 0.75rem;
    }
    
    .navbar-toggler:focus,
    .navbar-toggler:active {
        outline: 2px solid rgba(255, 255, 255, 0.5);
        outline-offset: 2px;
    }
    
    /* Mobile notification bell styling */
    .notification-badge-mobile {
        font-size: 0.6rem;
        padding: 0.1rem 0.3rem;
        min-width: 18px;
        height: 18px;
        line-height: 1;
    }
    
    /* Fix collapsed menu */
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--bs-primary);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        z-index: 1035;
        padding: 1rem;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    .navbar-collapse.collapsing {
        transition: height 0.35s ease;
    }
    
    /* Mobile menu items */
    .navbar-nav {
        padding: 0.5rem 0;
    }
    
    .navbar-nav .nav-item {
        margin-bottom: 0.25rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 0.375rem;
        font-size: 1rem;
        display: block;
        width: 100%;
        color: #fff;
        text-decoration: none;
    }
    
    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:focus,
    .navbar-nav .nav-link:active {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Mobile logout button styling */
    #logout-form-mobile {
        margin: 0;
        padding: 0;
    }
    
    #logout-form-mobile button {
        background: none;
        border: none;
        color: #fff;
        padding: 0.75rem 1rem;
        border-radius: 0.375rem;
        font-size: 1rem;
        text-decoration: none;
        cursor: pointer;
    }
    
    #logout-form-mobile button:hover,
    #logout-form-mobile button:focus,
    #logout-form-mobile button:active {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Profile link with username */
    .navbar-nav .nav-link small {
        opacity: 0.8;
        font-size: 0.875rem;
    }
    
    /* Separator line */
    .navbar-nav hr.border-secondary {
        border-color: rgba(255, 255, 255, 0.2) !important;
        margin: 0.5rem 1rem;
    }
    
    /* Clean mobile menu without dropdowns */
    .navbar-nav .nav-item:last-child {
        margin-bottom: 1rem;
    }
    
    /* Ensure mobile buttons have proper touch targets */
    #logout-form-mobile button,
    .navbar-nav .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

/* Mobile-specific improvements */
@media (max-width: 767px) {
    /* Better spacing for mobile */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* Cards on mobile */
    .card {
        border-radius: 0.5rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    
    .card-header {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Tables on mobile */
    .table-responsive {
        border-radius: 0.5rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
    
    .table {
        font-size: 0.875rem;
        margin-bottom: 0;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    .table .btn-sm {
        padding: 0.375rem 0.5rem;
        font-size: 0.8rem;
        min-width: auto;
    }
    
    /* Forms on mobile */
    .form-label {
        font-size: 0.9rem;
        font-weight: 500;
        margin-bottom: 0.375rem;
    }
    
    .form-control,
    .form-select {
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 0.625rem 0.875rem !important;
        min-height: 44px !important;
        border-radius: 0.375rem !important;
    }
    
    .btn {
        min-height: 44px;
        padding: 0.625rem 1.25rem;
        font-size: 1rem;
        border-radius: 0.375rem;
        font-weight: 500;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Alerts on mobile */
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        border-radius: 0.375rem;
        margin-bottom: 1rem;
    }
    
    .alert-dismissible .btn-close {
        padding: 0.5rem;
    }
    
    /* Modal on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .modal-body {
        padding: 1rem;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    /* Dashboard stats */
    .stat-card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .stat-card p {
        font-size: 0.9rem;
        margin-bottom: 0;
    }
    
    /* Footer on mobile */
    footer {
        padding: 1.5rem 1rem;
        font-size: 0.8rem;
        text-align: center;
    }
    
    footer a {
        display: inline-block;
        padding: 0.25rem 0.5rem;
    }
    
    /* Responsive Table Fixes for Admin Transfers */
    .table-responsive {
        margin: 0 -1rem;
        padding: 0 1rem;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Compact table on mobile */
    .table {
        font-size: 0.75rem;
    }
    
    .table th,
    .table td {
        padding: 0.3rem;
        white-space: nowrap;
    }
    
    /* Hide less important columns on small screens */
    @media (max-width: 576px) {
        .table th:nth-child(3), /* Customer column */
        .table td:nth-child(3),
        .table th:nth-child(4), /* Agent column */
        .table td:nth-child(4) {
            display: none;
        }
    }
    
    /* Make amount columns more compact */
    .table td:nth-child(6), /* Send Amount */
    .table td:nth-child(7)  /* Receive Amount */ {
        font-size: 0.7rem;
        min-width: 80px;
        max-width: 100px;
    }
    
    /* Compact action buttons */
    .btn-group-sm > .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    /* Summary statistics cards responsive */
    .row.mb-4 > [class*="col-md-2"] {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 0.5rem;
    }
    
    .card-body.text-center {
        padding: 0.5rem;
    }
    
    .card-body.text-center h5 {
        font-size: 1rem;
    }
    
    .card-body.text-center small {
        font-size: 0.65rem;
    }
    
    /* Fix customer balance positioning */
    .customer-balance {
        text-align: right;
        padding-right: 0.5rem !important;
    }
    
    /* Mobile-first table improvements */
    @media (max-width: 768px) {
        /* Remove horizontal scroll for better UX */
        .table-responsive {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin-bottom: 0;
        }
        
        /* Compact table cells */
        .table td, .table th {
            padding: 0.4rem 0.3rem;
            font-size: 0.8rem;
        }
        
        /* Amount columns - prevent wrapping */
        td[style*="white-space: nowrap"] {
            padding-right: 0.5rem !important;
        }
        
        /* Status badges more compact */
        .badge {
            padding: 0.25rem 0.4rem;
            font-size: 0.65rem;
        }
        
        /* Action buttons smaller */
        .btn-sm {
            padding: 0.2rem 0.3rem;
            font-size: 0.7rem;
        }
        
        /* Statistics cards - 2 per row on mobile */
        .col-md-3 {
            flex: 0 0 50%;
            max-width: 50%;
        }
        
        /* Card view as default on mobile */
        @media (max-width: 576px) {
            /* Allow JavaScript to control visibility */
            #tableView.d-none {
                display: none !important;
            }
            
            #cardView.d-none {
                display: none !important;
            }
            
            /* When not hidden, ensure they display properly */
            #tableView:not(.d-none) {
                display: block !important;
            }
            
            #cardView:not(.d-none) {
                display: block !important;
            }
            
            /* Keep view toggle visible but make it mobile-friendly */
            .btn-group[role="group"][aria-label="View toggle"] {
                display: inline-flex !important;
                margin-right: 0.5rem;
            }
            
            .btn-group-sm .btn {
                padding: 0.5rem 0.7rem;
                font-size: 0.85rem;
                min-width: 40px;
            }
            
            /* Make toggle buttons more prominent on mobile */
            .btn-group .btn-outline-light {
                border-color: rgba(255, 255, 255, 0.5);
            }
            
            .btn-group .btn-outline-light.active {
                background-color: #fff;
                color: #212529;
                border-color: #fff;
            }
            
            /* Stack filters on very small screens */
            @media (max-width: 400px) {
                .col-auto.d-flex {
                    flex-direction: column;
                    align-items: stretch !important;
                    width: 100%;
                }
                
                .btn-group[role="group"][aria-label="View toggle"] {
                    width: 100%;
                    margin-bottom: 0.5rem;
                }
                
                .btn-group .btn {
                    flex: 1;
                }
                
                .form-select-sm,
                .input-group-sm {
                    width: 100% !important;
                    margin-bottom: 0.5rem;
                }
            }
        }
    }
    
    /* Improve readability on small screens */
    @media (max-width: 480px) {
        .container-fluid {
            padding-left: 0.5rem;
            padding-right: 0.5rem;
        }
        
        .card {
            border-radius: 0.5rem;
        }
        
        .card-header,
        .card-body {
            padding: 0.75rem;
        }
    }
    
    /* Checkpoint Review Page Specific Fixes */
    @media (max-width: 768px) {
        /* Stack columns on mobile */
        .col-md-8, .col-lg-8 {
            margin-bottom: 1rem;
        }
        
        /* Compact definition lists */
        dl.row dt {
            font-size: 0.85rem;
        }
        
        dl.row dd {
            font-size: 0.85rem;
            margin-bottom: 0.25rem;
        }
        
        /* Amount calculation box */
        .border.rounded {
            padding: 0.75rem !important;
        }
        
        /* Make input fields mobile-friendly */
        input[type="number"].form-control-sm {
            font-size: 0.9rem;
            padding: 0.25rem 0.5rem;
        }
        
        /* Compact customer balance card */
        .card-body.p-2 {
            padding: 0.5rem !important;
        }
        
        /* Ensure amount displays don't overflow */
        .text-warning, .text-info, .text-success, .text-danger {
            word-break: break-word;
        }
        
        /* Make approval buttons more touch-friendly */
        .btn {
            min-height: 44px;
            font-size: 0.9rem;
        }
    }
}

/* iPhone-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific styles */
    .form-control,
    .form-select {
        -webkit-appearance: none;
        appearance: none;
    }
    
    .form-select {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e9ecef' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 0.75rem center;
        background-size: 16px 12px;
        padding-right: 2.5rem !important;
    }
    
    /* Fix iOS button appearance */
    button,
    .btn {
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Safe area for notched devices */
    @supports (padding: env(safe-area-inset-left)) {
        .navbar {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
        }
        
        .container,
        .container-fluid {
            padding-left: max(15px, env(safe-area-inset-left));
            padding-right: max(15px, env(safe-area-inset-right));
        }
        
        footer {
            padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
        }
    }
}

/* Android-specific fixes */
@media (hover: none) and (pointer: coarse) {
    /* Touch device optimizations */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    a,
    button,
    .btn,
    .nav-link,
    .dropdown-item {
        touch-action: manipulation;
        user-select: none;
    }
    
    /* Improve tap feedback */
    .btn:active,
    .nav-link:active,
    .dropdown-item:active {
        opacity: 0.8;
        transform: scale(0.98);
        transition: all 0.1s ease;
    }
}

/* Landscape mode adjustments */
@media (max-width: 767px) and (orientation: landscape) {
    .navbar-collapse {
        max-height: calc(100vh - 50px);
    }
    
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
        height: calc(100% - 1rem);
    }
    
    .hero-section {
        min-height: 100vh;
        padding: 1rem 0;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .navbar-toggler {
        border: 2px solid #fff;
    }
    
    .btn {
        border: 1px solid currentColor;
    }
    
    .form-control,
    .form-select {
        border: 2px solid #495057;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}