/* ============================================
   Responsive Design - Mobile First Approach
   ============================================ */

/* Base Responsive Utilities */
.mobile-only { display: none !important; }
.desktop-only { display: block !important; }

/* Touch-friendly minimum sizes */
button, .btn, a.btn {
    min-height: 44px;
    min-width: 44px;
}

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
}

/* ============================================
   Mobile Devices (< 480px)
   ============================================ */
@media (max-width: 480px) {
    /* Show/Hide utilities */
    .mobile-only { display: block !important; }
    .desktop-only { display: none !important; }
    
    /* Container adjustments */
    .container {
        padding: 0 1rem !important;
    }
    
    /* Typography scaling */
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.1rem !important; }
    
    /* Hero Section */
    .hero {
        padding: 40px 0 60px !important;
        min-height: auto !important;
    }
    
    .hero-text h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    .hero-text p {
        font-size: 1rem !important;
    }
    
    .hero-trust-badge {
        font-size: 0.8rem !important;
    }
    
    /* Invoice Paper/Editor */
    .paper-invoice, .invoice-paper {
        padding: 20px !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    .invoice-header {
        flex-direction: column !important;
        gap: 1.5rem !important;
    }
    
    .meta-section {
        align-items: flex-start !important;
        text-align: left !important;
    }
    
    .invoice-title, .invoice-title-text {
        font-size: 1.75rem !important;
    }
    
    /* Client Grid */
    .client-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    
    /* Tables - Horizontal scroll */
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    .items-table {
        min-width: 600px;
    }
    
    .items-table th,
    .items-table td {
        font-size: 0.85rem !important;
        padding: 0.5rem 0.25rem !important;
    }
    
    /* Features Grid */
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
    
    /* Pricing Grid */
    .pricing-grid {
        grid-template-columns: 1fr !important;
    }
    
    .pricing-card.featured {
        transform: none !important;
    }
    
    /* Conversion/CTA Section */
    .conversion-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
    
    .conversion-section h2 {
        font-size: 1.75rem !important;
    }
    
    /* Footer */
    .footer-grid, .unified-footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
    
    /* Dashboard Stats */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .dashboard-layout {
        grid-template-columns: 1fr !important;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        text-align: center;
        padding: 12px 16px !important;
    }
    
    .btn-lg {
        padding: 14px 20px !important;
    }
    
    /* Floating Actions */
    .floating-actions {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        flex-direction: column !important;
        border-radius: 0 !important;
        padding: 1rem !important;
        gap: 0.75rem !important;
    }
    
    .floating-actions .btn {
        width: 100% !important;
    }
    
    /* Forms */
    input, textarea, select {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
    
    /* Totals Section */
    .totals-section-wrapper {
        justify-content: center !important;
    }
    
    .totals-grid {
        width: 100% !important;
    }
    
    /* Invoice Footer */
    .invoice-footer {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
}

/* ============================================
   Tablet Devices (481px - 768px)
   ============================================ */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        padding: 0 1.5rem !important;
    }
    
    /* Hero adjustments */
    .hero-text h1 {
        font-size: 2.5rem !important;
    }
    
    /* Stats Grid - 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Features - 2 columns */
    .features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Pricing - 2 columns */
    .pricing-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Footer - 2 columns */
    .footer-grid, .unified-footer-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Dashboard layout - single column */
    .dashboard-layout {
        grid-template-columns: 1fr !important;
    }
    
    /* Tables - still scrollable */
    .table-container {
        overflow-x: auto;
    }
}

/* ============================================
   Small Desktop (769px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 960px;
    }
    
    /* Stats Grid - 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Features - 3 columns */
    .features-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Dashboard - maintain 2 column layout */
    .dashboard-layout {
        grid-template-columns: 2fr 1fr !important;
    }
}

/* ============================================
   Landscape Mobile (max-height: 500px)
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto !important;
        padding: 30px 0 !important;
    }
    
    .hero-text h1 {
        font-size: 1.5rem !important;
    }
    
    .floating-actions {
        position: relative !important;
        margin-top: 2rem;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .floating-actions,
    .mobile-menu-btn,
    .unified-header,
    .unified-footer,
    .add-item-btn,
    .remove-row-btn {
        display: none !important;
    }
    
    .invoice-paper {
        box-shadow: none !important;
        padding: 0 !important;
    }
    
    body {
        background: white !important;
    }
}

/* ============================================
   Accessibility Improvements
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor !important;
    }
}

/* ============================================
   Scrollable Tables Enhancement
   ============================================ */
.table-wrapper {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table-wrapper::after {
        content: '← Scroll →';
        position: absolute;
        bottom: 0;
        right: 0;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 8px;
        font-size: 0.75rem;
        border-radius: 4px 0 0 0;
        pointer-events: none;
        opacity: 0.5;
    }
}

/* ============================================
   Mobile Menu Enhancements
   ============================================ */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block !important;
        font-size: 1.5rem;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0.5rem;
    }
    
    .unified-nav-links {
        display: none;
    }
    
    .unified-nav-links.active {
        display: flex !important;
        flex-direction: column !important;
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        padding: 1rem !important;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
        gap: 1rem !important;
        z-index: 1001 !important;
    }
    
    .unified-nav-link {
        padding: 0.75rem !important;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .unified-nav-actions {
        flex-direction: column !important;
        width: 59% !important;
        gap: 0.75rem !important;
    }
    
    .unified-nav-actions .btn {
        width: 100% !important;
    }
}

/* ============================================
   Card Stacking on Mobile
   ============================================ */
@media (max-width: 768px) {
    .content-card {
        margin-bottom: 1rem !important;
    }
    
    .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }
    
    .card-header .btn {
        width: 100% !important;
    }
}

/* ============================================
   Form Improvements for Mobile
   ============================================ */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .form-group {
        width: 100% !important;
    }
}
