/* ========================================
   MOBILE RESPONSIVE STYLES
   Add this to all HTML pages for mobile support
   ======================================== */

/* Mobile First - Base responsive utilities */
@media screen and (max-width: 1024px) {
    /* Sidebar adjustments for tablets */
    .sidebar {
        width: 200px !important;
    }
    
    .content {
        margin-left: 200px !important;
    }
}

@media screen and (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed !important;
        left: -280px !important;
        width: 280px !important;
        transition: left 0.3s ease !important;
        z-index: 1000 !important;
        height: 100vh !important;
        overflow-y: auto !important;
    }
    
    .sidebar.active {
        left: 0 !important;
        box-shadow: 4px 0 20px rgba(0,0,0,0.2) !important;
    }
    
    /* Adjust content for mobile */
    .content {
        margin-left: 0 !important;
        padding: 15px !important;
        width: 100% !important;
    }
    
    /* Header responsive */
    .header {
        padding: 15px 20px !important;
        flex-wrap: wrap !important;
    }
    
    .header h1 {
        font-size: 20px !important;
        flex: 1 !important;
    }
    
    .header-actions {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    /* Stat cards grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .stat-card {
        padding: 15px !important;
    }
    
    .stat-card h3 {
        font-size: 14px !important;
    }
    
    .stat-value {
        font-size: 24px !important;
    }
    
    /* Charts responsive */
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .chart-card {
        padding: 15px !important;
    }
    
    /* Tables responsive */
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    table {
        min-width: 600px !important;
        font-size: 13px !important;
    }
    
    th, td {
        padding: 8px 10px !important;
    }
    
    /* Buttons responsive */
    .btn {
        padding: 8px 15px !important;
        font-size: 13px !important;
    }
    
    .header-actions .btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    /* Modal responsive */
    .modal-content {
        width: 95% !important;
        max-width: 500px !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        margin: 20px !important;
    }
    
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    
    .form-row {
        grid-template-columns: 1fr !important;
    }
    
    /* Form inputs */
    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* Recent activity */
    .recent-activity {
        padding: 15px !important;
    }
    
    .activity-item {
        padding: 12px !important;
    }
    
    /* Quick actions */
    .actions-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .action-card {
        padding: 15px !important;
    }
    
    /* Welcome section */
    .welcome {
        padding: 20px !important;
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .welcome h2 {
        font-size: 22px !important;
    }
    
    /* Filter section */
    .filters {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .filter-group {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    /* Invoice/Purchase view */
    .invoice-header {
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    .company-info, .invoice-info {
        text-align: center !important;
    }
    
    .invoice-actions {
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    
    /* Contact cards */
    .contact-card {
        padding: 15px !important;
    }
}

@media screen and (max-width: 480px) {
    /* Extra small mobile devices */
    .header h1 {
        font-size: 18px !important;
    }
    
    .header h1::before {
        font-size: 22px !important;
    }
    
    .stat-value {
        font-size: 20px !important;
    }
    
    .btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
        width: 100% !important;
    }
    
    .header-actions {
        width: 100% !important;
    }
    
    .header-actions .btn {
        flex: 1 !important;
    }
    
    /* Minimize chart canvas padding */
    canvas {
        max-height: 250px !important;
    }
}

/* ========================================
   MOBILE MENU TOGGLE BUTTON
   ======================================== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

.mobile-menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    margin: 5px 0;
    border-radius: 2px;
    transition: all 0.3s;
}

@media screen and (max-width: 768px) {
    .mobile-menu-toggle {
        display: block !important;
    }
    
    /* Add padding to header for menu button */
    .header {
        padding-left: 60px !important;
    }
}

/* ========================================
   MOBILE OVERLAY
   ======================================== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ========================================
   TOUCH-FRIENDLY IMPROVEMENTS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    button, .btn, a {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    /* Remove hover effects on touch devices */
    .stat-card:hover,
    .action-card:hover,
    .contact-card:hover {
        transform: none !important;
    }
    
    /* Better tap highlights */
    button, .btn, a {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }
}

/* ========================================
   LANDSCAPE MODE ADJUSTMENTS
   ======================================== */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .modal-content {
        max-height: 85vh !important;
    }
}

/* ========================================
   PRINT STYLES (for invoices/reports)
   ======================================== */
@media print {
    .header,
    .sidebar,
    .mobile-menu-toggle,
    .mobile-overlay,
    .btn,
    button {
        display: none !important;
    }
    
    .content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    body {
        background: white !important;
    }
}

/* ========================================
   PROGRESSIVE WEB APP STYLES
   ======================================== */
@media all and (display-mode: standalone) {
    /* Styles when app is installed as PWA */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .header {
        padding-top: calc(15px + env(safe-area-inset-top)) !important;
    }
}

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

