/* ============================================
   RESPONSIVE DESIGN SYSTEM - COMPLETE
   Mobile-First Approach for All Screens
   ============================================ */

/* ============================================
   BREAKPOINTS
   ============================================ */
/* 
   Mobile: 0-480px
   Tablet: 481px-768px
   Desktop: 769px-1024px
   Large Desktop: 1025px+
*/

/* ============================================
   MOBILE FIRST - BASE STYLES (0-480px)
   ============================================ */

/* Container adjustments */
.container,
.admin-container,
.user-container {
    width: 100%;
    padding-left: var(--space-4, 16px);
    padding-right: var(--space-4, 16px);
}

/* Typography - Mobile */
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5, h6 { font-size: 1rem; }

/* Forms - Mobile */
.form-group {
    margin-bottom: var(--space-4, 16px);
}

.input,
textarea,
select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
    width: 100%;
}

/* Buttons - Mobile */
.btn,
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
    min-height: 48px; /* Touch target size */
}

/* Cards - Mobile */
.card,
.admin-card,
.user-card {
    padding: var(--space-4, 16px);
    margin-bottom: var(--space-4, 16px);
}

/* Tables - Mobile: Convert to cards */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table-responsive table {
        display: block;
        width: 100%;
    }
    
    .table-responsive thead {
        display: none;
    }
    
    .table-responsive tbody {
        display: block;
        width: 100%;
    }
    
    .table-responsive tr {
        display: block;
        margin-bottom: var(--space-4, 16px);
        background: var(--bg-card, #1F1F1F);
        border-radius: var(--radius-md, 10px);
        padding: var(--space-4, 16px);
        border: 1px solid var(--border-default, #2A2A2A);
    }
    
    .table-responsive td {
        display: block;
        text-align: left;
        padding: var(--space-2, 8px) 0;
        border: none;
        border-bottom: 1px solid var(--border-default, #2A2A2A);
    }
    
    .table-responsive td:last-child {
        border-bottom: none;
    }
    
    .table-responsive td::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--text-muted, #666);
        display: inline-block;
        min-width: 120px;
    }
}

/* Grid Systems - Mobile */
.grid,
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4, 16px);
}

/* Navigation - Mobile */
.navbar,
.admin-header,
.user-header {
    padding: var(--space-3, 12px) var(--space-4, 16px);
}

.nav-links {
    display: none; /* Hidden by default on mobile */
}

.mobile-menu-toggle {
    display: block;
}

/* Sidebar - Mobile */
.sidebar,
.admin-sidebar,
.user-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    width: 280px;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), left 0.3s ease;
    overflow-y: auto;
}

.sidebar.show,
.admin-sidebar.show,
.user-sidebar.show {
    left: 0;
    transform: translateX(0);
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
}

.sidebar.show ~ .sidebar-overlay,
.admin-sidebar.show ~ .sidebar-overlay,
.user-sidebar.show ~ .sidebar-overlay {
    display: block;
}

/* ============================================
   TABLET STYLES (481px - 768px)
   ============================================ */
@media (min-width: 481px) {
    .container,
    .admin-container,
    .user-container {
        padding-left: var(--space-6, 24px);
        padding-right: var(--space-6, 24px);
    }
    
    /* 2 columns on tablet */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Buttons can be inline on tablet */
    .btn-group .btn {
        width: auto;
    }
    
    .btn-inline {
        width: auto;
        display: inline-block;
    }
}

/* ============================================
   SMALL TABLET / LARGE MOBILE (481px - 640px)
   ============================================ */
@media (min-width: 481px) and (max-width: 640px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
}

/* ============================================
   TABLET PORTRAIT / SMALL DESKTOP (641px - 768px)
   ============================================ */
@media (min-width: 641px) and (max-width: 768px) {
    .card,
    .admin-card,
    .user-card {
        padding: var(--space-6, 24px);
    }
}

/* ============================================
   DESKTOP STYLES (769px - 1024px)
   ============================================ */
@media (min-width: 769px) {
    .container,
    .admin-container,
    .user-container {
        max-width: 1200px;
        margin: 0 auto;
        padding-left: var(--space-8, 32px);
        padding-right: var(--space-8, 32px);
    }
    
    /* Typography - Desktop */
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    
    /* Grid - Desktop */
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
    
    /* Navigation - Desktop */
    .nav-links {
        display: flex;
    }
    
    .mobile-menu-toggle {
        display: none;
    }
    
    /* Sidebar - Desktop */
    .sidebar,
    .admin-sidebar,
    .user-sidebar {
        position: relative;
        left: 0;
        width: var(--sidebar-width, 260px);
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Main content with sidebar */
    .layout-with-sidebar {
        display: flex;
    }
    
    .main-content {
        flex: 1;
        margin-left: var(--space-6, 24px);
    }
    
    /* Buttons - Desktop */
    .btn,
    .btn-primary,
    .btn-secondary {
        width: auto;
        display: inline-block;
    }
    
    .btn-full-mobile {
        width: auto;
    }
}

/* ============================================
   LARGE DESKTOP (1025px+)
   ============================================ */
@media (min-width: 1025px) {
    .container,
    .admin-container,
    .user-container {
        max-width: var(--container-max, 1400px);
    }
    
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Hide/Show by breakpoint */
.hide-mobile { display: none; }
.show-mobile { display: block; }

@media (min-width: 769px) {
    .hide-mobile { display: block; }
    .show-mobile { display: none; }
    .hide-desktop { display: none; }
    .show-desktop { display: block; }
}

/* Text alignment */
.text-center-mobile {
    text-align: center;
}

@media (min-width: 769px) {
    .text-center-mobile {
        text-align: left;
    }
}

/* Spacing utilities */
.mobile-mt-0 { margin-top: 0; }
.mobile-mb-0 { margin-bottom: 0; }
.mobile-p-0 { padding: 0; }

@media (min-width: 769px) {
    .mobile-mt-0 { margin-top: revert; }
    .mobile-mb-0 { margin-bottom: revert; }
    .mobile-p-0 { padding: revert; }
}

/* ============================================
   SPECIFIC COMPONENT RESPONSIVE FIXES
   ============================================ */

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4, 16px);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: var(--space-6, 24px);
}

@media (max-width: 480px) {
    .auth-card {
        padding: var(--space-4, 16px);
    }
}

/* Product cards */
.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4, 16px);
}

@media (min-width: 481px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 769px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1025px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* KPI Cards / Stats */
.stats-grid,
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4, 16px);
}

@media (min-width: 481px) {
    .stats-grid,
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 769px) {
    .stats-grid,
    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Modals */
.modal-content {
    width: 90%;
    max-width: 600px;
    margin: var(--space-4, 16px) auto;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: var(--space-2, 8px) auto;
        max-height: calc(100vh - 16px);
    }
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4, 16px);
}

@media (min-width: 769px) {
    .form-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Search and filters */
.search-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4, 16px);
}

@media (min-width: 481px) {
    .search-filters {
        grid-template-columns: 2fr 1fr;
    }
}

/* Pagination */
.pagination {
    flex-wrap: wrap;
    justify-content: center;
}

.pagination .btn {
    min-width: 40px;
    padding: 8px 12px;
}

/* ============================================
   TOUCH FRIENDLY (Mobile)
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    a, button, .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    *:hover {
        /* Hover styles are less relevant on touch */
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar,
    .admin-sidebar,
    .user-sidebar,
    .navbar,
    .admin-header,
    .user-header,
    .btn,
    .pagination {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-default: #ffffff;
        --text-primary: #ffffff;
        --bg-card: #000000;
    }
}

/* ============================================
   USER PAGES - COMPLETE RESPONSIVENESS
   ============================================ */

/* Cards - All User Pages */
@media (max-width: 768px) {
    /* Package Cards */
    .packages-grid-modern,
    .packages-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 0 0.5rem;
    }
    
    .package-card-simple,
    .package-card {
        max-width: 100% !important;
        min-height: auto;
        margin: 0 auto;
    }
    
    .package-banner {
        height: 180px;
    }
    
    .package-name {
        font-size: 1.25rem;
    }
    
    .package-price-value {
        font-size: 1.5rem;
    }
    
    .package-cta-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* Stats Grid */
    .stats-grid-commissions,
    .quick-stats-grid-modern,
    .stats-grid,
    .kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
        min-height: auto;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Account Cards */
    .account-sections {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    .account-card {
        width: 100%;
        padding: 1.25rem;
    }
    
    /* Commission Table */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        font-size: 0.875rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }
    
    /* Dashboard Cards */
    .dashboard-grid-modern {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .quick-actions-modern {
        grid-template-columns: 1fr !important;
    }
    
    .action-card-modern {
        padding: 1rem;
        min-height: auto;
    }
    
    /* Referral Card */
    .referral-card-modern {
        padding: 1.25rem;
    }
    
    .referral-link-modern {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .referral-link-modern input {
        width: 100%;
        font-size: 0.875rem;
    }
    
    .btn-copy-modern {
        width: 100%;
        padding: 0.875rem;
    }
    
    /* Financial Cards */
    .financial-summary {
        grid-template-columns: 1fr !important;
    }
    
    /* Form Groups */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9375rem;
        margin-bottom: 0.5rem;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.875rem;
        width: 100%;
    }
    
    /* Buttons */
    .btn,
    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Modals */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 1rem auto;
        padding: 1.25rem;
    }
    
    .modal-header h3 {
        font-size: 1.25rem;
    }
    
    /* Payment Options */
    .payment-methods {
        grid-template-columns: 1fr !important;
    }
    
    .payment-option {
        padding: 1rem;
    }
    
    /* Info Banners */
    .info-banner {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .info-banner i {
        font-size: 1.5rem;
    }
    
    /* Section Headers */
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    /* Empty States */
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state i {
        font-size: 2.5rem;
    }
    
    .empty-state h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .package-card-simple,
    .package-card {
        min-height: auto;
    }
    
    .package-banner {
        height: 150px;
    }
    
    .package-name {
        font-size: 1.125rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .dashboard-title {
        font-size: 1.5rem !important;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .page-header p {
        font-size: 0.9375rem;
    }
    
    /* Tables become cards */
    .table-responsive table {
        display: block;
    }
    
    .table-responsive thead {
        display: none;
    }
    
    .table-responsive tbody {
        display: block;
    }
    
    .table-responsive tr {
        display: block;
        margin-bottom: 1rem;
        background: #FFFFFF;
        border: 1px solid #E5E5E5;
        border-radius: 8px;
        padding: 1rem;
    }
    
    .table-responsive td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid #F5F5F5;
    }
    
    .table-responsive td:last-child {
        border-bottom: none;
    }
    
    .table-responsive td::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #666;
        display: inline-block;
        min-width: 100px;
    }
}

