/* mobile.css - Global Mobile Responsiveness Fixes */
/* Created: Dec 6, 2025 | For Builders Bazar */

/* ========================================
   MOBILE BREAKPOINTS
   ======================================== */
/* Mobile: < 768px */
/* Tablet: 768px - 1024px */
/* Desktop: > 1024px */

/* ========================================
   GLOBAL MOBILE FIXES
   ======================================== */

/* Ensure all text is readable on mobile */
@media (max-width: 768px) {
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* Removed aggressive !important rules - let Tailwind handle sizing */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    
    /* Prevent horizontal scroll */
    body, html {
        overflow-x: hidden;
        max-width: 100vw;
    }
}

/* ========================================
   TABLES - MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* Make tables scrollable horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    table {
        min-width: 600px;
        font-size: 0.875rem;
    }
    
    table th,
    table td {
        padding: 0.5rem !important;
        white-space: nowrap;
    }
    
    /* Stack table rows vertically for better mobile UX */
    .mobile-stack-table {
        display: block;
        width: 100%;
    }
    
    .mobile-stack-table thead {
        display: none;
    }
    
    .mobile-stack-table tbody,
    .mobile-stack-table tr,
    .mobile-stack-table td {
        display: block;
        width: 100%;
    }
    
    .mobile-stack-table tr {
        margin-bottom: 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.5rem;
        padding: 1rem;
        background: white;
    }
    
    .mobile-stack-table td {
        text-align: left !important;
        padding: 0.5rem 0 !important;
        border: none !important;
    }
    
    .mobile-stack-table td:before {
        content: attr(data-label);
        font-weight: bold;
        display: inline-block;
        margin-right: 0.5rem;
        color: #64748b;
    }
}

/* ========================================
   FORMS - MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* Make form inputs touch-friendly */
    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 - keep this one */
        min-height: 44px; /* Touch-friendly size */
        padding: 0.75rem;
    }
    
    /* Stack form fields vertically */
    .form-row {
        flex-direction: column !important;
    }
    
    .form-row > * {
        width: 100% !important;
        margin-bottom: 1rem;
    }
    
    /* Make buttons touch-friendly */
    button,
    .btn,
    a.button {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* File upload buttons */
    input[type="file"] {
        font-size: 14px;
        padding: 0.5rem;
    }
}

/* ========================================
   MODALS - MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .modal,
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100vh !important;
        border-radius: 0 !important;
    }
    
    .modal-content {
        height: 100%;
        overflow-y: auto;
        border-radius: 0 !important;
    }
    
    .modal-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: white;
        border-bottom: 1px solid #e2e8f0;
    }
}

/* ========================================
   CARDS & PANELS - MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .card,
    .panel,
    .glass-panel {
        margin: 0.5rem !important;
        padding: 1rem !important;
        border-radius: 1rem !important;
    }
    
    /* Stack cards vertically */
    .card-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

/* ========================================
   NAVIGATION - MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* Hide desktop navigation */
    .desktop-nav {
        display: none !important;
    }
    
    /* Show mobile navigation */
    .mobile-nav {
        display: flex !important;
    }
    
    /* Bottom navigation bar */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: white;
        border-top: 1px solid #e2e8f0;
        padding: 0.5rem;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        text-decoration: none;
        color: #64748b;
        font-size: 0.75rem;
    }
    
    .bottom-nav a.active {
        color: #0d9488;
    }
    
    .bottom-nav i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }
}

/* ========================================
   SPACING & PADDING - MOBILE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Reduce padding on mobile */
    .container,
    .max-w-7xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Reduce margins */
    .section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* Adjust grid gaps */
    .grid {
        gap: 1rem !important;
    }
}

/* ========================================
   IMAGES & MEDIA - MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Responsive video embeds */
    .video-container {
        position: relative;
        padding-bottom: 56.25%; /* 16:9 aspect ratio */
        height: 0;
        overflow: hidden;
    }
    
    .video-container iframe,
    .video-container video {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* ========================================
   UTILITY CLASSES - MOBILE SPECIFIC
   ======================================== */

/* Hide on mobile */
.hide-mobile {
    display: none !important;
}

/* Show only on mobile */
@media (min-width: 769px) {
    .show-mobile {
        display: none !important;
    }
}

/* Full width on mobile */
@media (max-width: 768px) {
    .mobile-full-width {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-text-left {
        text-align: left !important;
    }
}

/* ========================================
   TOUCH INTERACTIONS
   ======================================== */

/* Increase touch target size */
@media (max-width: 768px) {
    a, button, .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    @media (hover: none) {
        *:hover {
            background-color: inherit !important;
        }
    }
}

/* ========================================
   SPECIFIC PAGE FIXES
   ======================================== */

/* Dashboard Mobile Fixes */
@media (max-width: 768px) {
    .dashboard-stats {
        grid-template-columns: 1fr !important;
    }
    
    .quick-actions {
        grid-template-columns: 1fr !important;
    }
}

/* Projects Page Mobile Fixes */
@media (max-width: 768px) {
    .project-card {
        margin: 0.5rem 0 !important;
    }
    
    .project-actions {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
}

/* Requirements/Bids Page Mobile Fixes */
@media (max-width: 768px) {
    .bid-card {
        padding: 1rem !important;
    }
    
    .bid-actions {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    .bid-actions button {
        width: 100% !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    /* Hide navigation and non-essential elements */
    nav, .sidebar, .mobile-nav, .bottom-nav, .no-print {
        display: none !important;
    }
    
    /* Ensure content fits on page */
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    /* Prevent page breaks inside elements */
    .card, .panel, table, .no-break {
        page-break-inside: avoid;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus states for keyboard navigation */
@media (max-width: 768px) {
    *:focus {
        outline: 2px solid #0d9488;
        outline-offset: 2px;
    }
    
    /* Skip to content link */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: #0d9488;
        color: white;
        padding: 8px;
        text-decoration: none;
        z-index: 100;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
}
