/* ===================================================================
   GLOBAL MOBILE RESPONSIVE CSS FOR KEITH'S CLOSET
   This file provides mobile-friendly styles for all pages
   =================================================================== */

/* ===================================================================
   1. BASE MOBILE STYLES
   =================================================================== */
   
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent horizontal scroll */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* ===================================================================
   2. CONTAINER & LAYOUT RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .container,
    .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    main.container {
        padding: 10px 15px !important;
        margin-top: 80px !important;
    }
    
    .row {
        margin-left: -10px;
        margin-right: -10px;
    }
    
    .col, [class*="col-"] {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* ===================================================================
   3. TYPOGRAPHY RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }
    
    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem !important;
        line-height: 1.3;
    }
    
    h4 {
        font-size: 1.1rem !important;
    }
    
    h5, h6 {
        font-size: 1rem !important;
    }
    
    p, body {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    small, .small {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.3rem !important;
    }
    
    h3 {
        font-size: 1.15rem !important;
    }
}

/* ===================================================================
   4. TABLE RESPONSIVE (MOBILE-FIRST)
   =================================================================== */

@media (max-width: 768px) {
    /* Wrapper for horizontal scrolling */
    .table-responsive,
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block;
        width: 100%;
        border-radius: 0 !important;
        margin-left: -15px;
        margin-right: -15px;
        border-left: none !important;
        border-right: none !important;
    }
    
    /* Table styling for mobile */
    table {
        min-width: 700px;
        font-size: 0.85rem;
    }
    
    table thead th {
        font-size: 0.8rem;
        padding: 8px 6px !important;
        white-space: nowrap;
    }
    
    table tbody td {
        font-size: 0.85rem;
        padding: 8px 6px !important;
        white-space: nowrap;
    }
    
    /* Sticky first column for better mobile experience */
    table th:first-child,
    table td:first-child {
        position: sticky;
        left: 0;
        z-index: 10;
        background: white;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    }
    
    table thead th:first-child {
        z-index: 11;
    }
}

@media (max-width: 480px) {
    table {
        min-width: 600px;
        font-size: 0.8rem;
    }
    
    table thead th,
    table tbody td {
        font-size: 0.75rem;
        padding: 6px 4px !important;
    }
}

/* ===================================================================
   5. FORM CONTROLS RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 10px 12px !important;
        height: auto !important;
        min-height: 44px; /* iOS touch target size */
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 5px;
        font-weight: 500;
    }
    
    .form-row > .col,
    .form-row > [class*="col-"] {
        margin-bottom: 15px;
    }
    
    /* Make form columns stack on mobile */
    .form-row {
        display: block !important;
    }
    
    .form-row .col,
    .form-row [class*="col-"] {
        max-width: 100% !important;
        flex-basis: 100% !important;
    }
}

/* ===================================================================
   6. BUTTON RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .btn {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
        min-height: 44px; /* iOS touch target */
        white-space: normal;
        word-wrap: break-word;
    }
    
    .btn-lg {
        padding: 12px 20px !important;
        font-size: 1rem !important;
        min-height: 48px;
    }
    
    .btn-sm {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        min-height: 38px;
    }
    
    /* Make buttons full width on mobile for better touch */
    .btn-block-mobile {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }
    
    /* Button groups */
    .btn-group {
        display: flex;
        flex-direction: column;
    }
    
    .btn-group .btn {
        border-radius: 4px !important;
        margin-bottom: 5px;
    }
}

/* ===================================================================
   7. CARD RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .card {
        margin-bottom: 15px;
        border-radius: 8px;
    }
    
    .card-header {
        padding: 12px 15px;
        font-size: 1rem;
    }
    
    .card-body {
        padding: 15px;
    }
    
    .card-footer {
        padding: 12px 15px;
    }
    
    .card-title {
        font-size: 1.15rem;
        margin-bottom: 10px;
    }
    
    .card-text {
        font-size: 0.9rem;
    }
}

/* ===================================================================
   8. MODAL RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 8px;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 12px 15px;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 5px 0;
    }
    
    .modal-title {
        font-size: 1.15rem;
    }
}

/* ===================================================================
   9. NAVIGATION RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .navbar {
        padding: 10px 15px;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
        padding: 8px 0;
    }
    
    .navbar-nav {
        padding: 10px 0;
    }
    
    .navbar-nav .nav-item {
        margin-bottom: 5px;
    }
    
    .navbar-nav .nav-link {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .navbar-toggler {
        padding: 8px 12px;
        font-size: 1.1rem;
    }
}

/* ===================================================================
   10. ALERT & NOTIFICATION RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .alert {
        margin-bottom: 15px;
        padding: 12px 15px;
        font-size: 0.9rem;
        border-radius: 6px;
    }
    
    .alert-heading {
        font-size: 1rem;
    }
    
    /* SweetAlert2 Mobile Adjustments */
    .swal2-popup {
        font-size: 0.9rem !important;
        padding: 20px !important;
    }
    
    .swal2-title {
        font-size: 1.3rem !important;
    }
    
    .swal2-content {
        font-size: 0.9rem !important;
    }
    
    .swal2-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .swal2-actions button {
        width: 100%;
        margin: 0 !important;
    }
}

/* ===================================================================
   11. PAGINATION RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-item {
        margin: 2px;
    }
    
    .page-link {
        padding: 6px 10px;
        font-size: 0.85rem;
        min-width: 36px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===================================================================
   12. BREADCRUMB RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .breadcrumb {
        padding: 8px 12px;
        font-size: 0.85rem;
        flex-wrap: wrap;
    }
    
    .breadcrumb-item {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ===================================================================
   13. IMAGE & MEDIA RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .img-fluid {
        width: 100%;
    }
    
    /* Video embeds */
    iframe,
    video {
        max-width: 100%;
        height: auto;
    }
}

/* ===================================================================
   14. SPACING UTILITIES FOR MOBILE
   =================================================================== */

@media (max-width: 768px) {
    /* Reduce spacing on mobile */
    .mt-5, .my-5 {
        margin-top: 2rem !important;
    }
    
    .mb-5, .my-5 {
        margin-bottom: 2rem !important;
    }
    
    .pt-5, .py-5 {
        padding-top: 2rem !important;
    }
    
    .pb-5, .py-5 {
        padding-bottom: 2rem !important;
    }
    
    .mt-4, .my-4 {
        margin-top: 1.5rem !important;
    }
    
    .mb-4, .my-4 {
        margin-bottom: 1.5rem !important;
    }
}

/* ===================================================================
   15. SELECT2 DROPDOWN RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .select2-container {
        font-size: 16px !important;
    }
    
    .select2-container .select2-selection--single {
        height: 44px !important;
        padding: 8px 12px !important;
    }
    
    .select2-container .select2-selection__rendered {
        line-height: 28px !important;
        padding-left: 0 !important;
    }
    
    .select2-container .select2-selection__arrow {
        height: 42px !important;
    }
    
    .select2-dropdown {
        font-size: 16px !important;
    }
    
    .select2-results__option {
        padding: 12px 15px !important;
    }
}

/* ===================================================================
   16. DATATABLE RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .dataTables_wrapper {
        font-size: 0.85rem;
    }
    
    .dataTables_length,
    .dataTables_filter {
        margin-bottom: 15px;
    }
    
    .dataTables_length select,
    .dataTables_filter input {
        font-size: 16px !important;
        padding: 8px 12px !important;
        min-height: 44px;
    }
    
    .dataTables_info {
        font-size: 0.8rem;
        padding: 10px 0;
    }
    
    .dataTables_paginate {
        margin-top: 15px;
    }
}

/* ===================================================================
   17. UTILITY CLASSES
   =================================================================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
    
    .show-mobile-inline {
        display: inline-block !important;
    }
    
    .show-mobile-flex {
        display: flex !important;
    }
}

/* ===================================================================
   18. TOUCH-FRIENDLY ENHANCEMENTS
   =================================================================== */

@media (max-width: 768px) {
    /* Increase touch targets */
    a, button, input[type="checkbox"], input[type="radio"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent text selection on double-tap */
    .no-select {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Remove hover effects on touch devices */
    @media (hover: none) {
        .btn:hover,
        .card:hover,
        a:hover {
            transform: none !important;
        }
    }
}

/* ===================================================================
   19. SCROLLBAR STYLING FOR MOBILE
   =================================================================== */

@media (max-width: 768px) {
    /* Webkit scrollbar for horizontal scrolling */
    .table-responsive::-webkit-scrollbar,
    .table-container::-webkit-scrollbar {
        height: 6px;
    }
    
    .table-responsive::-webkit-scrollbar-track,
    .table-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb,
    .table-container::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 3px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover,
    .table-container::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}

/* ===================================================================
   20. LOADING & SPINNER RESPONSIVE
   =================================================================== */

@media (max-width: 768px) {
    .spinner-border,
    .spinner-grow {
        width: 2rem;
        height: 2rem;
    }
    
    .spinner-border-sm,
    .spinner-grow-sm {
        width: 1rem;
        height: 1rem;
    }
}

/* ===================================================================
   21. FIXED ELEMENTS MOBILE
   =================================================================== */

@media (max-width: 768px) {
    /* Adjust body padding for fixed headers */
    body.has-fixed-header {
        padding-top: 70px;
    }
    
    /* Fixed bottom action bar for mobile */
    .mobile-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 12px 15px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1000;
    }
    
    /* Add padding to body when mobile action bar is present */
    body.has-mobile-action-bar {
        padding-bottom: 70px;
    }
}

/* ===================================================================
   22. PERFORMANCE OPTIMIZATIONS & ANIMATION CONTROL
   =================================================================== */

@media (max-width: 768px) {
    /* Slow down decorative animations for better mobile experience */
    /* Keep functional animations quick, slow down decorative ones */
    
    /* Quick functional animations (buttons, modals, etc.) */
    .btn,
    .modal,
    .alert,
    .dropdown-menu,
    .tooltip,
    .popover {
        animation-duration: 0.3s !important;
        transition-duration: 0.3s !important;
    }
    
    /* Slow down decorative/background animations */
    body,
    .bg-layer,
    .background,
    .floating,
    .particle,
    .wave,
    [class*="float"],
    [class*="animate"] {
        animation-duration: 20s !important;
        animation-timing-function: ease-in-out !important;
    }
    
    /* Specific animation types - make them slower */
    [class*="gradient"],
    [class*="shimmer"],
    [class*="glow"] {
        animation-duration: 15s !important;
    }
    
    /* Floating/flying animations - very slow */
    [class*="fly"],
    [class*="bird"],
    [class*="heart"],
    [class*="icon-float"] {
        animation-duration: 30s !important;
        opacity: 0.3 !important;
    }
    
    /* Pulse/bounce animations - moderate speed */
    [class*="pulse"],
    [class*="bounce"],
    [class*="shake"] {
        animation-duration: 3s !important;
    }
    
    /* Disable parallax and complex 3D animations on mobile */
    .parallax,
    [data-parallax],
    [class*="3d"] {
        background-attachment: scroll !important;
        transform: none !important;
        animation: none !important;
    }
    
    /* Reduce animation opacity for better performance */
    .animated,
    [class*="animate"] {
        opacity: 0.7 !important;
    }
}

/* Extra performance optimization for very small screens */
@media (max-width: 480px) {
    /* Disable or heavily reduce decorative animations */
    .bg-layer,
    .floating-shapes,
    [class*="particle"],
    [class*="decoration"] {
        display: none !important;
    }
    
    /* Make decorative animations extremely slow (not all elements) */
    body,
    .background,
    [class*="float"],
    [class*="fly"],
    [class*="animate"] {
        animation-duration: 40s !important;
    }
    
    /* Keep functional animations quick */
    .btn,
    .modal,
    .alert,
    .dropdown-menu,
    .form-control,
    input,
    select,
    textarea {
        animation-duration: 0.3s !important;
        transition-duration: 0.3s !important;
    }
}

/* ===================================================================
   23. PRINT STYLES
   =================================================================== */

@media print {
    .hide-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    .container {
        max-width: 100%;
    }
}

