/* ================================================================
   MOBILE OPTIMIZATION STYLES FOR COLORS Print Manager
   ================================================================ */

/* ================================================================
   GLOBAL MOBILE STYLES
   ================================================================ */

/* Make sure all content is accessible on small screens */
@media (max-width: 768px) {
    /* Reduce padding on mobile */
    .mobile-p-2 {
        padding: 0.5rem !important;
    }
    
    .mobile-p-3 {
        padding: 0.75rem !important;
    }
    
    /* Stack elements vertically on mobile */
    .mobile-stack {
        flex-direction: column !important;
    }
    
    .mobile-stack > * {
        width: 100% !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Full width buttons on mobile */
    .mobile-btn-full {
        width: 100% !important;
        text-align: center !important;
    }
    
    /* Reduce font sizes for mobile */
    .mobile-text-sm {
        font-size: 0.875rem !important;
    }
    
    .mobile-text-base {
        font-size: 1rem !important;
    }
    
    /* Hide non-essential elements on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    /* Show elements only on mobile */
    .mobile-show {
        display: block !important;
    }
}

/* ================================================================
   TABLE OPTIMIZATION FOR MOBILE
   ================================================================ */

@media (max-width: 768px) {
    /* Make tables scrollable horizontally */
    .table-responsive {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    /* Alternative: Card layout for tables on mobile */
    .table-to-cards tbody tr {
        display: block;
        margin-bottom: 1rem;
        padding: 1rem;
        background: white;
        border-radius: 0.5rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .table-to-cards td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .table-to-cards td:last-child {
        border-bottom: none;
    }
    
    .table-to-cards td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        font-size: 0.75rem;
        margin-right: 1rem;
    }
    
    /* Hide table headers on mobile for card view */
    .table-to-cards thead {
        display: none;
    }
}

/* ================================================================
   FORM OPTIMIZATION FOR MOBILE
   ================================================================ */

@media (max-width: 768px) {
    /* Larger input fields for easier touch */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    textarea,
    select {
        min-height: 44px; /* Minimum touch target size */
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Stack form groups vertically */
    .form-group {
        margin-bottom: 1rem;
    }
    
    /* Full width labels and inputs */
    .form-label {
        display: block;
        margin-bottom: 0.5rem;
    }
    
    /* Larger buttons for touch */
    button,
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
    }
}

/* ================================================================
   CARD LAYOUT FOR MOBILE
   ================================================================ */

@media (max-width: 768px) {
    /* Stack grid items on mobile */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Reduce card padding on mobile */
    .card {
        padding: 1rem !important;
    }
    
    /* Stack card actions vertically */
    .card-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-actions a,
    .card-actions button {
        width: 100%;
        text-align: center;
    }
}

/* ================================================================
   NAVIGATION MOBILE STYLES
   ================================================================ */

@media (max-width: 768px) {
    /* Sidebar takes full screen on mobile */
    .sidebar {
        width: 85% !important;
        max-width: 320px !important;
    }
    
    /* Larger touch targets in navigation */
    .sidebar-link {
        min-height: 48px;
        padding: 0.875rem 1rem;
    }
    
    /* Mobile header adjustments */
    .mobile-header {
        padding: 0.75rem 1rem;
    }
    
    /* User dropdown on mobile */
    .mobile-user-dropdown {
        position: absolute;
        right: 1rem;
        top: 100%;
        background: white;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        border-radius: 0.5rem;
        min-width: 200px;
        z-index: 50;
    }
}

/* ================================================================
   DASHBOARD WIDGETS FOR MOBILE
   ================================================================ */

@media (max-width: 768px) {
    /* Stack dashboard stats vertically */
    .dashboard-stats {
        grid-template-columns: 1fr !important;
    }
    
    /* Larger stat cards on mobile */
    .stat-card {
        padding: 1.5rem !important;
    }
    
    .stat-value {
        font-size: 2rem !important;
    }
    
    .stat-label {
        font-size: 0.875rem !important;
    }
}

/* ================================================================
   ACTION BUTTONS FOR MOBILE
   ================================================================ */

@media (max-width: 768px) {
    /* Stack action buttons vertically */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons a,
    .action-buttons button {
        width: 100%;
        text-align: center;
        padding: 0.75rem 1rem;
    }
    
    /* Minimum touch target size */
    .touch-target {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ================================================================
   MODAL/DIALOG FOR MOBILE
   ================================================================ */

@media (max-width: 768px) {
    /* Full screen modals on mobile */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 1rem !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Stack modal actions */
    .modal-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-actions button {
        width: 100%;
    }
}

/* ================================================================
   LOADING SPINNER FOR MOBILE
   ================================================================ */

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ================================================================
   UTILITY CLASSES FOR MOBILE
   ================================================================ */

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .mobile-header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Remove tap highlight color on mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Better touch scrolling */
* {
    -webkit-overflow-scrolling: touch;
}

/* ================================================================
   PRINT OPTIMIZATION (Mobile-friendly)
   ================================================================ */

@media print {
    .sidebar,
    .mobile-header,
    .no-print {
        display: none !important;
    }
    
    body {
        padding: 0;
        margin: 0;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
}

/* ================================================================
   LANDSCAPE MOBILE OPTIMIZATION
   ================================================================ */

@media (max-width: 768px) and (orientation: landscape) {
    /* Adjust for landscape mode */
    .sidebar {
        max-height: 100vh;
        overflow-y: auto;
    }
    
    /* Reduce header height in landscape */
    .mobile-header {
        height: auto;
        min-height: 56px;
    }
}

/* ================================================================
   ACCESSIBILITY FOR MOBILE
   ================================================================ */

/* Focus indicators for touch devices */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sidebar-link.active {
        border-left-width: 6px;
    }
    
    button,
    .btn {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
