/**
 * Mobile Responsive Styles for KreeptoFx
 * Include this CSS in all pages for mobile compatibility
 */

/* ============================================
   MOBILE NAVIGATION - Always visible styles
   ============================================ */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    z-index: 1050;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.mobile-header .brand {
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
}

.mobile-header .menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.75rem;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1051;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

@media screen and (max-width: 991.98px) {
    /* Show mobile header */
    .mobile-header {
        display: flex !important;
    }
    
    /* Hide/transform sidebar */
    .sidebar {
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        z-index: 1052 !important;
        width: 280px !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        overflow-y: auto !important;
    }
    
    .sidebar.show {
        transform: translateX(0) !important;
    }
    
    /* Adjust main content - remove sidebar margin */
    .main-content {
        margin-left: 0 !important;
        padding-top: 70px !important;
        width: 100% !important;
    }
    
    /* Topbar adjustments - no fixed positioning */
    .topbar {
        padding: 0.75rem 1rem !important;
        position: relative !important;
    }
    
    /* Content padding */
    .content {
        padding: 1rem !important;
    }
    
    /* Stats row - 2 columns */
    .row.g-4 > [class*="col-md-3"],
    .row.g-3 > [class*="col-md-2"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media screen and (max-width: 767.98px) {
    /* Smaller content padding */
    .content {
        padding: 0.75rem !important;
    }
    
    /* Stack stat cards */
    .stat-card, .stat-box {
        margin-bottom: 0.75rem;
    }
    
    /* Full width cards */
    .card {
        border-radius: 12px !important;
    }
    
    /* Responsive tables - horizontal scroll */
    .table-responsive {
        font-size: 0.85rem;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 0.35rem;
        white-space: nowrap;
        vertical-align: middle;
    }
    
    /* Hide less important columns on mobile */
    .table .hide-mobile,
    .table th:nth-child(5),
    .table td:nth-child(5) {
        display: none;
    }
    
    /* Stack buttons */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    /* Modal full width */
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }
    
    .modal-lg {
        max-width: calc(100% - 1rem) !important;
    }
    
    /* Smaller headings */
    h4, .h4 {
        font-size: 1.2rem !important;
    }
    
    h5, .h5 {
        font-size: 1rem !important;
    }
    
    /* Quick actions grid - 2 columns */
    .row.g-4 > [class*="col-md-3"]:not(.stat-card),
    .row.g-3 > [class*="col-md-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .quick-action {
        padding: 0.875rem !important;
    }
    
    .quick-action i {
        font-size: 1.5rem !important;
    }
    
    .quick-action .mt-2 {
        font-size: 0.85rem;
    }
    
    .quick-action small {
        display: none;
    }
    
    /* Balance card */
    .balance-card, .referral-card, .user-header {
        padding: 1.25rem !important;
        border-radius: 16px !important;
    }
    
    .balance-card .display-4,
    .referral-card .display-4,
    .balance-card h2 {
        font-size: 1.75rem !important;
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* Filter rows - stack */
    .card-body .row.g-3 > div[class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        padding: 0.4rem 0.7rem;
    }
    
    /* User header on user-detail page */
    .user-header .row {
        flex-direction: column;
        text-align: center;
    }
    
    .user-header .col-auto {
        margin-bottom: 1rem;
    }
    
    /* Stats row full width on small */
    #statsRow > div {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}

@media screen and (max-width: 575.98px) {
    /* Extra small screens */
    .main-content {
        padding-top: 65px !important;
    }
    
    .content {
        padding: 0.5rem !important;
    }
    
    /* Stats row - still 2 columns */
    .stat-value, .stat-box .value {
        font-size: 1.1rem !important;
    }
    
    .stat-box {
        padding: 0.75rem !important;
    }
    
    .stat-box .small {
        font-size: 0.7rem !important;
    }
    
    /* Smaller buttons */
    .btn-sm {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.8rem !important;
    }
    
    /* Action buttons in tables */
    .table td .btn {
        padding: 0.2rem 0.4rem !important;
        margin-bottom: 2px;
    }
    
    /* Cards header */
    .card-header {
        padding: 0.75rem 1rem !important;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    /* Nav tabs - horizontal scroll */
    .nav-tabs, .nav-pills, #userTabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
    }
    
    .nav-tabs .nav-link, .nav-pills .nav-link {
        white-space: nowrap !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
    
    /* User info in tables */
    .table td .small,
    .table td .fw-medium {
        font-size: 0.75rem !important;
    }
    
    /* Table - hide more columns */
    .table th:nth-child(4),
    .table td:nth-child(4),
    .table th:nth-child(6),
    .table td:nth-child(6) {
        display: none;
    }
    
    /* Hide certain elements */
    .d-none-xs {
        display: none !important;
    }
    
    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.8rem;
    }
    
    /* Topbar title */
    .topbar h5 {
        font-size: 1rem !important;
    }
    
    /* Action cards - full width */
    .row.g-3 > [class*="col-md-3"].action-card-col,
    .row.g-4 > [class*="col-md-3"]:has(.action-card) {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ============================================
   TOUCH FRIENDLY
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 42px;
    }
    
    .btn-sm {
        min-height: 36px;
    }
    
    .nav-link {
        padding: 0.875rem 1.25rem !important;
    }
    
    .form-check-input {
        width: 1.25em;
        height: 1.25em;
    }
    
    /* Remove hover effects on touch */
    .quick-action:hover,
    .stat-card:hover,
    .feature-card:hover,
    .action-card:hover {
        transform: none !important;
        border-color: inherit !important;
    }
    
    /* Sidebar links */
    .sidebar .nav-link {
        padding: 1rem 1.5rem !important;
    }
}

/* ============================================
   LANDSCAPE PHONE
   ============================================ */

@media screen and (max-height: 500px) and (orientation: landscape) {
    .mobile-header {
        height: 50px;
    }
    
    .main-content {
        padding-top: 55px !important;
    }
    
    .modal-body {
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .sidebar {
        padding-top: 0 !important;
    }
    
    .sidebar > div:first-child {
        padding: 0.75rem 1rem !important;
    }
}

/* ============================================
   SCROLLABLE TABLES (Max 8 rows visible)
   ============================================ */

/* Table scroll container - activates after ~8 rows */
.table-scroll {
    max-height: 400px; /* Approx 8 rows × 50px per row */
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    border-radius: 8px;
}

.table-scroll table {
    margin-bottom: 0;
}

/* Sticky header for scrollable tables */
.table-scroll thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
}

.table-scroll thead th {
    background: #f1f5f9;
    border-bottom: 2px solid #e2e8f0;
}

/* Custom scrollbar for table scroll */
.table-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Smaller scroll height on mobile */
@media screen and (max-width: 767.98px) {
    .table-scroll {
        max-height: 320px; /* Smaller on mobile */
    }
}

/* Admin tables - slightly larger */
.table-scroll-lg {
    max-height: 500px; /* ~10 rows */
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sticky-top-mobile {
    position: sticky;
    top: 60px;
    z-index: 10;
    background: inherit;
}

/* Hide on mobile */
@media screen and (max-width: 767.98px) {
    .hide-sm {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media screen and (max-width: 991.98px) {
    .show-mobile {
        display: block !important;
    }
    
    .hide-mobile-all {
        display: none !important;
    }
}
