/* ============================================
   RESPONSIVE STYLES FOR ALL DEVICES
   ============================================ */

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-size: 16px;
    overflow-x: hidden;
}

/* ============================================
   MOBILE FIRST - Extra Small Devices (320px - 575px)
   ============================================ */
@media (max-width: 575px) {
    /* Typography */
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.1rem !important; }
    h4 { font-size: 1rem !important; }
    
    /* Container */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Navigation */
    nav .flex {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    nav h1 {
        font-size: 1.25rem !important;
    }

    nav .flex > div {
        width: 100%;
        justify-content: center !important;
    }

    nav a, nav span {
        font-size: 0.875rem !important;
    }

    /* Welcome Banner */
    .bg-gradient-to-r.rounded-xl.p-6 {
        padding: 1rem !important;
    }

    .bg-gradient-to-r.rounded-xl .flex {
        flex-direction: column !important;
        text-align: center !important;
    }

    .bg-gradient-to-r.rounded-xl h2 {
        font-size: 1.25rem !important;
    }

    /* Statistics Cards */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .stat-card {
        padding: 1rem !important;
    }

    .stat-card h3 {
        font-size: 2rem !important;
    }

    .stat-card p {
        font-size: 0.75rem !important;
    }

    .stat-card .bg-blue-100,
    .stat-card .bg-green-100,
    .stat-card .bg-red-100,
    .stat-card .bg-purple-100,
    .stat-card .bg-orange-100 {
        padding: 0.75rem !important;
    }

    .stat-card i {
        font-size: 1.5rem !important;
    }

    /* Buttons */
    .btn {
        font-size: 0.875rem !important;
        padding: 0.5rem 1rem !important;
    }

    .btn-lg {
        font-size: 1rem !important;
        padding: 0.75rem 1.5rem !important;
    }

    .btn-group {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.25rem !important;
    }

    .btn-group .btn {
        width: 100% !important;
        border-radius: 0.375rem !important;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .table {
        font-size: 0.75rem !important;
        min-width: 800px !important;
    }

    .table th,
    .table td {
        padding: 0.5rem !important;
        white-space: nowrap !important;
    }

    /* Hide less important columns on mobile */
    .table th:nth-child(6),
    .table td:nth-child(6),
    .table th:nth-child(7),
    .table td:nth-child(7),
    .table th:nth-child(8),
    .table td:nth-child(8) {
        display: none !important;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 1rem !important;
        padding: 0.75rem !important;
    }

    .form-label {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
    }

    .input-group-text {
        font-size: 0.875rem !important;
    }

    /* Cards */
    .rounded-xl {
        border-radius: 0.75rem !important;
    }

    .p-6 {
        padding: 1rem !important;
    }

    .p-8 {
        padding: 1.5rem !important;
    }

    /* Modals */
    .modal-dialog {
        margin: 0.5rem !important;
    }

    .modal-content {
        border-radius: 0.75rem !important;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem !important;
    }

    /* Badges */
    .badge {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    /* Alerts */
    .alert {
        font-size: 0.875rem !important;
        padding: 0.75rem !important;
    }

    /* Quick Action Cards */
    .bg-gradient-to-r.rounded-xl.shadow-lg.p-8 {
        padding: 1.25rem !important;
    }

    .bg-gradient-to-r.rounded-xl.shadow-lg h3 {
        font-size: 1.1rem !important;
    }

    .bg-gradient-to-r.rounded-xl.shadow-lg i {
        font-size: 2.5rem !important;
    }

    /* Transaction Cards */
    .flex.items-center.justify-between.p-3 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    /* Pagination */
    .pagination {
        font-size: 0.875rem !important;
    }

    .page-link {
        padding: 0.375rem 0.75rem !important;
    }

    /* Floating Action Button */
    .position-fixed.bottom-0.end-0 {
        bottom: 1rem !important;
        right: 1rem !important;
        width: 50px !important;
        height: 50px !important;
    }

    /* Search and Filter */
    .flex.flex-wrap.gap-3 {
        flex-direction: column !important;
    }

    .flex-1.min-w-\$200px\$ {
        width: 100% !important;
    }

    #filterStatus {
        width: 100% !important;
    }

    /* Dashboard Summary */
    .grid.grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Activity Feed */
    .space-y-3 > div {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    /* Login Page */
    .min-h-screen {
        padding: 1rem !important;
    }

    .max-w-md {
        max-width: 100% !important;
    }
}

/* ============================================
   SMALL DEVICES - Phones (576px - 767px)
   ============================================ */
@media (min-width: 576px) and (max-width: 767px) {
    .container {
        max-width: 540px !important;
    }

    .grid-cols-1 {
        grid-template-columns: 1fr !important;
    }

    .grid-cols-2 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .table {
        font-size: 0.875rem !important;
    }

    .table th,
    .table td {
        padding: 0.75rem !important;
    }

    /* Hide some columns */
    .table th:nth-child(7),
    .table td:nth-child(7),
    .table th:nth-child(8),
    .table td:nth-child(8) {
        display: none !important;
    }

    nav h1 {
        font-size: 1.5rem !important;
    }

    .stat-card h3 {
        font-size: 2.5rem !important;
    }
}

/* ============================================
   MEDIUM DEVICES - Tablets (768px - 991px)
   ============================================ */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 720px !important;
    }

    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    nav .flex {
        flex-wrap: wrap !important;
    }

    .table {
        font-size: 0.875rem !important;
    }

    /* Show more columns */
    .table th,
    .table td {
        padding: 0.75rem !important;
    }

    .stat-card h3 {
        font-size: 2.75rem !important;
    }

    /* Adjust button groups */
    .btn-group {
        flex-direction: row !important;
    }
}

/* ============================================
   LARGE DEVICES - Desktops (992px - 1199px)
   ============================================ */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        max-width: 960px !important;
    }

    .grid-cols-4 {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .table {
        font-size: 0.9rem !important;
    }
}

/* ============================================
   EXTRA LARGE DEVICES - Large Desktops (1200px+)
   ============================================ */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px !important;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION
   ============================================ */
@media (max-width: 767px) and (orientation: landscape) {
    nav {
        padding: 0.5rem 0 !important;
    }

    .py-8 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .stat-card {
        padding: 0.75rem !important;
    }

    .stat-card h3 {
        font-size: 1.5rem !important;
    }

    .modal-dialog {
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body {
        background: white !important;
        color: black !important;
    }

    nav,
    .btn,
    .no-print,
    .position-fixed,
    .modal,
    .alert {
        display: none !important;
    }

    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }

    .shadow-lg,
    .rounded-xl {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    .bg-gradient-to-r {
        background: #f3f4f6 !important;
        color: black !important;
    }

    .table {
        page-break-inside: avoid !important;
    }

    .stat-card {
        page-break-inside: avoid !important;
        border: 1px solid #ddd !important;
    }
}

/* ============================================
   TOUCH DEVICE OPTIMIZATIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px !important;
        min-width: 44px !important;
    }

    a, button {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Remove hover effects on touch devices */
    .hover\:scale-105:hover,
    .hover\:bg-gray-100:hover,
    .hover-lift:hover {
        transform: none !important;
        background-color: inherit !important;
    }

    /* Better spacing for touch */
    .table td,
    .table th {
        padding: 1rem !important;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .pulse {
        animation: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor !important;
    }

    .badge {
        border: 1px solid currentColor !important;
    }
}

/* ============================================
   SPECIFIC COMPONENT FIXES
   ============================================ */

/* Fix for long usernames/text */
@media (max-width: 767px) {
    .text-truncate-mobile {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 150px !important;
    }

    /* Stack flex items on mobile */
    .flex-mobile-column {
        flex-direction: column !important;
    }

    /* Full width on mobile */
    .w-mobile-full {
        width: 100% !important;
    }

    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }
}

/* Show on desktop only */
@media (min-width: 768px) {
    .show-mobile {
        display: none !important;
    }

    .hide-desktop {
        display: none !important;
    }
}

/* ============================================
   UTILITY CLASSES FOR RESPONSIVE
   ============================================ */
.mobile-stack {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .mobile-stack {
        flex-direction: row;
        gap: 1rem;
    }
}

.mobile-center {
    text-align: center;
}

@media (min-width: 768px) {
    .mobile-center {
        text-align: left;
    }
}

/* Responsive padding */
.responsive-padding {
    padding: 1rem;
}

@media (min-width: 768px) {
    .responsive-padding {
        padding: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .responsive-padding {
        padding: 2rem;
    }
}