/* =============================================
   MOBILE RESPONSIVE & UI/UX ENHANCEMENTS
   For NOUN Muslim Staff Halal Cooperative Society
   ============================================= */

/* =============================================
   1. BASE MOBILE IMPROVEMENTS
   ============================================= */

/* Ensure proper viewport behavior */
@viewport {
    width: device-width;
    zoom: 1;
}

/* Improve touch targets - minimum 44x44px */
button,
a,
input,
select,
textarea,
.clickable {
    min-height: 44px;
    min-width: 44px;
}

/* Better tap highlighting */
* {
    -webkit-tap-highlight-color: rgba(16, 185, 129, 0.2);
    -webkit-touch-callout: none;
}

/* Smooth scrolling for better UX */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* =============================================
   2. DASHBOARD LAYOUT MOBILE ENHANCEMENTS
   ============================================= */

@media (max-width: 768px) {
    /* Sidebar Mobile Improvements */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1001;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Main Content Mobile */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }

    /* Header Mobile Improvements */
    .top-header {
        height: auto;
        min-height: 60px;
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .page-title {
        font-size: 1.125rem !important;
        line-height: 1.4;
    }

    .breadcrumb {
        display: none; /* Hide on mobile for space */
    }

    /* Content Area Mobile */
    .content-area {
        padding: 1rem !important;
    }

    .content-title {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem;
    }

    .content-description {
        font-size: 0.875rem !important;
    }

    /* Sidebar Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        border: 1px solid var(--border-color, #e5e7eb);
        background: white;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
        background: #f3f4f6;
    }
}

/* =============================================
   3. NAVIGATION MOBILE ENHANCEMENTS
   ============================================= */

@media (max-width: 768px) {
    /* Public Navigation */
    nav .max-w-7xl {
        padding: 0 1rem;
    }

    nav .hidden.space-x-8 {
        display: none !important;
    }

    /* Responsive Nav Menu */
    .responsive-nav-menu {
        display: block;
        width: 100%;
        background: white;
        border-top: 1px solid #e5e7eb;
    }

    /* Dropdown Mobile */
    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-menu {
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
    }
}

/* =============================================
   4. TABLES RESPONSIVE DESIGN
   ============================================= */

/* Table Wrapper for Horizontal Scroll */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .table-responsive {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
    }

    /* Table Mobile Adjustments */
    table {
        min-width: 600px; /* Ensure table doesn't squish too much */
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    /* Card View for Tables on Very Small Screens */
    @media (max-width: 480px) {
        .table-card-view table,
        .table-card-view thead,
        .table-card-view tbody,
        .table-card-view th,
        .table-card-view td,
        .table-card-view tr {
            display: block;
        }

        .table-card-view thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }

        .table-card-view tr {
            margin-bottom: 1rem;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            padding: 1rem;
            background: white;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }

        .table-card-view td {
            border: none;
            position: relative;
            padding-left: 50%;
            padding-top: 0.75rem;
            padding-bottom: 0.75rem;
            white-space: normal;
        }

        .table-card-view td:before {
            content: attr(data-label);
            position: absolute;
            left: 1rem;
            font-weight: 600;
            color: #374151;
        }

        .table-card-view td:first-child {
            padding-top: 0.5rem;
        }

        .table-card-view td:last-child {
            padding-bottom: 0.5rem;
        }
    }
}

/* =============================================
   5. CARDS & GRID MOBILE IMPROVEMENTS
   ============================================= */

@media (max-width: 768px) {
    /* Grid Adjustments */
    .grid {
        display: grid;
        gap: 1rem;
    }

    .grid-cols-1,
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .md\:grid-cols-2,
    .lg\:grid-cols-3,
    .lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }

    /* Cards */
    .card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .card-header {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Dashboard Cards */
    .dashboard-card {
        padding: 1.25rem;
        border-radius: 12px;
    }

    /* Stat Cards */
    .stat-card {
        padding: 1rem;
        flex-direction: row;
        gap: 1rem;
    }

    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }

    .stat-number {
        font-size: 1.5rem !important;
    }

    .stat-label {
        font-size: 0.8125rem;
    }
}

/* =============================================
   6. FORMS MOBILE OPTIMIZATION
   ============================================= */

@media (max-width: 768px) {
    /* Form Groups */
    .form-group,
    .mb-4,
    .mb-6 {
        margin-bottom: 1rem !important;
    }

    /* Input Fields */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="date"],
    input[type="time"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
        border-radius: 8px;
        width: 100%;
    }

    /* Labels */
    label {
        font-size: 0.9375rem;
        margin-bottom: 0.5rem;
        display: block;
    }

    /* Buttons */
    button,
    .btn,
    .button {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        border-radius: 8px;
        width: 100%;
        justify-content: center;
    }

    /* Button Groups */
    .button-group,
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .button-group button,
    .btn-group button {
        width: 100%;
    }

    /* Form Actions */
    .form-actions {
        display: flex;
        flex-direction: column-reverse;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }

    .form-actions button,
    .form-actions a {
        width: 100%;
    }
}

/* =============================================
   7. MODALS MOBILE OPTIMIZATION
   ============================================= */

@media (max-width: 768px) {
    .modal,
    [x-data] .modal {
        padding: 0;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100vh;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .modal-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        border-bottom: 1px solid #e5e7eb;
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
    }

    .modal-footer {
        padding: 1rem;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* =============================================
   8. UTILITY CLASSES FOR MOBILE
   ============================================= */

/* Mobile Visibility */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }

    .mobile-hide {
        display: none !important;
    }

    .mobile-show {
        display: block !important;
    }
}

/* Mobile Spacing */
@media (max-width: 768px) {
    .mobile-p-1 { padding: 0.5rem !important; }
    .mobile-p-2 { padding: 1rem !important; }
    .mobile-p-3 { padding: 1.5rem !important; }
    
    .mobile-m-1 { margin: 0.5rem !important; }
    .mobile-m-2 { margin: 1rem !important; }
    .mobile-m-3 { margin: 1.5rem !important; }
    
    .mobile-mb-1 { margin-bottom: 0.5rem !important; }
    .mobile-mb-2 { margin-bottom: 1rem !important; }
    .mobile-mb-3 { margin-bottom: 1.5rem !important; }
    
    .mobile-mt-1 { margin-top: 0.5rem !important; }
    .mobile-mt-2 { margin-top: 1rem !important; }
    .mobile-mt-3 { margin-top: 1.5rem !important; }
}

/* Mobile Text Sizes */
@media (max-width: 768px) {
    .mobile-text-xs { font-size: 0.75rem !important; }
    .mobile-text-sm { font-size: 0.875rem !important; }
    .mobile-text-base { font-size: 1rem !important; }
    .mobile-text-lg { font-size: 1.125rem !important; }
    .mobile-text-xl { font-size: 1.25rem !important; }
}

/* =============================================
   9. LISTS & ITEMS MOBILE IMPROVEMENTS
   ============================================= */

@media (max-width: 768px) {
    /* Application List */
    .application-list .application-item {
        flex-wrap: wrap;
        padding: 1rem;
        gap: 0.75rem;
    }

    .application-details {
        flex: 1 1 100%;
        order: 2;
    }

    .application-avatar {
        width: 40px;
        height: 40px;
        font-size: 0.875rem;
    }

    .application-status {
        order: 3;
        margin-right: 0;
    }

    .application-actions {
        order: 4;
    }

    /* Financial Activities List */
    .financial-activity-item {
        flex-wrap: wrap;
        padding: 1rem;
        gap: 0.75rem;
    }

    .activity-details {
        flex: 1 1 100%;
    }

    .activity-amount {
        width: 100%;
        text-align: left;
        font-size: 1.25rem;
    }

    /* Quick Actions */
    .quick-actions {
        gap: 0.75rem;
    }

    .quick-action-item {
        padding: 0.875rem;
    }

    .quick-action-icon {
        width: 36px;
        height: 36px;
    }

    .quick-action-title {
        font-size: 0.9375rem;
    }

    .quick-action-desc {
        font-size: 0.8125rem;
    }
}

/* =============================================
   10. ALERTS & NOTIFICATIONS MOBILE
   ============================================= */

@media (max-width: 768px) {
    .alert-item {
        padding: 0.875rem !important;
        margin-bottom: 0.75rem;
    }

    .alert-item .flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .alert-item .flex-shrink-0 {
        margin-bottom: 0.25rem;
    }

    .alert-item .ml-3 {
        margin-left: 0 !important;
    }
}

/* =============================================
   11. USER MENU MOBILE IMPROVEMENTS
   ============================================= */

@media (max-width: 768px) {
    .user-menu-dropdown {
        position: fixed !important;
        top: 60px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .user-menu-info {
        display: none !important;
    }

    .user-menu-avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.875rem !important;
    }

    .user-menu-button {
        padding: 0.5rem !important;
    }
}

/* =============================================
   12. CHARTS & GRAPHS MOBILE
   ============================================= */

@media (max-width: 768px) {
    .chart-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    canvas {
        max-width: 100%;
        height: auto !important;
    }
}

/* =============================================
   13. SEARCH & FILTERS MOBILE
   ============================================= */

@media (max-width: 768px) {
    .search-container {
        width: 100%;
        margin-bottom: 1rem;
    }

    .search-input {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .filter-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .filter-button {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* =============================================
   14. PAGINATION MOBILE
   ============================================= */

@media (max-width: 768px) {
    .pagination {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .pagination a,
    .pagination span {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
    }

    /* Hide page numbers on very small screens, keep only prev/next */
    @media (max-width: 480px) {
        .pagination a:not(.prev):not(.next),
        .pagination span:not(.prev):not(.next) {
            display: none;
        }

        .pagination .active {
            display: flex !important;
        }
    }
}

/* =============================================
   15. BADGES & STATUS INDICATORS MOBILE
   ============================================= */

@media (max-width: 768px) {
    .status-badge,
    .badge {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
        border-radius: 12px;
    }

    .nav-badge {
        font-size: 0.6875rem;
        padding: 0.125rem 0.375rem;
    }
}

/* =============================================
   16. FOOTERS MOBILE
   ============================================= */

@media (max-width: 768px) {
    footer {
        padding: 2rem 1rem;
    }

    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }

    footer h3,
    footer h4 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    footer p,
    footer a,
    footer li {
        font-size: 0.875rem;
    }

    footer .text-center.md\:text-left,
    footer .text-center.md\:text-right {
        text-align: center !important;
    }
}

/* =============================================
   17. SPECIAL MOBILE INTERACTIONS
   ============================================= */

/* Pull to refresh indicator (optional) */
.pull-to-refresh {
    display: none;
}

@media (max-width: 768px) {
    .pull-to-refresh {
        display: block;
        text-align: center;
        padding: 1rem;
        color: #6b7280;
        font-size: 0.875rem;
    }
}

/* Bottom navigation bar (if needed) */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 0.5rem;
        justify-content: space-around;
        align-items: center;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        text-decoration: none;
        color: #6b7280;
        font-size: 0.75rem;
        min-width: 60px;
        transition: all 0.2s ease;
    }

    .mobile-bottom-nav a.active {
        color: #10b981;
    }

    .mobile-bottom-nav a i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    /* Add padding to body when bottom nav is present */
    body.has-bottom-nav {
        padding-bottom: 70px;
    }
}

/* =============================================
   18. LOADING STATES MOBILE
   ============================================= */

@media (max-width: 768px) {
    .loading-spinner {
        width: 40px;
        height: 40px;
    }

    .skeleton-loader {
        border-radius: 8px;
    }
}

/* =============================================
   19. ACCESSIBILITY IMPROVEMENTS FOR MOBILE
   ============================================= */

/* Focus indicators */
@media (max-width: 768px) {
    *:focus {
        outline: 2px solid #10b981;
        outline-offset: 2px;
    }

    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #10b981;
        outline-offset: 2px;
    }
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #10b981;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 9999;
}

.skip-to-main:focus {
    top: 0;
}

/* =============================================
   20. PERFORMANCE OPTIMIZATIONS
   ============================================= */

/* GPU acceleration for smooth animations */
@media (max-width: 768px) {
    .sidebar,
    .sidebar-overlay,
    .modal,
    .dropdown {
        will-change: transform, opacity;
        transform: translateZ(0);
        backface-visibility: hidden;
    }
}

/* Reduce animations on slow devices */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =============================================
   21. LANDSCAPE ORIENTATION ADJUSTMENTS
   ============================================= */

@media (max-width: 896px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }

    .top-header {
        min-height: 50px;
        padding: 0.5rem 1rem;
    }

    .content-area {
        padding: 0.75rem !important;
    }

    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* =============================================
   22. VERY SMALL SCREENS (< 375px)
   ============================================= */

@media (max-width: 374px) {
    .page-title {
        font-size: 1rem !important;
    }

    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        margin: 0 auto;
    }

    .btn,
    button {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }
}

/* =============================================
   23. PRINT STYLES (BONUS)
   ============================================= */

@media print {
    .sidebar,
    .mobile-menu-toggle,
    .sidebar-toggle,
    .mobile-bottom-nav,
    .user-menu,
    .header-action,
    button:not(.print-button) {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .card,
    .stat-card,
    .dashboard-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* =============================================
   24. DARK MODE MOBILE SUPPORT
   ============================================= */

@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .sidebar {
        background: #1f2937;
        border-right-color: #374151;
    }

    .top-header {
        background: #1f2937;
        border-bottom-color: #374151;
    }

    .card,
    .stat-card,
    .dashboard-card {
        background: #1f2937;
        border-color: #374151;
    }

    .mobile-menu-toggle {
        background: #1f2937;
        border-color: #374151;
        color: #f3f4f6;
    }

    .user-menu-dropdown {
        background: #1f2937;
        border-color: #374151;
    }

    input,
    select,
    textarea {
        background: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }
}





